Direct3D proof of concept / Steam BPM overlay

Post your working scripts, libraries and tools
lexikos
Posts: 7057
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Direct3D proof of concept / Steam BPM overlay

04 Mar 2017, 20:12

Direct3D Proof of Concept

Demonstrates rendering a minimal 3D scene (a spinning triangle) to a semi-transparent window. There are two methods shown:
  • If DWM is disabled (only possible on Windows Vista and 7), the scene is rendered into an off-screen bitmap which is used to update a layered window. You can also test this by setting Demo = Vista near the top of the script.
  • If DWM is enabled, a trick is used to make the window semi-transparent while allowing Direct3D to render to it directly. The drawback is that as far as the mouse is concerned, the entire window is solid (even the transparent parts). The WS_EX_TRANSPARENT (mouse pass-through) style does not work on these windows either.
I recently had cause to look for a minimal program which uses Direct3D, so I dug up this old proof of concept.

I wrote this some time between 2008 and 2010 (with the exception of the Struct() function since I lost the original), so it does not support x64. I have tested it on AutoHotkey v1.1.25.01, Unicode 32-bit.

Code: Select all

;
; Script Requirements:
;
;   DirectX - March 2008 or later. (d3dx9_37.dll)
;     DirectX End-User Runtime Web Installer (March 2008):
;     http://www.microsoft.com/downloads/details.aspx?FamilyId=2DA43D38-DB71-4C1B-BC6A-9B6652CD92A3&displaylang=en
;

if !DllCall("dwmapi\DwmIsCompositionEnabled","int*",Demo) && Demo
    Demo = Vista
else if A_OSType = WIN32_NT
    Demo = Layered

Gui, +LastFound
GuiHwnd := WinExist()

if Demo=Vista
    Gui, -Caption +AlwaysOnTop
else if Demo=Layered
    Gui, -Caption +E0x80000 ; WS_EX_LAYERED
else
    Gui, +Resize +MinSizex50

GuiW := 600
GuiH := 400
Gui, Show, W%GuiW% H%GuiH% Hide
; WinMaximize
WinGetPos,,, GuiW, GuiH

gosub DirectX_Defines

d3d := Direct3DCreate9(D3D_SDK_VERSION)
if !d3d
{
    MsgBox, 16, Error, Direct3DCreate9 failed.
    ExitApp
}

if !IDirect3D9_CheckDeviceMultiSampleType(d3d
        , D3DADAPTER_DEFAULT
        , D3DDEVTYPE_HAL
        , D3DFMT_A8R8G8B8
        , true
        , D3DMULTISAMPLE_NONMASKABLE
        , multisample_quality)
    multisample := true

gosub PreparePresentationParameters

hr := IDirect3D9_CreateDevice(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, GuiHwnd
                        , D3DCREATE_SOFTWARE_VERTEXPROCESSING
                        , &pp, dev)
if hr
{
    SetFormat, Integer, H
    hr &= 0xFFFFFFFF
    MsgBox, 16, Error, IDirect3D9_CreateDevice returned error code %hr%.
    ExitApp
}

OnMessage(0x5, "OnSize") ; WM_SIZE
OnMessage(0x14, "OnErase") ; WM_ERASEBKGND
OnMessage(0x84, "OnHitTest") ; WM_NCHITTEST

DllCall("QueryPerformanceFrequency","int64*",perf_freq)

; Set up temporary surfaces, etc.
RecreateResources()

if Demo=Vista
{
    DllCall("dwmapi\DwmExtendFrameIntoClientArea","uint",GuiHwnd,"uint"
        , Struct(rect,"int",-1,"int",-1,"int",-1,"int",-1))
}

Gui, Show

SetTimer, PaintLoop, -1
return

PreparePresentationParameters:
VarSetCapacity(pp, 56, 0) ; D3DPRESENT_PARAMETERS
NumPut(true, pp, 32) ; Windowed
NumPut(D3DSWAPEFFECT_DISCARD, pp, 24) ; SwapEffect
NumPut(D3DFMT_A8R8G8B8, pp, 8) ; BackBufferFormat
if (multisample) {
    NumPut(D3DMULTISAMPLE_NONMASKABLE, pp, 16)
    NumPut(multisample_quality-1, pp, 20)
}
return

; Release resources that must be released before resetting the device.
ReleaseResources()
{
    global
    if Demo=Layered
    {
        ; "Before calling the IDirect3DDevice9::Reset method for a device,
        ;  an application should release any explicit render targets, ..."
        D3DRelease(temp_surface), temp_surface:=0
        ; D3DPOOL_SYSTEMMEM resources (like system_surface) do not
        ; need to be recreated when the device is lost/reset.
        ; However, we may need to resize the surface
        ; (i.e. the user maximized the window via hotkey and triggered OnSize().)
        D3DRelease(system_surface), system_surface:=0
        
        ; Delete the GDI bitmap in case it needs to be resized.
        DllCall("SelectObject", "UInt", bdc, "UInt", obm)
        DllCall("DeleteObject", "UInt", hbm)
        DllCall("DeleteDC", "UInt", bdc)
    }
    else if Demo=Vista
    {
        D3DRelease(temp_surface), temp_surface:=0
    }
}

; Recreate resources that must be recreated after the device is lost.
RecreateResources()
{
    global
    if Demo=Layered
    {
        ; Create a surface in system memory for retrieving the rendered image.
        ERRq(IDirect3DDevice9_CreateOffscreenPlainSurface(dev, GuiW, GuiH, D3DFMT_A8R8G8B8
            , D3DPOOL_SYSTEMMEM, system_surface, NULL), "CreateOffscreenPlainSurface")
        ; Since multisampled back-buffers aren't lockable, create a
        ; lockable render target surface to act as an intermediary.
        ERRq(IDirect3DDevice9_CreateRenderTarget(dev, GuiW, GuiH, D3DFMT_A8R8G8B8
            , D3DMULTISAMPLE_NONE, 0, true, temp_surface, NULL), "CreateRenderTarget")
        
        ; Create or recreate a GDI bitmap with the correct size.
        bdc := DllCall("CreateCompatibleDC", "UInt", 0)
        hbm := CreateDIBSection(GuiW, -GuiH, 32, bdc, bitmap_bits)
        obm := DllCall("SelectObject", "UInt", bdc, "UInt", hbm)
    }
    else if Demo=Vista
    {
        ; Create a 1x1 surface for retrieving pixel data to hit-test.
        ERRq(IDirect3DDevice9_CreateRenderTarget(dev, 1, 1, D3DFMT_A8R8G8B8
            , D3DMULTISAMPLE_NONE, 0, true, temp_surface, NULL), "CreateRenderTarget")
    }
}

PaintLoop:
SetBatchLines, -1
Loop {
    Critical, 1000 ; Prevent OnSize -> device reset while rendering.
    OnPaint(0,0,0xF,GuiHwnd)
    Critical, Off

    DllCall("QueryPerformanceCounter","int64*",render_this)
    if (render_last) {
        render_ticks += render_this-render_last
        render_count += 1
        ToolTip % 1/(render_ticks/perf_freq/render_count) " fps"
    }
    render_last := render_this

    Sleep, -1
}
return

OnErase() { ; Do all rendering in OnPaint().
    Critical 1000
    if A_Gui
        return 1
}

OnSize()
{
    global
    Critical 1000
    if !A_Gui
        return
    ; Reset pp since it is modified by CreateDevice() and Reset().
    gosub PreparePresentationParameters
    ; Reset the device to resize its backbuffer.
    Gui, +LastFound
    WinGetPos,,, GuiW, GuiH
    ReleaseResources()
    ERRq(IDirect3DDevice9_Reset(dev, &pp), "Reset")
    RecreateResources()
}

OnHitTest(wParam, lParam, msg, hwnd)
{
    local x, y, wx, wy, ww, wh, r, rc, hdc, back_buffer
    Critical 1000
    if !A_Gui
        return

    if Demo=Layered
    {   ; Layered windows have hit-testing support.
        r := DllCall("DefWindowProc","uint",hwnd,"uint",msg,"uint",wParam,"uint",lParam)
        return (r>0) ? 2 : r ; HTCAPTION=2
    }
    else if Demo!=Vista
        return
    if ERRq(IDirect3DDevice9_GetBackBuffer(dev, 0, 0, D3DBACKBUFFER_TYPE_MONO, back_buffer), "GetBackBuffer")
        return 2 ; FAIL, but let the GUI be clickable.

    Gui, +LastFound
    WinGetPos, wx, wy, ww, wh
    x := (lParam<<48>>48) - wx
    y := (lParam<<32>>48) - wy
    
    if (x < 0 || x >= GuiW || y < 0 || y >= GuiH)
    {
        D3DRelease(back_buffer)
        return 0 ; HTNOWHERE
    }
    
    Struct(rc,"int",x,"int",y,"int",x+1,"int",y+1)
    
    if !ERRq(IDirect3DDevice9_StretchRect(dev, back_buffer, &rc, temp_surface, NULL, D3DTEXF_NONE), DEBUG_STATE "StretchRect")
    if !ERRq(IDirect3DSurface9_LockRect(temp_surface, &rc, NULL, 0), "LockRect")
    {
        r := NumGet(NumGet(rc,4))>>24 ? 2 : 0 ; HTCAPTION : HTNOWHERE
        ERRq(IDirect3DSurface9_UnlockRect(temp_surface), "UnlockRect")
    }
    D3DRelease(back_buffer)
    return r
}

OnPaint(wParam, lParam, msg, hwnd)
{
    local vp ; Viewport
        , w, h, matrix, vEye, vAt, vUp ; Transformations
        , light, verts ; Structures for content
        , back_buffer, locked_bits, pitch, locked_rect ; UpdateLayeredWindow
    static PI=3.141592653589

    GetClientSize(hwnd, w, h)
    ; Clear the display.
    if ERRq(IDirect3DDevice9_Clear(dev, 1, NULL, D3DCLEAR_TARGET, 0x000000, 1.0, 0), "Clear")
    {   ; Device lost?
        return 0
    }
    
    ;
    ; Set up the camera.
    ;
    VarSetCapacity(matrix,64)
    
    D3DXMatrixPerspectiveFovLH(&matrix, PI/4, w/h, 1.0, 100.0)
    ERRq(IDirect3DDevice9_SetTransform(dev, D3DTS_PROJECTION, &matrix), "SetTransform")
    
    D3DXMatrixLookAtLH(&matrix
        , D3DVector(vEye,0,0,5)  ; eye point
        , D3DVector(vAt, 0,0,0)  ; camera look-at target
        , D3DVector(vUp, 0,1,0)) ; current world's up
    ERRq(IDirect3DDevice9_SetTransform(dev, D3DTS_VIEW, &matrix), "SetTransform")
    
    ; Rotate the world!
    D3DXMatrixRotationY(&matrix, Mod(A_TickCount,3000) / 3000.0 * 2*PI)
    ERRq(IDirect3DDevice9_SetTransform(dev, D3DTS_WORLDMATRIX_0, &matrix), "SetTransform")
    
    ;
    ; Set up the device.
    ;
    ERRq(IDirect3DDevice9_SetRenderState(dev, D3DRS_CULLMODE, D3DCULL_NONE), "SetRenderState:D3DRS_CULLMODE")
    ERRq(IDirect3DDevice9_SetRenderState(dev, D3DRS_LIGHTING, false), "SetRenderState:D3DRS_LIGHTING")
    ERRq(IDirect3DDevice9_SetRenderState(dev, D3DRS_ALPHABLENDENABLE, true), "SetRenderState:D3DRS_ALPHABLENDENABLE")
    ERRq(IDirect3DDevice9_SetRenderState(dev, D3DRS_SRCBLEND, D3DBLEND_SRCALPHA), "SetRenderState:D3DRS_SRCBLEND")
    ERRq(IDirect3DDevice9_SetRenderState(dev, D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA), "SetRenderState:D3DRS_DESTBLEND")
    
    ;
    ; Set up the content.
    ;
    
    ; Set up the light.
;     Struct(light
;         , "uint", D3DLIGHT_POINT
;         , "float",1.0,"float",1.0,"float",1.0,"float",0.0 ; Diffuse  { r, g, b, a }
;         , "float",0.0,"float",0.0,"float",0.0,"float",0.0 ; Specular { r, g, b, a }
;         , "float",0.0,"float",0.0,"float",0.0,"float",0.0 ; Ambient  { r, g, b, a }
;         , "float",0.0,"float",0.0,"float",0.0 ; Position { x, y, z }
;         , "float",0.0,"float",0.0,"float",0.0 ; Direction { x, y, z }
;         , "float",2.0 ; Range
;         , "float",0.0 ; Falloff
;         , "float",0.2 ; Attenuation0
;         , "float",0.0 ; Attenuation1
;         , "float",0.0 ; Attenuation2
;         , "float",0.0 ; Theta
;         , "float",0.0) ; Phi
;     ERRq(IDirect3DDevice9_SetLight(dev, 0, &light), "SetLight")
;     ERRq(IDirect3DDevice9_LightEnable(dev, 0, true), "LightEnable")
    
    ERRq(IDirect3DDevice9_BeginScene(dev), "BeginScene")
    ; Set vertex format: PositionNormalColored.
    ;   float X, Y, Z, Nx, Ny, Nz; int Color;
    ERRq(IDirect3DDevice9_SetFVF(dev, D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_DIFFUSE), "SetFVF")
    
    Struct(verts
        ; verts[0]
        , "float",0,"float",1,"float",1     ; Position
        , "float",0,"float",0,"float",-1    ; Normal
        , "uint",0xffff0000
        ; verts[1]
        , "float",-1,"float",-1,"float",1
        , "float",0,"float",0,"float",-1
        , "uint",0xff00ff00
        ; verts[2]
        , "float",1,"float",-1,"float",1
        , "float",0,"float",0,"float",-1
        , "uint",0x000000ff)
    
    ERRq(IDirect3DDevice9_DrawPrimitiveUP(dev, D3DPT_TRIANGLELIST, 1, &verts, 28), "DrawPrimitiveUP")
    
    ERRq(IDirect3DDevice9_EndScene(dev), "EndScene")
    
    ;
    ; Present the content.
    ;
    if Demo!=Layered
    {
        ERRq(IDirect3DDevice9_Present(dev, NULL, NULL, NULL, NULL), "Present")
    }
    else
    {
        ; Notes on layered windows and Direct3D:
        ; http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1810617&SiteID=1&pageid=0
        if ERRq(IDirect3DDevice9_GetBackBuffer(dev, 0, 0, D3DBACKBUFFER_TYPE_MONO, back_buffer), "GetBackBuffer")
            return 0
        ; Using a temporary render target (temp_surface) allows multisampling to be used.
        ; Locking temp_surface instead of copying to system_surface and locking that
        ; seems to be roughly 10x SLOWER.
        if !ERRq(IDirect3DDevice9_StretchRect(dev, back_buffer, NULL, temp_surface, NULL, D3DTEXF_NONE), "StretchRect")
        && !ERRq(IDirect3DDevice9_GetRenderTargetData(dev, temp_surface, system_surface), "GetRenderTargetData")
;         if !ERRq(IDirect3DDevice9_GetRenderTargetData(dev, back_buffer, system_surface), "GetRenderTargetData")
        {
            VarSetCapacity(locked_rect, 8) ; INT Pitch; void * pBits;
            if !ERRq(IDirect3DSurface9_LockRect(system_surface, &locked_rect, NULL, 0x8010), "LockRect")
            {
                pitch := NumGet(locked_rect,0,"int")
                locked_bits := NumGet(locked_rect,4)
                if (pitch != GuiW*4)
                    Loop %GuiH%
                        DllCall("RtlMoveMemory","uint",bitmap_bits+(A_Index-1)*GuiW*4,"uint",locked_bits,"uint",GuiW*4)
                        , locked_bits+=pitch ;, bitmap_bits+=GuiW*4
                else
                    DllCall("RtlMoveMemory","uint",bitmap_bits,"uint",locked_bits,"uint",GuiW*GuiH*4)

                ERRq(IDirect3DSurface9_UnlockRect(system_surface), "UnlockRect")
                
                if !DllCall("UpdateLayeredWindow"
                    ,"uint",hwnd
                    ,"uint",0
                    ,"uint",0 ; position unchanged
                    ,"int64*",GuiW|GuiH<<32
                    ,"uint",bdc
                    ,"int64*",0
                    ,"uint",0
                    ,"int*",0xFF<<16|1<<24
                    ,"uint",2)
                    StdOut(A_LastError, "UpdateLayeredWindow")
            }
        }
        D3DRelease(back_buffer)
    }
    
    ; Since we didn't call BeginPaint(), the invalidated region of
    ; the window is left invalid, and OnPaint() essentially loops.
    return 0
}

CreateDIBSection(w, h, bpp, hDC=0, ByRef ppvBits=0)
{
    hdcUsed := hDC ? hDC : DllCall("GetDC", "UInt", 0)
    if (hdcUsed)
    {
        VarSetCapacity(bi, 40, 0) ; BITMAPINFO(HEADER)
        NumPut(40, bi,  0)              ; biSize
        NumPut(1,  bi, 12, "UShort")    ; biPlanes
        NumPut(0,  bi, 16)              ; biCompression = BI_RGB (none)
        NumPut(w,  bi,  4)              ; biWidth
        NumPut(h,  bi,  8)              ; biHeight
        NumPut(bpp,bi, 14, "UShort")    ; biBitCount
        
        hbmp := DllCall("CreateDIBSection"
            , "UInt" , hDC
            , "UInt" , &bi   ; defines format, attributes, etc.
            , "UInt" , 0     ; iUsage = DIB_RGB_COLORS
            , "UInt*", ppvBits ; gets a pointer to the bitmap data
            , "UInt" , 0
            , "UInt" , 0)

        if (hdcUsed != hDC)
            DllCall("ReleaseDC", "UInt", 0, "UInt", hdcUsed)

        return hbmp
    }
    return 0
}

ERRq(hresult, tag) {
    if !hresult
        return
    fi := A_FormatInteger
    SetFormat, Integer, H
    hresult &= 0xFFFFFFFF
    SetFormat, Integer, %fi%
    StdOut(hresult, "Error calling " tag)
    return hresult
}

D3DVector(ByRef v, x, y, z) {
    VarSetCapacity(v,12), NumPut(z,NumPut(y,NumPut(x,v,0,"float"),0,"float"),0,"float")
    return &v
}
D3DRelease(ppv) { ; COM_Release. So far the only required COM_* function...
	Return	DllCall(NumGet(NumGet(1*ppv)+8), "Uint", ppv)
}

GetClientSize(hwnd, ByRef w, ByRef h)
{
    VarSetCapacity(rc, 16)
    DllCall("GetClientRect", "uint", hwnd, "uint", &rc)
    w := NumGet(rc, 8, "int")
    h := NumGet(rc, 12, "int")
}

GuiEscape:
GuiClose:
ExitApp


DirectX_Defines:
;
; Constants
;
NULL = 0

D3D_SDK_VERSION = 32

D3DADAPTER_DEFAULT = 0

D3DCREATE_FPU_PRESERVE                  = 0x00000002
D3DCREATE_MULTITHREADED                 = 0x00000004
D3DCREATE_PUREDEVICE                    = 0x00000010
D3DCREATE_SOFTWARE_VERTEXPROCESSING     = 0x00000020
D3DCREATE_HARDWARE_VERTEXPROCESSING     = 0x00000040
D3DCREATE_MIXED_VERTEXPROCESSING        = 0x00000080
D3DCREATE_DISABLE_DRIVER_MANAGEMENT     = 0x00000100
D3DCREATE_ADAPTERGROUP_DEVICE           = 0x00000200
D3DCREATE_DISABLE_DRIVER_MANAGEMENT_EX  = 0x00000400
D3DCREATE_NOWINDOWCHANGES				= 0x00000800

D3DSWAPEFFECT_DISCARD = 1
D3DSWAPEFFECT_FLIP = 2
D3DSWAPEFFECT_COPY = 3

D3DCLEAR_TARGET   = 0x00000001
D3DCLEAR_ZBUFFER  = 0x00000002
D3DCLEAR_STENCIL  = 0x00000004

D3DPRESENTFLAG_LOCKABLE_BACKBUFFER     = 0x00000001
D3DPRESENTFLAG_DISCARD_DEPTHSTENCIL    = 0x00000002
D3DPRESENTFLAG_DEVICECLIP              = 0x00000004
D3DPRESENTFLAG_VIDEO                   = 0x00000010
;
; Enumerations
;   TODO: Write a script to automatically generate these from d3d9types.h
;
D3DDEVTYPE_HAL         = 1
D3DDEVTYPE_REF         = 2
D3DDEVTYPE_SW          = 3
D3DDEVTYPE_NULLREF     = 4

D3DTS_VIEW = 2
D3DTS_PROJECTION = 3
D3DTS_TEXTURE0 = 16
D3DTS_TEXTURE1 = 17
D3DTS_TEXTURE2 = 18
D3DTS_TEXTURE3 = 19
D3DTS_TEXTURE4 = 20
D3DTS_TEXTURE5 = 21
D3DTS_TEXTURE6 = 22
D3DTS_TEXTURE7 = 23
;#define D3DTS_WORLDMATRIX(index) (D3DTRANSFORMSTATETYPE)(index + 256)
D3DTS_WORLDMATRIX_0 = 256

D3DRS_ZENABLE = 7
D3DRS_FILLMODE = 8
D3DRS_SHADEMODE = 9
D3DRS_ZWRITEENABLE = 14
D3DRS_ALPHATESTENABLE = 15
D3DRS_LASTPIXEL = 16
D3DRS_SRCBLEND = 19
D3DRS_DESTBLEND = 20
D3DRS_CULLMODE = 22
D3DRS_ZFUNC = 23
D3DRS_ALPHAREF = 24
D3DRS_ALPHAFUNC = 25
D3DRS_DITHERENABLE = 26
D3DRS_ALPHABLENDENABLE = 27
D3DRS_FOGENABLE = 28
D3DRS_SPECULARENABLE = 29
D3DRS_FOGCOLOR = 34
D3DRS_FOGTABLEMODE = 35
D3DRS_FOGSTART = 36
D3DRS_FOGEND = 37
D3DRS_FOGDENSITY = 38
D3DRS_RANGEFOGENABLE = 48
D3DRS_STENCILENABLE = 52
D3DRS_STENCILFAIL = 53
D3DRS_STENCILZFAIL = 54
D3DRS_STENCILPASS = 55
D3DRS_STENCILFUNC = 56
D3DRS_STENCILREF = 57
D3DRS_STENCILMASK = 58
D3DRS_STENCILWRITEMASK = 59
D3DRS_TEXTUREFACTOR = 60
D3DRS_WRAP0 = 128
D3DRS_WRAP1 = 129
D3DRS_WRAP2 = 130
D3DRS_WRAP3 = 131
D3DRS_WRAP4 = 132
D3DRS_WRAP5 = 133
D3DRS_WRAP6 = 134
D3DRS_WRAP7 = 135
D3DRS_CLIPPING = 136
D3DRS_LIGHTING = 137
D3DRS_AMBIENT = 139
D3DRS_FOGVERTEXMODE = 140
D3DRS_COLORVERTEX = 141
D3DRS_LOCALVIEWER = 142
D3DRS_NORMALIZENORMALS = 143
D3DRS_DIFFUSEMATERIALSOURCE = 145
D3DRS_SPECULARMATERIALSOURCE = 146
D3DRS_AMBIENTMATERIALSOURCE = 147
D3DRS_EMISSIVEMATERIALSOURCE = 148
D3DRS_VERTEXBLEND = 151
D3DRS_CLIPPLANEENABLE = 152
D3DRS_POINTSIZE = 154
D3DRS_POINTSIZE_MIN = 155
D3DRS_POINTSPRITEENABLE = 156
D3DRS_POINTSCALEENABLE = 157
D3DRS_POINTSCALE_A = 158
D3DRS_POINTSCALE_B = 159
D3DRS_POINTSCALE_C = 160
D3DRS_MULTISAMPLEANTIALIAS = 161
D3DRS_MULTISAMPLEMASK = 162
D3DRS_PATCHEDGESTYLE = 163
D3DRS_DEBUGMONITORTOKEN = 165
D3DRS_POINTSIZE_MAX = 166
D3DRS_INDEXEDVERTEXBLENDENABLE = 167
D3DRS_COLORWRITEENABLE = 168
D3DRS_TWEENFACTOR = 170
D3DRS_BLENDOP = 171
D3DRS_POSITIONDEGREE = 172
D3DRS_NORMALDEGREE = 173
D3DRS_SCISSORTESTENABLE = 174
D3DRS_SLOPESCALEDEPTHBIAS = 175
D3DRS_ANTIALIASEDLINEENABLE = 176
D3DRS_MINTESSELLATIONLEVEL = 178
D3DRS_MAXTESSELLATIONLEVEL = 179
D3DRS_ADAPTIVETESS_X = 180
D3DRS_ADAPTIVETESS_Y = 181
D3DRS_ADAPTIVETESS_Z = 182
D3DRS_ADAPTIVETESS_W = 183
D3DRS_ENABLEADAPTIVETESSELLATION = 184
D3DRS_TWOSIDEDSTENCILMODE = 185
D3DRS_CCW_STENCILFAIL = 186
D3DRS_CCW_STENCILZFAIL = 187
D3DRS_CCW_STENCILPASS = 188
D3DRS_CCW_STENCILFUNC = 189
D3DRS_COLORWRITEENABLE1 = 190
D3DRS_COLORWRITEENABLE2 = 191
D3DRS_COLORWRITEENABLE3 = 192
D3DRS_BLENDFACTOR = 193
D3DRS_SRGBWRITEENABLE = 194
D3DRS_DEPTHBIAS = 195
D3DRS_WRAP8 = 198
D3DRS_WRAP9 = 199
D3DRS_WRAP10 = 200
D3DRS_WRAP11 = 201
D3DRS_WRAP12 = 202
D3DRS_WRAP13 = 203
D3DRS_WRAP14 = 204
D3DRS_WRAP15 = 205
D3DRS_SEPARATEALPHABLENDENABLE = 206
D3DRS_SRCBLENDALPHA = 207
D3DRS_DESTBLENDALPHA = 208
D3DRS_BLENDOPALPHA = 209

D3DCULL_NONE = 1
D3DCULL_CW = 2
D3DCULL_CCW = 3

D3DFVF_RESERVED0        = 0x001
D3DFVF_POSITION_MASK    = 0x400E
D3DFVF_XYZ              = 0x002
D3DFVF_XYZRHW           = 0x004
D3DFVF_XYZB1            = 0x006
D3DFVF_XYZB2            = 0x008
D3DFVF_XYZB3            = 0x00a
D3DFVF_XYZB4            = 0x00c
D3DFVF_XYZB5            = 0x00e
D3DFVF_XYZW             = 0x4002

D3DFVF_NORMAL           = 0x010
D3DFVF_PSIZE            = 0x020
D3DFVF_DIFFUSE          = 0x040
D3DFVF_SPECULAR         = 0x080

D3DFVF_TEXCOUNT_MASK    = 0xf00
D3DFVF_TEXCOUNT_SHIFT   = 8
D3DFVF_TEX0             = 0x000
D3DFVF_TEX1             = 0x100
D3DFVF_TEX2             = 0x200
D3DFVF_TEX3             = 0x300
D3DFVF_TEX4             = 0x400
D3DFVF_TEX5             = 0x500
D3DFVF_TEX6             = 0x600
D3DFVF_TEX7             = 0x700
D3DFVF_TEX8             = 0x800

D3DFVF_LASTBETA_UBYTE4   = 0x1000
D3DFVF_LASTBETA_D3DCOLOR = 0x8000

D3DPT_POINTLIST = 1
D3DPT_LINELIST = 2
D3DPT_LINESTRIP = 3
D3DPT_TRIANGLELIST = 4
D3DPT_TRIANGLESTRIP = 5
D3DPT_TRIANGLEFAN = 6

D3DLIGHT_POINT = 1
D3DLIGHT_SPOT = 2
D3DLIGHT_DIRECTIONAL = 3

D3DBLEND_ZERO = 1
D3DBLEND_ONE = 2
D3DBLEND_SRCCOLOR = 3
D3DBLEND_INVSRCCOLOR = 4
D3DBLEND_SRCALPHA = 5
D3DBLEND_INVSRCALPHA = 6
D3DBLEND_DESTALPHA = 7
D3DBLEND_INVDESTALPHA = 8
D3DBLEND_DESTCOLOR = 9
D3DBLEND_INVDESTCOLOR = 10
D3DBLEND_SRCALPHASAT = 11
D3DBLEND_BOTHSRCALPHA = 12
D3DBLEND_BOTHINVSRCALPHA = 13
D3DBLEND_BLENDFACTOR = 14
D3DBLEND_INVBLENDFACTOR = 15
D3DBLEND_SRCCOLOR2 = 16
D3DBLEND_INVSRCCOLOR2 = 17

D3DBLENDOP_ADD              = 1
D3DBLENDOP_SUBTRACT         = 2
D3DBLENDOP_REVSUBTRACT      = 3
D3DBLENDOP_MIN              = 4
D3DBLENDOP_MAX              = 5

; BackBuffer/Display Formats
D3DFMT_A8R8G8B8             = 21
D3DFMT_X8R8G8B8             = 22
D3DFMT_R5G6B5               = 23
D3DFMT_X1R5G5B5             = 24
D3DFMT_A1R5G5B5             = 25
D3DFMT_A2R10G10B10          = 35

D3DMULTISAMPLE_NONE = 0
D3DMULTISAMPLE_NONMASKABLE  = 1
D3DMULTISAMPLE_2_SAMPLES = 2
D3DMULTISAMPLE_3_SAMPLES = 3
D3DMULTISAMPLE_4_SAMPLES = 4
D3DMULTISAMPLE_5_SAMPLES = 5
D3DMULTISAMPLE_6_SAMPLES = 6
D3DMULTISAMPLE_7_SAMPLES = 7
D3DMULTISAMPLE_8_SAMPLES = 8
D3DMULTISAMPLE_9__SAMPLES = 9
D3DMULTISAMPLE_10_SAMPLES = 10
D3DMULTISAMPLE_11_SAMPLES = 11
D3DMULTISAMPLE_12_SAMPLES = 12
D3DMULTISAMPLE_13_SAMPLES = 13
D3DMULTISAMPLE_14_SAMPLES = 14
D3DMULTISAMPLE_15_SAMPLES = 15
D3DMULTISAMPLE_16_SAMPLES = 16

D3DBACKBUFFER_TYPE_MONO = 0
D3DBACKBUFFER_TYPE_LEFT = 1
D3DBACKBUFFER_TYPE_RIGHT = 2

D3DPOOL_DEFAULT = 0
D3DPOOL_MANAGED = 1
D3DPOOL_SYSTEMMEM = 2
D3DPOOL_SCRATCH = 3

D3DTEXF_NONE = 0
D3DTEXF_POINT = 1
D3DTEXF_LINEAR = 2
D3DTEXF_ANISOTROPIC = 3
D3DTEXF_PYRAMIDALQUAD = 6
D3DTEXF_GAUSSIANQUAD = 7
D3DTEXF_CONVOLUTIONMONO = 8
;
; Interface IDs
;
IDirect3D9 := "81BDCBCA-64D4-426d-AE8D-AD0147F4275C"
IDirect3DDevice9 := "D0223B96-BF7A-43fd-92BD-A43B0D82B9EB"
IDirect3DStateBlock9 := "B07C4FE5-310D-4ba8-A23C-4F0F206F218B"
IDirect3DResource9 := "05EEC05D-8F7D-4362-B999-D1BAF357C704"
IDirect3DVertexDeclaration9 := "DD13C59C-36FA-4098-A8FB-C7ED39DC8546"
IDirect3DVertexShader9 := "EFC5557E-6265-4613-8A94-43857889EB36"
IDirect3DPixelShader9 := "6D3BDBDC-5B02-4415-B852-CE5E8BCCB289"
IDirect3DBaseTexture9 := "580CA87E-1D3C-4d54-991D-B7D3E3C298CE"
IDirect3DTexture9 := "85C31227-3DE5-4f00-9B3A-F11AC38C18B5"
IDirect3DVolumeTexture9 := "2518526C-E789-4111-A7B9-47EF328D13E6"
IDirect3DCubeTexture9 := "FFF32F81-D953-473a-9223-93D652ABA93F"
IDirect3DVertexBuffer9 := "B64BB1B5-FD70-4df6-BF91-19D0A12455E3"
IDirect3DIndexBuffer9 := "7C9DD65E-D3F7-4529-ACEE-785830ACDE35"
IDirect3DSurface9 := "0CFBAF3A-9FF6-429a-99B3-A2796AF8B89B"
IDirect3DVolume9 := "24F416E6-1F67-4aa7-B88E-D33F6F3128A1"
IDirect3DSwapChain9 := "794950F2-ADFC-458a-905E-10A10B0B503B"
IDirect3DQuery9 := "d9771460-a695-4f26-bbd3-27b840b541cc"
return

; =============================================================================
;                               Direct3D Functions
; =============================================================================
Direct3DCreate9(SDKVersion) {
    if !DllCall("GetModuleHandle","str","d3d9")
        DllCall("LoadLibrary","str","d3d9")
    return DllCall("d3d9\Direct3DCreate9", "uint", SDKVersion)
}

; ==============================================================================
;                               Direct3D Interfaces
; ==============================================================================
;
; IDirect3D9
;
IDirect3D9_RegisterSoftwareDevice(this,pInitializeFunction) {
    return DllCall(NumGet(NumGet(this+0)+12),"uint",this,"uint",pInitializeFunction)
}
IDirect3D9_GetAdapterCount(this) {
    return DllCall(NumGet(NumGet(this+0)+16),"uint",this)
}
IDirect3D9_GetAdapterIdentifier(this,Adapter,Flags,pIdentifier) {
    return DllCall(NumGet(NumGet(this+0)+20),"uint",this,"uint",Adapter,"uint",Flags,"uint",pIdentifier)
}
IDirect3D9_GetAdapterModeCount(this,Adapter,Format) {
    return DllCall(NumGet(NumGet(this+0)+24),"uint",this,"uint",Adapter,"uint",Format)
}
IDirect3D9_EnumAdapterModes(this,Adapter,Format,Mode,pMode) {
    return DllCall(NumGet(NumGet(this+0)+28),"uint",this,"uint",Adapter,"uint",Format,"uint",Mode,"uint",pMode)
}
IDirect3D9_GetAdapterDisplayMode(this,Adapter,pMode) {
    return DllCall(NumGet(NumGet(this+0)+32),"uint",this,"uint",Adapter,"uint",pMode)
}
IDirect3D9_CheckDeviceType(this,Adapter,DevType,AdapterFormat,BackBufferFormat,bWindowed) {
    return DllCall(NumGet(NumGet(this+0)+36),"uint",this,"uint",Adapter,"uint",DevType,"uint",AdapterFormat,"uint",BackBufferFormat,"int",bWindowed)
}
IDirect3D9_CheckDeviceFormat(this,Adapter,DeviceType,AdapterFormat,Usage,RType,CheckFormat) {
    return DllCall(NumGet(NumGet(this+0)+40),"uint",this,"uint",Adapter,"uint",DeviceType,"uint",AdapterFormat,"uint",Usage,"uint",RType,"uint",CheckFormat)
}
IDirect3D9_CheckDeviceMultiSampleType(this,Adapter,DeviceType,SurfaceFormat,Windowed,MultiSampleType,ByRef pQualityLevels) {
    return DllCall(NumGet(NumGet(this+0)+44),"uint",this,"uint",Adapter,"uint",DeviceType,"uint",SurfaceFormat,"int",Windowed,"uint",MultiSampleType,"uint*",pQualityLevels)
}
IDirect3D9_CheckDepthStencilMatch(this,Adapter,DeviceType,AdapterFormat,RenderTargetFormat,DepthStencilFormat) {
    return DllCall(NumGet(NumGet(this+0)+48),"uint",this,"uint",Adapter,"uint",DeviceType,"uint",AdapterFormat,"uint",RenderTargetFormat,"uint",DepthStencilFormat)
}
IDirect3D9_CheckDeviceFormatConversion(this,Adapter,DeviceType,SourceFormat,TargetFormat) {
    return DllCall(NumGet(NumGet(this+0)+52),"uint",this,"uint",Adapter,"uint",DeviceType,"uint",SourceFormat,"uint",TargetFormat)
}
IDirect3D9_GetDeviceCaps(this,Adapter,DeviceType,pCaps) {
    return DllCall(NumGet(NumGet(this+0)+56),"uint",this,"uint",Adapter,"uint",DeviceType,"uint",pCaps)
}
IDirect3D9_GetAdapterMonitor(this,Adapter) {
    return DllCall(NumGet(NumGet(this+0)+60),"uint",this,"uint",Adapter)
}
IDirect3D9_CreateDevice(this,Adapter,DeviceType,hFocusWindow,BehaviorFlags,pPresentationParameters,ByRef ppReturnedDeviceInterface) {
    return DllCall(NumGet(NumGet(this+0)+64),"uint",this,"uint",Adapter,"uint",DeviceType,"uint",hFocusWindow,"uint",BehaviorFlags,"uint",pPresentationParameters,"uint*",ppReturnedDeviceInterface)
}
;
; IDirect3DDevice9
;
IDirect3DDevice9_TestCooperativeLevel(this) {
    return DllCall(NumGet(NumGet(this+0)+12),"uint",this)
}
IDirect3DDevice9_GetAvailableTextureMem(this) {
    return DllCall(NumGet(NumGet(this+0)+16),"uint",this)
}
IDirect3DDevice9_EvictManagedResources(this) {
    return DllCall(NumGet(NumGet(this+0)+20),"uint",this)
}
IDirect3DDevice9_GetDirect3D(this,ByRef ppD3D9) {
    return DllCall(NumGet(NumGet(this+0)+24),"uint",this,"uint*",ppD3D9)
}
IDirect3DDevice9_GetDeviceCaps(this,pCaps) {
    return DllCall(NumGet(NumGet(this+0)+28),"uint",this,"uint",pCaps)
}
IDirect3DDevice9_GetDisplayMode(this,iSwapChain,pMode) {
    return DllCall(NumGet(NumGet(this+0)+32),"uint",this,"uint",iSwapChain,"uint",pMode)
}
IDirect3DDevice9_GetCreationParameters(this,pParameters) {
    return DllCall(NumGet(NumGet(this+0)+36),"uint",this,"uint",pParameters)
}
IDirect3DDevice9_SetCursorProperties(this,XHotSpot,YHotSpot,pCursorBitmap) {
    return DllCall(NumGet(NumGet(this+0)+40),"uint",this,"uint",XHotSpot,"uint",YHotSpot,"uint",pCursorBitmap)
}
IDirect3DDevice9_SetCursorPosition(this,X,Y,Flags) {
    DllCall(NumGet(NumGet(this+0)+44),"uint",this,"int",X,"int",Y,"uint",Flags)
}
IDirect3DDevice9_ShowCursor(this,bShow) {
    return DllCall(NumGet(NumGet(this+0)+48),"uint",this,"int",bShow)
}
IDirect3DDevice9_CreateAdditionalSwapChain(this,pPresentationParameters,ByRef pSwapChain) {
    return DllCall(NumGet(NumGet(this+0)+52),"uint",this,"uint",pPresentationParameters,"uint*",pSwapChain)
}
IDirect3DDevice9_GetSwapChain(this,iSwapChain,ByRef pSwapChain) {
    return DllCall(NumGet(NumGet(this+0)+56),"uint",this,"uint",iSwapChain,"uint*",pSwapChain)
}
IDirect3DDevice9_GetNumberOfSwapChains(this) {
    return DllCall(NumGet(NumGet(this+0)+60),"uint",this)
}
IDirect3DDevice9_Reset(this,pPresentationParameters) {
    return DllCall(NumGet(NumGet(this+0)+64),"uint",this,"uint",pPresentationParameters)
}
IDirect3DDevice9_Present(this,pSourceRect,pDestRect,hDestWindowOverride,pDirtyRegion) {
    return DllCall(NumGet(NumGet(this+0)+68),"uint",this,"uint",pSourceRect,"uint",pDestRect,"uint",hDestWindowOverride,"uint",pDirtyRegion)
}
IDirect3DDevice9_GetBackBuffer(this,iSwapChain,iBackBuffer,Type,ByRef ppBackBuffer) {
    return DllCall(NumGet(NumGet(this+0)+72),"uint",this,"uint",iSwapChain,"uint",iBackBuffer,"uint",Type,"uint*",ppBackBuffer)
}
IDirect3DDevice9_GetRasterStatus(this,iSwapChain,pRasterStatus) {
    return DllCall(NumGet(NumGet(this+0)+76),"uint",this,"uint",iSwapChain,"uint",pRasterStatus)
}
IDirect3DDevice9_SetDialogBoxMode(this,bEnableDialogs) {
    return DllCall(NumGet(NumGet(this+0)+80),"uint",this,"int",bEnableDialogs)
}
IDirect3DDevice9_SetGammaRamp(this,iSwapChain,Flags,pRamp) {
    DllCall(NumGet(NumGet(this+0)+84),"uint",this,"uint",iSwapChain,"uint",Flags,"uint",pRamp)
}
IDirect3DDevice9_GetGammaRamp(this,iSwapChain,pRamp) {
    DllCall(NumGet(NumGet(this+0)+88),"uint",this,"uint",iSwapChain,"uint",pRamp)
}
IDirect3DDevice9_CreateTexture(this,Width,Height,Levels,Usage,Format,Pool,ByRef ppTexture,pSharedHandle) {
    return DllCall(NumGet(NumGet(this+0)+92),"uint",this,"uint",Width,"uint",Height,"uint",Levels,"uint",Usage,"uint",Format,"uint",Pool,"uint*",ppTexture,"uint",pSharedHandle)
}
IDirect3DDevice9_CreateVolumeTexture(this,Width,Height,Depth,Levels,Usage,Format,Pool,ByRef ppVolumeTexture,pSharedHandle) {
    return DllCall(NumGet(NumGet(this+0)+96),"uint",this,"uint",Width,"uint",Height,"uint",Depth,"uint",Levels,"uint",Usage,"uint",Format,"uint",Pool,"uint*",ppVolumeTexture,"uint",pSharedHandle)
}
IDirect3DDevice9_CreateCubeTexture(this,EdgeLength,Levels,Usage,Format,Pool,ByRef ppCubeTexture,pSharedHandle) {
    return DllCall(NumGet(NumGet(this+0)+100),"uint",this,"uint",EdgeLength,"uint",Levels,"uint",Usage,"uint",Format,"uint",Pool,"uint*",ppCubeTexture,"uint",pSharedHandle)
}
IDirect3DDevice9_CreateVertexBuffer(this,Length,Usage,FVF,Pool,ByRef ppVertexBuffer,pSharedHandle) {
    return DllCall(NumGet(NumGet(this+0)+104),"uint",this,"uint",Length,"uint",Usage,"uint",FVF,"uint",Pool,"uint*",ppVertexBuffer,"uint",pSharedHandle)
}
IDirect3DDevice9_CreateIndexBuffer(this,Length,Usage,Format,Pool,ByRef ppIndexBuffer,pSharedHandle) {
    return DllCall(NumGet(NumGet(this+0)+108),"uint",this,"uint",Length,"uint",Usage,"uint",Format,"uint",Pool,"uint*",ppIndexBuffer,"uint",pSharedHandle)
}
IDirect3DDevice9_CreateRenderTarget(this,Width,Height,Format,MultiSample,MultisampleQuality,Lockable,ByRef ppSurface,pSharedHandle) {
    return DllCall(NumGet(NumGet(this+0)+112),"uint",this,"uint",Width,"uint",Height,"uint",Format,"uint",MultiSample,"uint",MultisampleQuality,"int",Lockable,"uint*",ppSurface,"uint",pSharedHandle)
}
IDirect3DDevice9_CreateDepthStencilSurface(this,Width,Height,Format,MultiSample,MultisampleQuality,Discard,ByRef ppSurface,pSharedHandle) {
    return DllCall(NumGet(NumGet(this+0)+116),"uint",this,"uint",Width,"uint",Height,"uint",Format,"uint",MultiSample,"uint",MultisampleQuality,"int",Discard,"uint*",ppSurface,"uint",pSharedHandle)
}
IDirect3DDevice9_UpdateSurface(this,pSourceSurface,pSourceRect,pDestinationSurface,pDestPoint) {
    return DllCall(NumGet(NumGet(this+0)+120),"uint",this,"uint",pSourceSurface,"uint",pSourceRect,"uint",pDestinationSurface,"uint",pDestPoint)
}
IDirect3DDevice9_UpdateTexture(this,pSourceTexture,pDestinationTexture) {
    return DllCall(NumGet(NumGet(this+0)+124),"uint",this,"uint",pSourceTexture,"uint",pDestinationTexture)
}
IDirect3DDevice9_GetRenderTargetData(this,pRenderTarget,pDestSurface) {
    return DllCall(NumGet(NumGet(this+0)+128),"uint",this,"uint",pRenderTarget,"uint",pDestSurface)
}
IDirect3DDevice9_GetFrontBufferData(this,iSwapChain,pDestSurface) {
    return DllCall(NumGet(NumGet(this+0)+132),"uint",this,"uint",iSwapChain,"uint",pDestSurface)
}
IDirect3DDevice9_StretchRect(this,pSourceSurface,pSourceRect,pDestSurface,pDestRect,Filter) {
    return DllCall(NumGet(NumGet(this+0)+136),"uint",this,"uint",pSourceSurface,"uint",pSourceRect,"uint",pDestSurface,"uint",pDestRect,"uint",Filter)
}
IDirect3DDevice9_ColorFill(this,pSurface,pRect,color) {
    return DllCall(NumGet(NumGet(this+0)+140),"uint",this,"uint",pSurface,"uint",pRect,"uint",color)
}
IDirect3DDevice9_CreateOffscreenPlainSurface(this,Width,Height,Format,Pool,ByRef ppSurface,pSharedHandle) {
    return DllCall(NumGet(NumGet(this+0)+144),"uint",this,"uint",Width,"uint",Height,"uint",Format,"uint",Pool,"uint*",ppSurface,"uint",pSharedHandle)
}
IDirect3DDevice9_SetRenderTarget(this,RenderTargetIndex,pRenderTarget) {
    return DllCall(NumGet(NumGet(this+0)+148),"uint",this,"uint",RenderTargetIndex,"uint",pRenderTarget)
}
IDirect3DDevice9_GetRenderTarget(this,RenderTargetIndex,ByRef ppRenderTarget) {
    return DllCall(NumGet(NumGet(this+0)+152),"uint",this,"uint",RenderTargetIndex,"uint*",ppRenderTarget)
}
IDirect3DDevice9_SetDepthStencilSurface(this,pNewZStencil) {
    return DllCall(NumGet(NumGet(this+0)+156),"uint",this,"uint",pNewZStencil)
}
IDirect3DDevice9_GetDepthStencilSurface(this,ByRef ppZStencilSurface) {
    return DllCall(NumGet(NumGet(this+0)+160),"uint",this,"uint*",ppZStencilSurface)
}
IDirect3DDevice9_BeginScene(this) {
    return DllCall(NumGet(NumGet(this+0)+164),"uint",this)
}
IDirect3DDevice9_EndScene(this) {
    return DllCall(NumGet(NumGet(this+0)+168),"uint",this)
}
IDirect3DDevice9_Clear(this,Count,pRects,Flags,Color,Z,Stencil) {
    return DllCall(NumGet(NumGet(this+0)+172),"uint",this,"uint",Count,"uint",pRects,"uint",Flags,"uint",Color,"float",Z,"uint",Stencil)
}
IDirect3DDevice9_SetTransform(this,State,pMatrix) {
    return DllCall(NumGet(NumGet(this+0)+176),"uint",this,"uint",State,"uint",pMatrix)
}
IDirect3DDevice9_GetTransform(this,State,pMatrix) {
    return DllCall(NumGet(NumGet(this+0)+180),"uint",this,"uint",State,"uint",pMatrix)
}
IDirect3DDevice9_MultiplyTransform(this,param2,param3) {
    return DllCall(NumGet(NumGet(this+0)+184),"uint",this,"uint",param2,"uint",param3)
}
IDirect3DDevice9_SetViewport(this,pViewport) {
    return DllCall(NumGet(NumGet(this+0)+188),"uint",this,"uint",pViewport)
}
IDirect3DDevice9_GetViewport(this,pViewport) {
    return DllCall(NumGet(NumGet(this+0)+192),"uint",this,"uint",pViewport)
}
IDirect3DDevice9_SetMaterial(this,pMaterial) {
    return DllCall(NumGet(NumGet(this+0)+196),"uint",this,"uint",pMaterial)
}
IDirect3DDevice9_GetMaterial(this,pMaterial) {
    return DllCall(NumGet(NumGet(this+0)+200),"uint",this,"uint",pMaterial)
}
IDirect3DDevice9_SetLight(this,Index,param3) {
    return DllCall(NumGet(NumGet(this+0)+204),"uint",this,"uint",Index,"uint",param3)
}
IDirect3DDevice9_GetLight(this,Index,param3) {
    return DllCall(NumGet(NumGet(this+0)+208),"uint",this,"uint",Index,"uint",param3)
}
IDirect3DDevice9_LightEnable(this,Index,Enable) {
    return DllCall(NumGet(NumGet(this+0)+212),"uint",this,"uint",Index,"int",Enable)
}
IDirect3DDevice9_GetLightEnable(this,Index,ByRef pEnable) {
    return DllCall(NumGet(NumGet(this+0)+216),"uint",this,"uint",Index,"int*",pEnable)
}
IDirect3DDevice9_SetClipPlane(this,Index,ByRef pPlane) {
    return DllCall(NumGet(NumGet(this+0)+220),"uint",this,"uint",Index,"float*",pPlane)
}
IDirect3DDevice9_GetClipPlane(this,Index,ByRef pPlane) {
    return DllCall(NumGet(NumGet(this+0)+224),"uint",this,"uint",Index,"float*",pPlane)
}
IDirect3DDevice9_SetRenderState(this,State,Value) {
    return DllCall(NumGet(NumGet(this+0)+228),"uint",this,"uint",State,"uint",Value)
}
IDirect3DDevice9_GetRenderState(this,State,ByRef pValue) {
    return DllCall(NumGet(NumGet(this+0)+232),"uint",this,"uint",State,"uint*",pValue)
}
IDirect3DDevice9_CreateStateBlock(this,Type,ByRef ppSB) {
    return DllCall(NumGet(NumGet(this+0)+236),"uint",this,"uint",Type,"uint*",ppSB)
}
IDirect3DDevice9_BeginStateBlock(this) {
    return DllCall(NumGet(NumGet(this+0)+240),"uint",this)
}
IDirect3DDevice9_EndStateBlock(this,ByRef ppSB) {
    return DllCall(NumGet(NumGet(this+0)+244),"uint",this,"uint*",ppSB)
}
IDirect3DDevice9_SetClipStatus(this,pClipStatus) {
    return DllCall(NumGet(NumGet(this+0)+248),"uint",this,"uint",pClipStatus)
}
IDirect3DDevice9_GetClipStatus(this,pClipStatus) {
    return DllCall(NumGet(NumGet(this+0)+252),"uint",this,"uint",pClipStatus)
}
IDirect3DDevice9_GetTexture(this,Stage,ByRef ppTexture) {
    return DllCall(NumGet(NumGet(this+0)+256),"uint",this,"uint",Stage,"uint*",ppTexture)
}
IDirect3DDevice9_SetTexture(this,Stage,pTexture) {
    return DllCall(NumGet(NumGet(this+0)+260),"uint",this,"uint",Stage,"uint",pTexture)
}
IDirect3DDevice9_GetTextureStageState(this,Stage,Type,ByRef pValue) {
    return DllCall(NumGet(NumGet(this+0)+264),"uint",this,"uint",Stage,"uint",Type,"uint*",pValue)
}
IDirect3DDevice9_SetTextureStageState(this,Stage,Type,Value) {
    return DllCall(NumGet(NumGet(this+0)+268),"uint",this,"uint",Stage,"uint",Type,"uint",Value)
}
IDirect3DDevice9_GetSamplerState(this,Sampler,Type,ByRef pValue) {
    return DllCall(NumGet(NumGet(this+0)+272),"uint",this,"uint",Sampler,"uint",Type,"uint*",pValue)
}
IDirect3DDevice9_SetSamplerState(this,Sampler,Type,Value) {
    return DllCall(NumGet(NumGet(this+0)+276),"uint",this,"uint",Sampler,"uint",Type,"uint",Value)
}
IDirect3DDevice9_ValidateDevice(this,ByRef pNumPasses) {
    return DllCall(NumGet(NumGet(this+0)+280),"uint",this,"uint*",pNumPasses)
}
IDirect3DDevice9_SetPaletteEntries(this,PaletteNumber,pEntries) {
    return DllCall(NumGet(NumGet(this+0)+284),"uint",this,"uint",PaletteNumber,"uint",pEntries)
}
IDirect3DDevice9_GetPaletteEntries(this,PaletteNumber,pEntries) {
    return DllCall(NumGet(NumGet(this+0)+288),"uint",this,"uint",PaletteNumber,"uint",pEntries)
}
IDirect3DDevice9_SetCurrentTexturePalette(this,PaletteNumber) {
    return DllCall(NumGet(NumGet(this+0)+292),"uint",this,"uint",PaletteNumber)
}
IDirect3DDevice9_GetCurrentTexturePalette(this,ByRef PaletteNumber) {
    return DllCall(NumGet(NumGet(this+0)+296),"uint",this,"uint*",PaletteNumber)
}
IDirect3DDevice9_SetScissorRect(this,pRect) {
    return DllCall(NumGet(NumGet(this+0)+300),"uint",this,"uint",pRect)
}
IDirect3DDevice9_GetScissorRect(this,pRect) {
    return DllCall(NumGet(NumGet(this+0)+304),"uint",this,"uint",pRect)
}
IDirect3DDevice9_SetSoftwareVertexProcessing(this,bSoftware) {
    return DllCall(NumGet(NumGet(this+0)+308),"uint",this,"int",bSoftware)
}
IDirect3DDevice9_GetSoftwareVertexProcessing(this) {
    return DllCall(NumGet(NumGet(this+0)+312),"uint",this)
}
IDirect3DDevice9_SetNPatchMode(this,nSegments) {
    return DllCall(NumGet(NumGet(this+0)+316),"uint",this,"float",nSegments)
}
IDirect3DDevice9_GetNPatchMode(this) {
    return DllCall(NumGet(NumGet(this+0)+320),"uint",this)
}
IDirect3DDevice9_DrawPrimitive(this,PrimitiveType,StartVertex,PrimitiveCount) {
    return DllCall(NumGet(NumGet(this+0)+324),"uint",this,"uint",PrimitiveType,"uint",StartVertex,"uint",PrimitiveCount)
}
IDirect3DDevice9_DrawIndexedPrimitive(this,param2,BaseVertexIndex,MinVertexIndex,NumVertices,startIndex,primCount) {
    return DllCall(NumGet(NumGet(this+0)+328),"uint",this,"uint",param2,"int",BaseVertexIndex,"uint",MinVertexIndex,"uint",NumVertices,"uint",startIndex,"uint",primCount)
}
IDirect3DDevice9_DrawPrimitiveUP(this,PrimitiveType,PrimitiveCount,pVertexStreamZeroData,VertexStreamZeroStride) {
    return DllCall(NumGet(NumGet(this+0)+332),"uint",this,"uint",PrimitiveType,"uint",PrimitiveCount,"uint",pVertexStreamZeroData,"uint",VertexStreamZeroStride)
}
IDirect3DDevice9_DrawIndexedPrimitiveUP(this,PrimitiveType,MinVertexIndex,NumVertices,PrimitiveCount,pIndexData,IndexDataFormat,pVertexStreamZeroData,VertexStreamZeroStride) {
    return DllCall(NumGet(NumGet(this+0)+336),"uint",this,"uint",PrimitiveType,"uint",MinVertexIndex,"uint",NumVertices,"uint",PrimitiveCount,"uint",pIndexData,"uint",IndexDataFormat,"uint",pVertexStreamZeroData,"uint",VertexStreamZeroStride)
}
IDirect3DDevice9_ProcessVertices(this,SrcStartIndex,DestIndex,VertexCount,pDestBuffer,pVertexDecl,Flags) {
    return DllCall(NumGet(NumGet(this+0)+340),"uint",this,"uint",SrcStartIndex,"uint",DestIndex,"uint",VertexCount,"uint",pDestBuffer,"uint",pVertexDecl,"uint",Flags)
}
IDirect3DDevice9_CreateVertexDeclaration(this,pVertexElements,ByRef ppDecl) {
    return DllCall(NumGet(NumGet(this+0)+344),"uint",this,"uint",pVertexElements,"uint*",ppDecl)
}
IDirect3DDevice9_SetVertexDeclaration(this,pDecl) {
    return DllCall(NumGet(NumGet(this+0)+348),"uint",this,"uint",pDecl)
}
IDirect3DDevice9_GetVertexDeclaration(this,ByRef ppDecl) {
    return DllCall(NumGet(NumGet(this+0)+352),"uint",this,"uint*",ppDecl)
}
IDirect3DDevice9_SetFVF(this,FVF) {
    return DllCall(NumGet(NumGet(this+0)+356),"uint",this,"uint",FVF)
}
IDirect3DDevice9_GetFVF(this,ByRef pFVF) {
    return DllCall(NumGet(NumGet(this+0)+360),"uint",this,"uint*",pFVF)
}
IDirect3DDevice9_CreateVertexShader(this,ByRef pFunction,ByRef ppShader) {
    return DllCall(NumGet(NumGet(this+0)+364),"uint",this,"uint*",pFunction,"uint*",ppShader)
}
IDirect3DDevice9_SetVertexShader(this,pShader) {
    return DllCall(NumGet(NumGet(this+0)+368),"uint",this,"uint",pShader)
}
IDirect3DDevice9_GetVertexShader(this,ByRef ppShader) {
    return DllCall(NumGet(NumGet(this+0)+372),"uint",this,"uint*",ppShader)
}
IDirect3DDevice9_SetVertexShaderConstantF(this,StartRegister,ByRef pConstantData,Vector4fCount) {
    return DllCall(NumGet(NumGet(this+0)+376),"uint",this,"uint",StartRegister,"float*",pConstantData,"uint",Vector4fCount)
}
IDirect3DDevice9_GetVertexShaderConstantF(this,StartRegister,ByRef pConstantData,Vector4fCount) {
    return DllCall(NumGet(NumGet(this+0)+380),"uint",this,"uint",StartRegister,"float*",pConstantData,"uint",Vector4fCount)
}
IDirect3DDevice9_SetVertexShaderConstantI(this,StartRegister,ByRef pConstantData,Vector4iCount) {
    return DllCall(NumGet(NumGet(this+0)+384),"uint",this,"uint",StartRegister,"int*",pConstantData,"uint",Vector4iCount)
}
IDirect3DDevice9_GetVertexShaderConstantI(this,StartRegister,ByRef pConstantData,Vector4iCount) {
    return DllCall(NumGet(NumGet(this+0)+388),"uint",this,"uint",StartRegister,"int*",pConstantData,"uint",Vector4iCount)
}
IDirect3DDevice9_SetVertexShaderConstantB(this,StartRegister,ByRef pConstantData,BoolCount) {
    return DllCall(NumGet(NumGet(this+0)+392),"uint",this,"uint",StartRegister,"int*",pConstantData,"uint",BoolCount)
}
IDirect3DDevice9_GetVertexShaderConstantB(this,StartRegister,ByRef pConstantData,BoolCount) {
    return DllCall(NumGet(NumGet(this+0)+396),"uint",this,"uint",StartRegister,"int*",pConstantData,"uint",BoolCount)
}
IDirect3DDevice9_SetStreamSource(this,StreamNumber,pStreamData,OffsetInBytes,Stride) {
    return DllCall(NumGet(NumGet(this+0)+400),"uint",this,"uint",StreamNumber,"uint",pStreamData,"uint",OffsetInBytes,"uint",Stride)
}
IDirect3DDevice9_GetStreamSource(this,StreamNumber,ByRef ppStreamData,ByRef pOffsetInBytes,ByRef pStride) {
    return DllCall(NumGet(NumGet(this+0)+404),"uint",this,"uint",StreamNumber,"uint*",ppStreamData,"uint*",pOffsetInBytes,"uint*",pStride)
}
IDirect3DDevice9_SetStreamSourceFreq(this,StreamNumber,Setting) {
    return DllCall(NumGet(NumGet(this+0)+408),"uint",this,"uint",StreamNumber,"uint",Setting)
}
IDirect3DDevice9_GetStreamSourceFreq(this,StreamNumber,ByRef pSetting) {
    return DllCall(NumGet(NumGet(this+0)+412),"uint",this,"uint",StreamNumber,"uint*",pSetting)
}
IDirect3DDevice9_SetIndices(this,pIndexData) {
    return DllCall(NumGet(NumGet(this+0)+416),"uint",this,"uint",pIndexData)
}
IDirect3DDevice9_GetIndices(this,ByRef ppIndexData) {
    return DllCall(NumGet(NumGet(this+0)+420),"uint",this,"uint*",ppIndexData)
}
IDirect3DDevice9_CreatePixelShader(this,ByRef pFunction,ByRef ppShader) {
    return DllCall(NumGet(NumGet(this+0)+424),"uint",this,"uint*",pFunction,"uint*",ppShader)
}
IDirect3DDevice9_SetPixelShader(this,pShader) {
    return DllCall(NumGet(NumGet(this+0)+428),"uint",this,"uint",pShader)
}
IDirect3DDevice9_GetPixelShader(this,ByRef ppShader) {
    return DllCall(NumGet(NumGet(this+0)+432),"uint",this,"uint*",ppShader)
}
IDirect3DDevice9_SetPixelShaderConstantF(this,StartRegister,ByRef pConstantData,Vector4fCount) {
    return DllCall(NumGet(NumGet(this+0)+436),"uint",this,"uint",StartRegister,"float*",pConstantData,"uint",Vector4fCount)
}
IDirect3DDevice9_GetPixelShaderConstantF(this,StartRegister,ByRef pConstantData,Vector4fCount) {
    return DllCall(NumGet(NumGet(this+0)+440),"uint",this,"uint",StartRegister,"float*",pConstantData,"uint",Vector4fCount)
}
IDirect3DDevice9_SetPixelShaderConstantI(this,StartRegister,ByRef pConstantData,Vector4iCount) {
    return DllCall(NumGet(NumGet(this+0)+444),"uint",this,"uint",StartRegister,"int*",pConstantData,"uint",Vector4iCount)
}
IDirect3DDevice9_GetPixelShaderConstantI(this,StartRegister,ByRef pConstantData,Vector4iCount) {
    return DllCall(NumGet(NumGet(this+0)+448),"uint",this,"uint",StartRegister,"int*",pConstantData,"uint",Vector4iCount)
}
IDirect3DDevice9_SetPixelShaderConstantB(this,StartRegister,ByRef pConstantData,BoolCount) {
    return DllCall(NumGet(NumGet(this+0)+452),"uint",this,"uint",StartRegister,"int*",pConstantData,"uint",BoolCount)
}
IDirect3DDevice9_GetPixelShaderConstantB(this,StartRegister,ByRef pConstantData,BoolCount) {
    return DllCall(NumGet(NumGet(this+0)+456),"uint",this,"uint",StartRegister,"int*",pConstantData,"uint",BoolCount)
}
IDirect3DDevice9_DrawRectPatch(this,Handle,ByRef pNumSegs,pRectPatchInfo) {
    return DllCall(NumGet(NumGet(this+0)+460),"uint",this,"uint",Handle,"float*",pNumSegs,"uint",pRectPatchInfo)
}
IDirect3DDevice9_DrawTriPatch(this,Handle,ByRef pNumSegs,pTriPatchInfo) {
    return DllCall(NumGet(NumGet(this+0)+464),"uint",this,"uint",Handle,"float*",pNumSegs,"uint",pTriPatchInfo)
}
IDirect3DDevice9_DeletePatch(this,Handle) {
    return DllCall(NumGet(NumGet(this+0)+468),"uint",this,"uint",Handle)
}
IDirect3DDevice9_CreateQuery(this,Type,ByRef ppQuery) {
    return DllCall(NumGet(NumGet(this+0)+472),"uint",this,"uint",Type,"uint*",ppQuery)
}
;
; IDirect3DStateBlock9
;
IDirect3DStateBlock9_GetDevice(this,ByRef ppDevice) {
    return DllCall(NumGet(NumGet(this+0)+12),"uint",this,"uint*",ppDevice)
}
IDirect3DStateBlock9_Capture(this) {
    return DllCall(NumGet(NumGet(this+0)+16),"uint",this)
}
IDirect3DStateBlock9_Apply(this) {
    return DllCall(NumGet(NumGet(this+0)+20),"uint",this)
}
;
; IDirect3DSwapChain9
;
IDirect3DSwapChain9_Present(this,pSourceRect,pDestRect,hDestWindowOverride,pDirtyRegion,dwFlags) {
    return DllCall(NumGet(NumGet(this+0)+12),"uint",this,"uint",pSourceRect,"uint",pDestRect,"uint",hDestWindowOverride,"uint",pDirtyRegion,"uint",dwFlags)
}
IDirect3DSwapChain9_GetFrontBufferData(this,pDestSurface) {
    return DllCall(NumGet(NumGet(this+0)+16),"uint",this,"uint",pDestSurface)
}
IDirect3DSwapChain9_GetBackBuffer(this,iBackBuffer,Type,ByRef ppBackBuffer) {
    return DllCall(NumGet(NumGet(this+0)+20),"uint",this,"uint",iBackBuffer,"uint",Type,"uint*",ppBackBuffer)
}
IDirect3DSwapChain9_GetRasterStatus(this,pRasterStatus) {
    return DllCall(NumGet(NumGet(this+0)+24),"uint",this,"uint",pRasterStatus)
}
IDirect3DSwapChain9_GetDisplayMode(this,pMode) {
    return DllCall(NumGet(NumGet(this+0)+28),"uint",this,"uint",pMode)
}
IDirect3DSwapChain9_GetDevice(this,ByRef ppDevice) {
    return DllCall(NumGet(NumGet(this+0)+32),"uint",this,"uint*",ppDevice)
}
IDirect3DSwapChain9_GetPresentParameters(this,pPresentationParameters) {
    return DllCall(NumGet(NumGet(this+0)+36),"uint",this,"uint",pPresentationParameters)
}
;
; IDirect3DResource9
;
IDirect3DResource9_GetDevice(this,ByRef ppDevice) {
    return DllCall(NumGet(NumGet(this+0)+12),"uint",this,"uint*",ppDevice)
}
IDirect3DResource9_SetPrivateData(this,refguid,pData,SizeOfData,Flags) {
    return DllCall(NumGet(NumGet(this+0)+16),"uint",this,"uint",refguid,"uint",pData,"uint",SizeOfData,"uint",Flags)
}
IDirect3DResource9_GetPrivateData(this,refguid,pData,ByRef pSizeOfData) {
    return DllCall(NumGet(NumGet(this+0)+20),"uint",this,"uint",refguid,"uint",pData,"uint*",pSizeOfData)
}
IDirect3DResource9_FreePrivateData(this,refguid) {
    return DllCall(NumGet(NumGet(this+0)+24),"uint",this,"uint",refguid)
}
IDirect3DResource9_SetPriority(this,PriorityNew) {
    return DllCall(NumGet(NumGet(this+0)+28),"uint",this,"uint",PriorityNew)
}
IDirect3DResource9_GetPriority(this) {
    return DllCall(NumGet(NumGet(this+0)+32),"uint",this)
}
IDirect3DResource9_PreLoad(this) {
    DllCall(NumGet(NumGet(this+0)+36),"uint",this)
}
IDirect3DResource9_GetType(this) {
    return DllCall(NumGet(NumGet(this+0)+40),"uint",this)
}
;
; IDirect3DVertexDeclaration9
;
IDirect3DVertexDeclaration9_GetDevice(this,ByRef ppDevice) {
    return DllCall(NumGet(NumGet(this+0)+12),"uint",this,"uint*",ppDevice)
}
IDirect3DVertexDeclaration9_GetDeclaration(this,pElement,ByRef pNumElements) {
    return DllCall(NumGet(NumGet(this+0)+16),"uint",this,"uint",pElement,"uint*",pNumElements)
}
;
; IDirect3DVertexShader9
;
IDirect3DVertexShader9_GetDevice(this,ByRef ppDevice) {
    return DllCall(NumGet(NumGet(this+0)+12),"uint",this,"uint*",ppDevice)
}
IDirect3DVertexShader9_GetFunction(this,param2,ByRef pSizeOfData) {
    return DllCall(NumGet(NumGet(this+0)+16),"uint",this,"uint",param2,"uint*",pSizeOfData)
}
;
; IDirect3DPixelShader9
;
IDirect3DPixelShader9_GetDevice(this,ByRef ppDevice) {
    return DllCall(NumGet(NumGet(this+0)+12),"uint",this,"uint*",ppDevice)
}
IDirect3DPixelShader9_GetFunction(this,param2,ByRef pSizeOfData) {
    return DllCall(NumGet(NumGet(this+0)+16),"uint",this,"uint",param2,"uint*",pSizeOfData)
}
;
; IDirect3DBaseTexture9
;
IDirect3DBaseTexture9_GetDevice(this,ByRef ppDevice) {
    return DllCall(NumGet(NumGet(this+0)+12),"uint",this,"uint*",ppDevice)
}
IDirect3DBaseTexture9_SetPrivateData(this,refguid,pData,SizeOfData,Flags) {
    return DllCall(NumGet(NumGet(this+0)+16),"uint",this,"uint",refguid,"uint",pData,"uint",SizeOfData,"uint",Flags)
}
IDirect3DBaseTexture9_GetPrivateData(this,refguid,pData,ByRef pSizeOfData) {
    return DllCall(NumGet(NumGet(this+0)+20),"uint",this,"uint",refguid,"uint",pData,"uint*",pSizeOfData)
}
IDirect3DBaseTexture9_FreePrivateData(this,refguid) {
    return DllCall(NumGet(NumGet(this+0)+24),"uint",this,"uint",refguid)
}
IDirect3DBaseTexture9_SetPriority(this,PriorityNew) {
    return DllCall(NumGet(NumGet(this+0)+28),"uint",this,"uint",PriorityNew)
}
IDirect3DBaseTexture9_GetPriority(this) {
    return DllCall(NumGet(NumGet(this+0)+32),"uint",this)
}
IDirect3DBaseTexture9_PreLoad(this) {
    DllCall(NumGet(NumGet(this+0)+36),"uint",this)
}
IDirect3DBaseTexture9_GetType(this) {
    return DllCall(NumGet(NumGet(this+0)+40),"uint",this)
}
IDirect3DBaseTexture9_SetLOD(this,LODNew) {
    return DllCall(NumGet(NumGet(this+0)+44),"uint",this,"uint",LODNew)
}
IDirect3DBaseTexture9_GetLOD(this) {
    return DllCall(NumGet(NumGet(this+0)+48),"uint",this)
}
IDirect3DBaseTexture9_GetLevelCount(this) {
    return DllCall(NumGet(NumGet(this+0)+52),"uint",this)
}
IDirect3DBaseTexture9_SetAutoGenFilterType(this,FilterType) {
    return DllCall(NumGet(NumGet(this+0)+56),"uint",this,"uint",FilterType)
}
IDirect3DBaseTexture9_GetAutoGenFilterType(this) {
    return DllCall(NumGet(NumGet(this+0)+60),"uint",this)
}
IDirect3DBaseTexture9_GenerateMipSubLevels(this) {
    DllCall(NumGet(NumGet(this+0)+64),"uint",this)
}
;
; IDirect3DTexture9
;
IDirect3DTexture9_GetDevice(this,ByRef ppDevice) {
    return DllCall(NumGet(NumGet(this+0)+12),"uint",this,"uint*",ppDevice)
}
IDirect3DTexture9_SetPrivateData(this,refguid,pData,SizeOfData,Flags) {
    return DllCall(NumGet(NumGet(this+0)+16),"uint",this,"uint",refguid,"uint",pData,"uint",SizeOfData,"uint",Flags)
}
IDirect3DTexture9_GetPrivateData(this,refguid,pData,ByRef pSizeOfData) {
    return DllCall(NumGet(NumGet(this+0)+20),"uint",this,"uint",refguid,"uint",pData,"uint*",pSizeOfData)
}
IDirect3DTexture9_FreePrivateData(this,refguid) {
    return DllCall(NumGet(NumGet(this+0)+24),"uint",this,"uint",refguid)
}
IDirect3DTexture9_SetPriority(this,PriorityNew) {
    return DllCall(NumGet(NumGet(this+0)+28),"uint",this,"uint",PriorityNew)
}
IDirect3DTexture9_GetPriority(this) {
    return DllCall(NumGet(NumGet(this+0)+32),"uint",this)
}
IDirect3DTexture9_PreLoad(this) {
    DllCall(NumGet(NumGet(this+0)+36),"uint",this)
}
IDirect3DTexture9_GetType(this) {
    return DllCall(NumGet(NumGet(this+0)+40),"uint",this)
}
IDirect3DTexture9_SetLOD(this,LODNew) {
    return DllCall(NumGet(NumGet(this+0)+44),"uint",this,"uint",LODNew)
}
IDirect3DTexture9_GetLOD(this) {
    return DllCall(NumGet(NumGet(this+0)+48),"uint",this)
}
IDirect3DTexture9_GetLevelCount(this) {
    return DllCall(NumGet(NumGet(this+0)+52),"uint",this)
}
IDirect3DTexture9_SetAutoGenFilterType(this,FilterType) {
    return DllCall(NumGet(NumGet(this+0)+56),"uint",this,"uint",FilterType)
}
IDirect3DTexture9_GetAutoGenFilterType(this) {
    return DllCall(NumGet(NumGet(this+0)+60),"uint",this)
}
IDirect3DTexture9_GenerateMipSubLevels(this) {
    DllCall(NumGet(NumGet(this+0)+64),"uint",this)
}
IDirect3DTexture9_GetLevelDesc(this,Level,pDesc) {
    return DllCall(NumGet(NumGet(this+0)+68),"uint",this,"uint",Level,"uint",pDesc)
}
IDirect3DTexture9_GetSurfaceLevel(this,Level,ByRef ppSurfaceLevel) {
    return DllCall(NumGet(NumGet(this+0)+72),"uint",this,"uint",Level,"uint*",ppSurfaceLevel)
}
IDirect3DTexture9_LockRect(this,Level,pLockedRect,pRect,Flags) {
    return DllCall(NumGet(NumGet(this+0)+76),"uint",this,"uint",Level,"uint",pLockedRect,"uint",pRect,"uint",Flags)
}
IDirect3DTexture9_UnlockRect(this,Level) {
    return DllCall(NumGet(NumGet(this+0)+80),"uint",this,"uint",Level)
}
IDirect3DTexture9_AddDirtyRect(this,pDirtyRect) {
    return DllCall(NumGet(NumGet(this+0)+84),"uint",this,"uint",pDirtyRect)
}
;
; IDirect3DVolumeTexture9
;
IDirect3DVolumeTexture9_GetDevice(this,ByRef ppDevice) {
    return DllCall(NumGet(NumGet(this+0)+12),"uint",this,"uint*",ppDevice)
}
IDirect3DVolumeTexture9_SetPrivateData(this,refguid,pData,SizeOfData,Flags) {
    return DllCall(NumGet(NumGet(this+0)+16),"uint",this,"uint",refguid,"uint",pData,"uint",SizeOfData,"uint",Flags)
}
IDirect3DVolumeTexture9_GetPrivateData(this,refguid,pData,ByRef pSizeOfData) {
    return DllCall(NumGet(NumGet(this+0)+20),"uint",this,"uint",refguid,"uint",pData,"uint*",pSizeOfData)
}
IDirect3DVolumeTexture9_FreePrivateData(this,refguid) {
    return DllCall(NumGet(NumGet(this+0)+24),"uint",this,"uint",refguid)
}
IDirect3DVolumeTexture9_SetPriority(this,PriorityNew) {
    return DllCall(NumGet(NumGet(this+0)+28),"uint",this,"uint",PriorityNew)
}
IDirect3DVolumeTexture9_GetPriority(this) {
    return DllCall(NumGet(NumGet(this+0)+32),"uint",this)
}
IDirect3DVolumeTexture9_PreLoad(this) {
    DllCall(NumGet(NumGet(this+0)+36),"uint",this)
}
IDirect3DVolumeTexture9_GetType(this) {
    return DllCall(NumGet(NumGet(this+0)+40),"uint",this)
}
IDirect3DVolumeTexture9_SetLOD(this,LODNew) {
    return DllCall(NumGet(NumGet(this+0)+44),"uint",this,"uint",LODNew)
}
IDirect3DVolumeTexture9_GetLOD(this) {
    return DllCall(NumGet(NumGet(this+0)+48),"uint",this)
}
IDirect3DVolumeTexture9_GetLevelCount(this) {
    return DllCall(NumGet(NumGet(this+0)+52),"uint",this)
}
IDirect3DVolumeTexture9_SetAutoGenFilterType(this,FilterType) {
    return DllCall(NumGet(NumGet(this+0)+56),"uint",this,"uint",FilterType)
}
IDirect3DVolumeTexture9_GetAutoGenFilterType(this) {
    return DllCall(NumGet(NumGet(this+0)+60),"uint",this)
}
IDirect3DVolumeTexture9_GenerateMipSubLevels(this) {
    DllCall(NumGet(NumGet(this+0)+64),"uint",this)
}
IDirect3DVolumeTexture9_GetLevelDesc(this,Level,pDesc) {
    return DllCall(NumGet(NumGet(this+0)+68),"uint",this,"uint",Level,"uint",pDesc)
}
IDirect3DVolumeTexture9_GetVolumeLevel(this,Level,ByRef ppVolumeLevel) {
    return DllCall(NumGet(NumGet(this+0)+72),"uint",this,"uint",Level,"uint*",ppVolumeLevel)
}
IDirect3DVolumeTexture9_LockBox(this,Level,pLockedVolume,pBox,Flags) {
    return DllCall(NumGet(NumGet(this+0)+76),"uint",this,"uint",Level,"uint",pLockedVolume,"uint",pBox,"uint",Flags)
}
IDirect3DVolumeTexture9_UnlockBox(this,Level) {
    return DllCall(NumGet(NumGet(this+0)+80),"uint",this,"uint",Level)
}
IDirect3DVolumeTexture9_AddDirtyBox(this,pDirtyBox) {
    return DllCall(NumGet(NumGet(this+0)+84),"uint",this,"uint",pDirtyBox)
}
;
; IDirect3DCubeTexture9
;
IDirect3DCubeTexture9_GetDevice(this,ByRef ppDevice) {
    return DllCall(NumGet(NumGet(this+0)+12),"uint",this,"uint*",ppDevice)
}
IDirect3DCubeTexture9_SetPrivateData(this,refguid,pData,SizeOfData,Flags) {
    return DllCall(NumGet(NumGet(this+0)+16),"uint",this,"uint",refguid,"uint",pData,"uint",SizeOfData,"uint",Flags)
}
IDirect3DCubeTexture9_GetPrivateData(this,refguid,pData,ByRef pSizeOfData) {
    return DllCall(NumGet(NumGet(this+0)+20),"uint",this,"uint",refguid,"uint",pData,"uint*",pSizeOfData)
}
IDirect3DCubeTexture9_FreePrivateData(this,refguid) {
    return DllCall(NumGet(NumGet(this+0)+24),"uint",this,"uint",refguid)
}
IDirect3DCubeTexture9_SetPriority(this,PriorityNew) {
    return DllCall(NumGet(NumGet(this+0)+28),"uint",this,"uint",PriorityNew)
}
IDirect3DCubeTexture9_GetPriority(this) {
    return DllCall(NumGet(NumGet(this+0)+32),"uint",this)
}
IDirect3DCubeTexture9_PreLoad(this) {
    DllCall(NumGet(NumGet(this+0)+36),"uint",this)
}
IDirect3DCubeTexture9_GetType(this) {
    return DllCall(NumGet(NumGet(this+0)+40),"uint",this)
}
IDirect3DCubeTexture9_SetLOD(this,LODNew) {
    return DllCall(NumGet(NumGet(this+0)+44),"uint",this,"uint",LODNew)
}
IDirect3DCubeTexture9_GetLOD(this) {
    return DllCall(NumGet(NumGet(this+0)+48),"uint",this)
}
IDirect3DCubeTexture9_GetLevelCount(this) {
    return DllCall(NumGet(NumGet(this+0)+52),"uint",this)
}
IDirect3DCubeTexture9_SetAutoGenFilterType(this,FilterType) {
    return DllCall(NumGet(NumGet(this+0)+56),"uint",this,"uint",FilterType)
}
IDirect3DCubeTexture9_GetAutoGenFilterType(this) {
    return DllCall(NumGet(NumGet(this+0)+60),"uint",this)
}
IDirect3DCubeTexture9_GenerateMipSubLevels(this) {
    DllCall(NumGet(NumGet(this+0)+64),"uint",this)
}
IDirect3DCubeTexture9_GetLevelDesc(this,Level,pDesc) {
    return DllCall(NumGet(NumGet(this+0)+68),"uint",this,"uint",Level,"uint",pDesc)
}
IDirect3DCubeTexture9_GetCubeMapSurface(this,FaceType,Level,ByRef ppCubeMapSurface) {
    return DllCall(NumGet(NumGet(this+0)+72),"uint",this,"uint",FaceType,"uint",Level,"uint*",ppCubeMapSurface)
}
IDirect3DCubeTexture9_LockRect(this,FaceType,Level,pLockedRect,pRect,Flags) {
    return DllCall(NumGet(NumGet(this+0)+76),"uint",this,"uint",FaceType,"uint",Level,"uint",pLockedRect,"uint",pRect,"uint",Flags)
}
IDirect3DCubeTexture9_UnlockRect(this,FaceType,Level) {
    return DllCall(NumGet(NumGet(this+0)+80),"uint",this,"uint",FaceType,"uint",Level)
}
IDirect3DCubeTexture9_AddDirtyRect(this,FaceType,pDirtyRect) {
    return DllCall(NumGet(NumGet(this+0)+84),"uint",this,"uint",FaceType,"uint",pDirtyRect)
}
;
; IDirect3DVertexBuffer9
;
IDirect3DVertexBuffer9_GetDevice(this,ByRef ppDevice) {
    return DllCall(NumGet(NumGet(this+0)+12),"uint",this,"uint*",ppDevice)
}
IDirect3DVertexBuffer9_SetPrivateData(this,refguid,pData,SizeOfData,Flags) {
    return DllCall(NumGet(NumGet(this+0)+16),"uint",this,"uint",refguid,"uint",pData,"uint",SizeOfData,"uint",Flags)
}
IDirect3DVertexBuffer9_GetPrivateData(this,refguid,pData,ByRef pSizeOfData) {
    return DllCall(NumGet(NumGet(this+0)+20),"uint",this,"uint",refguid,"uint",pData,"uint*",pSizeOfData)
}
IDirect3DVertexBuffer9_FreePrivateData(this,refguid) {
    return DllCall(NumGet(NumGet(this+0)+24),"uint",this,"uint",refguid)
}
IDirect3DVertexBuffer9_SetPriority(this,PriorityNew) {
    return DllCall(NumGet(NumGet(this+0)+28),"uint",this,"uint",PriorityNew)
}
IDirect3DVertexBuffer9_GetPriority(this) {
    return DllCall(NumGet(NumGet(this+0)+32),"uint",this)
}
IDirect3DVertexBuffer9_PreLoad(this) {
    DllCall(NumGet(NumGet(this+0)+36),"uint",this)
}
IDirect3DVertexBuffer9_GetType(this) {
    return DllCall(NumGet(NumGet(this+0)+40),"uint",this)
}
IDirect3DVertexBuffer9_Lock(this,OffsetToLock,SizeToLock,ByRef ppbData,Flags) {
    return DllCall(NumGet(NumGet(this+0)+44),"uint",this,"uint",OffsetToLock,"uint",SizeToLock,"uint*",ppbData,"uint",Flags)
}
IDirect3DVertexBuffer9_Unlock(this) {
    return DllCall(NumGet(NumGet(this+0)+48),"uint",this)
}
IDirect3DVertexBuffer9_GetDesc(this,pDesc) {
    return DllCall(NumGet(NumGet(this+0)+52),"uint",this,"uint",pDesc)
}
;
; IDirect3DIndexBuffer9
;
IDirect3DIndexBuffer9_GetDevice(this,ByRef ppDevice) {
    return DllCall(NumGet(NumGet(this+0)+12),"uint",this,"uint*",ppDevice)
}
IDirect3DIndexBuffer9_SetPrivateData(this,refguid,pData,SizeOfData,Flags) {
    return DllCall(NumGet(NumGet(this+0)+16),"uint",this,"uint",refguid,"uint",pData,"uint",SizeOfData,"uint",Flags)
}
IDirect3DIndexBuffer9_GetPrivateData(this,refguid,pData,ByRef pSizeOfData) {
    return DllCall(NumGet(NumGet(this+0)+20),"uint",this,"uint",refguid,"uint",pData,"uint*",pSizeOfData)
}
IDirect3DIndexBuffer9_FreePrivateData(this,refguid) {
    return DllCall(NumGet(NumGet(this+0)+24),"uint",this,"uint",refguid)
}
IDirect3DIndexBuffer9_SetPriority(this,PriorityNew) {
    return DllCall(NumGet(NumGet(this+0)+28),"uint",this,"uint",PriorityNew)
}
IDirect3DIndexBuffer9_GetPriority(this) {
    return DllCall(NumGet(NumGet(this+0)+32),"uint",this)
}
IDirect3DIndexBuffer9_PreLoad(this) {
    DllCall(NumGet(NumGet(this+0)+36),"uint",this)
}
IDirect3DIndexBuffer9_GetType(this) {
    return DllCall(NumGet(NumGet(this+0)+40),"uint",this)
}
IDirect3DIndexBuffer9_Lock(this,OffsetToLock,SizeToLock,ByRef ppbData,Flags) {
    return DllCall(NumGet(NumGet(this+0)+44),"uint",this,"uint",OffsetToLock,"uint",SizeToLock,"uint*",ppbData,"uint",Flags)
}
IDirect3DIndexBuffer9_Unlock(this) {
    return DllCall(NumGet(NumGet(this+0)+48),"uint",this)
}
IDirect3DIndexBuffer9_GetDesc(this,pDesc) {
    return DllCall(NumGet(NumGet(this+0)+52),"uint",this,"uint",pDesc)
}
;
; IDirect3DSurface9
;
IDirect3DSurface9_GetDevice(this,ByRef ppDevice) {
    return DllCall(NumGet(NumGet(this+0)+12),"uint",this,"uint*",ppDevice)
}
IDirect3DSurface9_SetPrivateData(this,refguid,pData,SizeOfData,Flags) {
    return DllCall(NumGet(NumGet(this+0)+16),"uint",this,"uint",refguid,"uint",pData,"uint",SizeOfData,"uint",Flags)
}
IDirect3DSurface9_GetPrivateData(this,refguid,pData,ByRef pSizeOfData) {
    return DllCall(NumGet(NumGet(this+0)+20),"uint",this,"uint",refguid,"uint",pData,"uint*",pSizeOfData)
}
IDirect3DSurface9_FreePrivateData(this,refguid) {
    return DllCall(NumGet(NumGet(this+0)+24),"uint",this,"uint",refguid)
}
IDirect3DSurface9_SetPriority(this,PriorityNew) {
    return DllCall(NumGet(NumGet(this+0)+28),"uint",this,"uint",PriorityNew)
}
IDirect3DSurface9_GetPriority(this) {
    return DllCall(NumGet(NumGet(this+0)+32),"uint",this)
}
IDirect3DSurface9_PreLoad(this) {
    DllCall(NumGet(NumGet(this+0)+36),"uint",this)
}
IDirect3DSurface9_GetType(this) {
    return DllCall(NumGet(NumGet(this+0)+40),"uint",this)
}
IDirect3DSurface9_GetContainer(this,riid,ByRef ppContainer) {
    return DllCall(NumGet(NumGet(this+0)+44),"uint",this,"uint",riid,"uint*",ppContainer)
}
IDirect3DSurface9_GetDesc(this,pDesc) {
    return DllCall(NumGet(NumGet(this+0)+48),"uint",this,"uint",pDesc)
}
IDirect3DSurface9_LockRect(this,pLockedRect,pRect,Flags) {
    return DllCall(NumGet(NumGet(this+0)+52),"uint",this,"uint",pLockedRect,"uint",pRect,"uint",Flags)
}
IDirect3DSurface9_UnlockRect(this) {
    return DllCall(NumGet(NumGet(this+0)+56),"uint",this)
}
IDirect3DSurface9_GetDC(this,ByRef phdc) {
    return DllCall(NumGet(NumGet(this+0)+60),"uint",this,"uint*",phdc)
}
IDirect3DSurface9_ReleaseDC(this,hdc) {
    return DllCall(NumGet(NumGet(this+0)+64),"uint",this,"uint",hdc)
}
;
; IDirect3DVolume9
;
IDirect3DVolume9_GetDevice(this,ByRef ppDevice) {
    return DllCall(NumGet(NumGet(this+0)+12),"uint",this,"uint*",ppDevice)
}
IDirect3DVolume9_SetPrivateData(this,refguid,pData,SizeOfData,Flags) {
    return DllCall(NumGet(NumGet(this+0)+16),"uint",this,"uint",refguid,"uint",pData,"uint",SizeOfData,"uint",Flags)
}
IDirect3DVolume9_GetPrivateData(this,refguid,pData,ByRef pSizeOfData) {
    return DllCall(NumGet(NumGet(this+0)+20),"uint",this,"uint",refguid,"uint",pData,"uint*",pSizeOfData)
}
IDirect3DVolume9_FreePrivateData(this,refguid) {
    return DllCall(NumGet(NumGet(this+0)+24),"uint",this,"uint",refguid)
}
IDirect3DVolume9_GetContainer(this,riid,ByRef ppContainer) {
    return DllCall(NumGet(NumGet(this+0)+28),"uint",this,"uint",riid,"uint*",ppContainer)
}
IDirect3DVolume9_GetDesc(this,pDesc) {
    return DllCall(NumGet(NumGet(this+0)+32),"uint",this,"uint",pDesc)
}
IDirect3DVolume9_LockBox(this,pLockedVolume,pBox,Flags) {
    return DllCall(NumGet(NumGet(this+0)+36),"uint",this,"uint",pLockedVolume,"uint",pBox,"uint",Flags)
}
IDirect3DVolume9_UnlockBox(this) {
    return DllCall(NumGet(NumGet(this+0)+40),"uint",this)
}
;
; IDirect3DQuery9
;
IDirect3DQuery9_GetDevice(this,ByRef ppDevice) {
    return DllCall(NumGet(NumGet(this+0)+12),"uint",this,"uint*",ppDevice)
}
IDirect3DQuery9_GetType(this) {
    return DllCall(NumGet(NumGet(this+0)+16),"uint",this)
}
IDirect3DQuery9_GetDataSize(this) {
    return DllCall(NumGet(NumGet(this+0)+20),"uint",this)
}
IDirect3DQuery9_Issue(this,dwIssueFlags) {
    return DllCall(NumGet(NumGet(this+0)+24),"uint",this,"uint",dwIssueFlags)
}
IDirect3DQuery9_GetData(this,pData,dwSize,dwGetDataFlags) {
    return DllCall(NumGet(NumGet(this+0)+28),"uint",this,"uint",pData,"uint",dwSize,"uint",dwGetDataFlags)
}

; ==============================================================================
;                                 D3DX Functions
; ==============================================================================
D3DXFloat32To16Array(pOut,ByRef pIn,n) {
    return DllCall("d3dx9_37\D3DXFloat32To16Array","uint",pOut,"float*",pIn,"uint",n)
}
D3DXFloat16To32Array(ByRef pOut,pIn,n) {
    return DllCall("d3dx9_37\D3DXFloat16To32Array","float*",pOut,"uint",pIn,"uint",n)
}
D3DXVec2Normalize(pOut,pV) {
    return DllCall("d3dx9_37\D3DXVec2Normalize","uint",pOut,"uint",pV)
}
D3DXVec2Hermite(pOut,pV1,pT1,pV2,pT2,s) {
    return DllCall("d3dx9_37\D3DXVec2Hermite","uint",pOut,"uint",pV1,"uint",pT1,"uint",pV2,"uint",pT2,"float",s)
}
D3DXVec2CatmullRom(pOut,pV0,pV1,pV2,pV3,s) {
    return DllCall("d3dx9_37\D3DXVec2CatmullRom","uint",pOut,"uint",pV0,"uint",pV1,"uint",pV2,"uint",pV3,"float",s)
}
D3DXVec2BaryCentric(pOut,pV1,pV2,pV3,f,g) {
    return DllCall("d3dx9_37\D3DXVec2BaryCentric","uint",pOut,"uint",pV1,"uint",pV2,"uint",pV3,"float",f,"float",g)
}
D3DXVec2Transform(pOut,pV,pM) {
    return DllCall("d3dx9_37\D3DXVec2Transform","uint",pOut,"uint",pV,"uint",pM)
}
D3DXVec2TransformCoord(pOut,pV,pM) {
    return DllCall("d3dx9_37\D3DXVec2TransformCoord","uint",pOut,"uint",pV,"uint",pM)
}
D3DXVec2TransformNormal(pOut,pV,pM) {
    return DllCall("d3dx9_37\D3DXVec2TransformNormal","uint",pOut,"uint",pV,"uint",pM)
}
D3DXVec2TransformArray(pOut,OutStride,pV,VStride,pM,n) {
    return DllCall("d3dx9_37\D3DXVec2TransformArray","uint",pOut,"uint",OutStride,"uint",pV,"uint",VStride,"uint",pM,"uint",n)
}
D3DXVec2TransformCoordArray(pOut,OutStride,pV,VStride,pM,n) {
    return DllCall("d3dx9_37\D3DXVec2TransformCoordArray","uint",pOut,"uint",OutStride,"uint",pV,"uint",VStride,"uint",pM,"uint",n)
}
D3DXVec2TransformNormalArray(pOut,OutStride,pV,VStride,pM,n) {
    return DllCall("d3dx9_37\D3DXVec2TransformNormalArray","uint",pOut,"uint",OutStride,"uint",pV,"uint",VStride,"uint",pM,"uint",n)
}
D3DXVec3Normalize(pOut,pV) {
    return DllCall("d3dx9_37\D3DXVec3Normalize","uint",pOut,"uint",pV)
}
D3DXVec3Hermite(pOut,pV1,pT1,pV2,pT2,s) {
    return DllCall("d3dx9_37\D3DXVec3Hermite","uint",pOut,"uint",pV1,"uint",pT1,"uint",pV2,"uint",pT2,"float",s)
}
D3DXVec3CatmullRom(pOut,pV0,pV1,pV2,pV3,s) {
    return DllCall("d3dx9_37\D3DXVec3CatmullRom","uint",pOut,"uint",pV0,"uint",pV1,"uint",pV2,"uint",pV3,"float",s)
}
D3DXVec3BaryCentric(pOut,pV1,pV2,pV3,f,g) {
    return DllCall("d3dx9_37\D3DXVec3BaryCentric","uint",pOut,"uint",pV1,"uint",pV2,"uint",pV3,"float",f,"float",g)
}
D3DXVec3Transform(pOut,pV,pM) {
    return DllCall("d3dx9_37\D3DXVec3Transform","uint",pOut,"uint",pV,"uint",pM)
}
D3DXVec3TransformCoord(pOut,pV,pM) {
    return DllCall("d3dx9_37\D3DXVec3TransformCoord","uint",pOut,"uint",pV,"uint",pM)
}
D3DXVec3TransformNormal(pOut,pV,pM) {
    return DllCall("d3dx9_37\D3DXVec3TransformNormal","uint",pOut,"uint",pV,"uint",pM)
}
D3DXVec3TransformArray(pOut,OutStride,pV,VStride,pM,n) {
    return DllCall("d3dx9_37\D3DXVec3TransformArray","uint",pOut,"uint",OutStride,"uint",pV,"uint",VStride,"uint",pM,"uint",n)
}
D3DXVec3TransformCoordArray(pOut,OutStride,pV,VStride,pM,n) {
    return DllCall("d3dx9_37\D3DXVec3TransformCoordArray","uint",pOut,"uint",OutStride,"uint",pV,"uint",VStride,"uint",pM,"uint",n)
}
D3DXVec3TransformNormalArray(pOut,OutStride,pV,VStride,pM,n) {
    return DllCall("d3dx9_37\D3DXVec3TransformNormalArray","uint",pOut,"uint",OutStride,"uint",pV,"uint",VStride,"uint",pM,"uint",n)
}
D3DXVec3Project(pOut,pV,pViewport,pProjection,pView,pWorld) {
    return DllCall("d3dx9_37\D3DXVec3Project","uint",pOut,"uint",pV,"uint",pViewport,"uint",pProjection,"uint",pView,"uint",pWorld)
}
D3DXVec3Unproject(pOut,pV,pViewport,pProjection,pView,pWorld) {
    return DllCall("d3dx9_37\D3DXVec3Unproject","uint",pOut,"uint",pV,"uint",pViewport,"uint",pProjection,"uint",pView,"uint",pWorld)
}
D3DXVec3ProjectArray(pOut,OutStride,pV,VStride,pViewport,pProjection,pView,pWorld,n) {
    return DllCall("d3dx9_37\D3DXVec3ProjectArray","uint",pOut,"uint",OutStride,"uint",pV,"uint",VStride,"uint",pViewport,"uint",pProjection,"uint",pView,"uint",pWorld,"uint",n)
}
D3DXVec3UnprojectArray(pOut,OutStride,pV,VStride,pViewport,pProjection,pView,pWorld,n) {
    return DllCall("d3dx9_37\D3DXVec3UnprojectArray","uint",pOut,"uint",OutStride,"uint",pV,"uint",VStride,"uint",pViewport,"uint",pProjection,"uint",pView,"uint",pWorld,"uint",n)
}
D3DXVec4Cross(pOut,pV1,pV2,pV3) {
    return DllCall("d3dx9_37\D3DXVec4Cross","uint",pOut,"uint",pV1,"uint",pV2,"uint",pV3)
}
D3DXVec4Normalize(pOut,pV) {
    return DllCall("d3dx9_37\D3DXVec4Normalize","uint",pOut,"uint",pV)
}
D3DXVec4Hermite(pOut,pV1,pT1,pV2,pT2,s) {
    return DllCall("d3dx9_37\D3DXVec4Hermite","uint",pOut,"uint",pV1,"uint",pT1,"uint",pV2,"uint",pT2,"float",s)
}
D3DXVec4CatmullRom(pOut,pV0,pV1,pV2,pV3,s) {
    return DllCall("d3dx9_37\D3DXVec4CatmullRom","uint",pOut,"uint",pV0,"uint",pV1,"uint",pV2,"uint",pV3,"float",s)
}
D3DXVec4BaryCentric(pOut,pV1,pV2,pV3,f,g) {
    return DllCall("d3dx9_37\D3DXVec4BaryCentric","uint",pOut,"uint",pV1,"uint",pV2,"uint",pV3,"float",f,"float",g)
}
D3DXVec4Transform(pOut,pV,pM) {
    return DllCall("d3dx9_37\D3DXVec4Transform","uint",pOut,"uint",pV,"uint",pM)
}
D3DXVec4TransformArray(pOut,OutStride,pV,VStride,pM,n) {
    return DllCall("d3dx9_37\D3DXVec4TransformArray","uint",pOut,"uint",OutStride,"uint",pV,"uint",VStride,"uint",pM,"uint",n)
}
D3DXMatrixDeterminant(pM) {
    return DllCall("d3dx9_37\D3DXMatrixDeterminant","uint",pM)
}
D3DXMatrixDecompose(pOutScale,pOutRotation,pOutTranslation,pM) {
    return DllCall("d3dx9_37\D3DXMatrixDecompose","uint",pOutScale,"uint",pOutRotation,"uint",pOutTranslation,"uint",pM)
}
D3DXMatrixTranspose(pOut,pM) {
    return DllCall("d3dx9_37\D3DXMatrixTranspose","uint",pOut,"uint",pM)
}
D3DXMatrixMultiply(pOut,pM1,pM2) {
    return DllCall("d3dx9_37\D3DXMatrixMultiply","uint",pOut,"uint",pM1,"uint",pM2)
}
D3DXMatrixMultiplyTranspose(pOut,pM1,pM2) {
    return DllCall("d3dx9_37\D3DXMatrixMultiplyTranspose","uint",pOut,"uint",pM1,"uint",pM2)
}
D3DXMatrixInverse(pOut,ByRef pDeterminant,pM) {
    return DllCall("d3dx9_37\D3DXMatrixInverse","uint",pOut,"float*",pDeterminant,"uint",pM)
}
D3DXMatrixScaling(pOut,sx,sy,sz) {
    return DllCall("d3dx9_37\D3DXMatrixScaling","uint",pOut,"float",sx,"float",sy,"float",sz)
}
D3DXMatrixTranslation(pOut,x,y,z) {
    return DllCall("d3dx9_37\D3DXMatrixTranslation","uint",pOut,"float",x,"float",y,"float",z)
}
D3DXMatrixRotationX(pOut,Angle) {
    return DllCall("d3dx9_37\D3DXMatrixRotationX","uint",pOut,"float",Angle)
}
D3DXMatrixRotationY(pOut,Angle) {
    return DllCall("d3dx9_37\D3DXMatrixRotationY","uint",pOut,"float",Angle)
}
D3DXMatrixRotationZ(pOut,Angle) {
    return DllCall("d3dx9_37\D3DXMatrixRotationZ","uint",pOut,"float",Angle)
}
D3DXMatrixRotationAxis(pOut,pV,Angle) {
    return DllCall("d3dx9_37\D3DXMatrixRotationAxis","uint",pOut,"uint",pV,"float",Angle)
}
D3DXMatrixRotationQuaternion(pOut,pQ) {
    return DllCall("d3dx9_37\D3DXMatrixRotationQuaternion","uint",pOut,"uint",pQ)
}
D3DXMatrixRotationYawPitchRoll(pOut,Yaw,Pitch,Roll) {
    return DllCall("d3dx9_37\D3DXMatrixRotationYawPitchRoll","uint",pOut,"float",Yaw,"float",Pitch,"float",Roll)
}
D3DXMatrixTransformation(pOut,pScalingCenter,pScalingRotation,pScaling,pRotationCenter,pRotation,pTranslation) {
    return DllCall("d3dx9_37\D3DXMatrixTransformation","uint",pOut,"uint",pScalingCenter,"uint",pScalingRotation,"uint",pScaling,"uint",pRotationCenter,"uint",pRotation,"uint",pTranslation)
}
D3DXMatrixTransformation2D(pOut,pScalingCenter,ScalingRotation,pScaling,pRotationCenter,Rotation,pTranslation) {
    return DllCall("d3dx9_37\D3DXMatrixTransformation2D","uint",pOut,"uint",pScalingCenter,"float",ScalingRotation,"uint",pScaling,"uint",pRotationCenter,"float",Rotation,"uint",pTranslation)
}
D3DXMatrixAffineTransformation(pOut,Scaling,pRotationCenter,pRotation,pTranslation) {
    return DllCall("d3dx9_37\D3DXMatrixAffineTransformation","uint",pOut,"float",Scaling,"uint",pRotationCenter,"uint",pRotation,"uint",pTranslation)
}
D3DXMatrixAffineTransformation2D(pOut,Scaling,pRotationCenter,Rotation,pTranslation) {
    return DllCall("d3dx9_37\D3DXMatrixAffineTransformation2D","uint",pOut,"float",Scaling,"uint",pRotationCenter,"float",Rotation,"uint",pTranslation)
}
D3DXMatrixLookAtRH(pOut,pEye,pAt,pUp) {
    return DllCall("d3dx9_37\D3DXMatrixLookAtRH","uint",pOut,"uint",pEye,"uint",pAt,"uint",pUp)
}
D3DXMatrixLookAtLH(pOut,pEye,pAt,pUp) {
    return DllCall("d3dx9_37\D3DXMatrixLookAtLH","uint",pOut,"uint",pEye,"uint",pAt,"uint",pUp)
}
D3DXMatrixPerspectiveRH(pOut,w,h,zn,zf) {
    return DllCall("d3dx9_37\D3DXMatrixPerspectiveRH","uint",pOut,"float",w,"float",h,"float",zn,"float",zf)
}
D3DXMatrixPerspectiveLH(pOut,w,h,zn,zf) {
    return DllCall("d3dx9_37\D3DXMatrixPerspectiveLH","uint",pOut,"float",w,"float",h,"float",zn,"float",zf)
}
D3DXMatrixPerspectiveFovRH(pOut,fovy,Aspect,zn,zf) {
    return DllCall("d3dx9_37\D3DXMatrixPerspectiveFovRH","uint",pOut,"float",fovy,"float",Aspect,"float",zn,"float",zf)
}
D3DXMatrixPerspectiveFovLH(pOut,fovy,Aspect,zn,zf) {
    return DllCall("d3dx9_37\D3DXMatrixPerspectiveFovLH","uint",pOut,"float",fovy,"float",Aspect,"float",zn,"float",zf)
}
D3DXMatrixPerspectiveOffCenterRH(pOut,l,r,b,t,zn,zf) {
    return DllCall("d3dx9_37\D3DXMatrixPerspectiveOffCenterRH","uint",pOut,"float",l,"float",r,"float",b,"float",t,"float",zn,"float",zf)
}
D3DXMatrixPerspectiveOffCenterLH(pOut,l,r,b,t,zn,zf) {
    return DllCall("d3dx9_37\D3DXMatrixPerspectiveOffCenterLH","uint",pOut,"float",l,"float",r,"float",b,"float",t,"float",zn,"float",zf)
}
D3DXMatrixOrthoRH(pOut,w,h,zn,zf) {
    return DllCall("d3dx9_37\D3DXMatrixOrthoRH","uint",pOut,"float",w,"float",h,"float",zn,"float",zf)
}
D3DXMatrixOrthoLH(pOut,w,h,zn,zf) {
    return DllCall("d3dx9_37\D3DXMatrixOrthoLH","uint",pOut,"float",w,"float",h,"float",zn,"float",zf)
}
D3DXMatrixOrthoOffCenterRH(pOut,l,r,b,t,zn,zf) {
    return DllCall("d3dx9_37\D3DXMatrixOrthoOffCenterRH","uint",pOut,"float",l,"float",r,"float",b,"float",t,"float",zn,"float",zf)
}
D3DXMatrixOrthoOffCenterLH(pOut,l,r,b,t,zn,zf) {
    return DllCall("d3dx9_37\D3DXMatrixOrthoOffCenterLH","uint",pOut,"float",l,"float",r,"float",b,"float",t,"float",zn,"float",zf)
}
D3DXMatrixShadow(pOut,pLight,pPlane) {
    return DllCall("d3dx9_37\D3DXMatrixShadow","uint",pOut,"uint",pLight,"uint",pPlane)
}
D3DXMatrixReflect(pOut,pPlane) {
    return DllCall("d3dx9_37\D3DXMatrixReflect","uint",pOut,"uint",pPlane)
}
D3DXQuaternionToAxisAngle(pQ,pAxis,ByRef pAngle) {
    DllCall("d3dx9_37\D3DXQuaternionToAxisAngle","uint",pQ,"uint",pAxis,"float*",pAngle)
}
D3DXQuaternionRotationMatrix(pOut,pM) {
    return DllCall("d3dx9_37\D3DXQuaternionRotationMatrix","uint",pOut,"uint",pM)
}
D3DXQuaternionRotationAxis(pOut,pV,Angle) {
    return DllCall("d3dx9_37\D3DXQuaternionRotationAxis","uint",pOut,"uint",pV,"float",Angle)
}
D3DXQuaternionRotationYawPitchRoll(pOut,Yaw,Pitch,Roll) {
    return DllCall("d3dx9_37\D3DXQuaternionRotationYawPitchRoll","uint",pOut,"float",Yaw,"float",Pitch,"float",Roll)
}
D3DXQuaternionMultiply(pOut,pQ1,pQ2) {
    return DllCall("d3dx9_37\D3DXQuaternionMultiply","uint",pOut,"uint",pQ1,"uint",pQ2)
}
D3DXQuaternionNormalize(pOut,pQ) {
    return DllCall("d3dx9_37\D3DXQuaternionNormalize","uint",pOut,"uint",pQ)
}
D3DXQuaternionInverse(pOut,pQ) {
    return DllCall("d3dx9_37\D3DXQuaternionInverse","uint",pOut,"uint",pQ)
}
D3DXQuaternionLn(pOut,pQ) {
    return DllCall("d3dx9_37\D3DXQuaternionLn","uint",pOut,"uint",pQ)
}
D3DXQuaternionExp(pOut,pQ) {
    return DllCall("d3dx9_37\D3DXQuaternionExp","uint",pOut,"uint",pQ)
}
D3DXQuaternionSlerp(pOut,pQ1,pQ2,t) {
    return DllCall("d3dx9_37\D3DXQuaternionSlerp","uint",pOut,"uint",pQ1,"uint",pQ2,"float",t)
}
D3DXQuaternionSquad(pOut,pQ1,pA,pB,pC,t) {
    return DllCall("d3dx9_37\D3DXQuaternionSquad","uint",pOut,"uint",pQ1,"uint",pA,"uint",pB,"uint",pC,"float",t)
}
D3DXQuaternionSquadSetup(pAOut,pBOut,pCOut,pQ0,pQ1,pQ2,pQ3) {
    DllCall("d3dx9_37\D3DXQuaternionSquadSetup","uint",pAOut,"uint",pBOut,"uint",pCOut,"uint",pQ0,"uint",pQ1,"uint",pQ2,"uint",pQ3)
}
D3DXQuaternionBaryCentric(pOut,pQ1,pQ2,pQ3,f,g) {
    return DllCall("d3dx9_37\D3DXQuaternionBaryCentric","uint",pOut,"uint",pQ1,"uint",pQ2,"uint",pQ3,"float",f,"float",g)
}
D3DXPlaneNormalize(pOut,pP) {
    return DllCall("d3dx9_37\D3DXPlaneNormalize","uint",pOut,"uint",pP)
}
D3DXPlaneIntersectLine(pOut,pP,pV1,pV2) {
    return DllCall("d3dx9_37\D3DXPlaneIntersectLine","uint",pOut,"uint",pP,"uint",pV1,"uint",pV2)
}
D3DXPlaneFromPointNormal(pOut,pPoint,pNormal) {
    return DllCall("d3dx9_37\D3DXPlaneFromPointNormal","uint",pOut,"uint",pPoint,"uint",pNormal)
}
D3DXPlaneFromPoints(pOut,pV1,pV2,pV3) {
    return DllCall("d3dx9_37\D3DXPlaneFromPoints","uint",pOut,"uint",pV1,"uint",pV2,"uint",pV3)
}
D3DXPlaneTransform(pOut,pP,pM) {
    return DllCall("d3dx9_37\D3DXPlaneTransform","uint",pOut,"uint",pP,"uint",pM)
}
D3DXPlaneTransformArray(pOut,OutStride,pP,PStride,pM,n) {
    return DllCall("d3dx9_37\D3DXPlaneTransformArray","uint",pOut,"uint",OutStride,"uint",pP,"uint",PStride,"uint",pM,"uint",n)
}
D3DXColorAdjustSaturation(pOut,pC,s) {
    return DllCall("d3dx9_37\D3DXColorAdjustSaturation","uint",pOut,"uint",pC,"float",s)
}
D3DXColorAdjustContrast(pOut,pC,c) {
    return DllCall("d3dx9_37\D3DXColorAdjustContrast","uint",pOut,"uint",pC,"float",c)
}
D3DXFresnelTerm(CosTheta,RefractionIndex) {
    return DllCall("d3dx9_37\D3DXFresnelTerm","float",CosTheta,"float",RefractionIndex)
}
D3DXCreateMatrixStack(Flags,ppStack) {
    return DllCall("d3dx9_37\D3DXCreateMatrixStack","uint",Flags,"uint",ppStack)
}
D3DXSHEvalDirection(pOut,Order,pDir) {
    return DllCall("d3dx9_37\D3DXSHEvalDirection","uint",pOut,"uint",Order,"uint",pDir)
}
D3DXSHRotate(pOut,Order,pMatrix,pIn) {
    return DllCall("d3dx9_37\D3DXSHRotate","uint",pOut,"uint",Order,"uint",pMatrix,"uint",pIn)
}
D3DXSHRotateZ(pOut,Order,Angle,pIn) {
    return DllCall("d3dx9_37\D3DXSHRotateZ","uint",pOut,"uint",Order,"float",Angle,"uint",pIn)
}
D3DXSHAdd(pOut,Order,pA,pB) {
    return DllCall("d3dx9_37\D3DXSHAdd","uint",pOut,"uint",Order,"uint",pA,"uint",pB)
}
D3DXSHScale(pOut,Order,pIn,Scale) {
    return DllCall("d3dx9_37\D3DXSHScale","uint",pOut,"uint",Order,"uint",pIn,"float",Scale)
}
D3DXSHDot(Order,pA,pB) {
    return DllCall("d3dx9_37\D3DXSHDot","uint",Order,"uint",pA,"uint",pB)
}
D3DXSHMultiply2(pOut,pF,pG) {
    return DllCall("d3dx9_37\D3DXSHMultiply2","uint",pOut,"uint",pF,"uint",pG)
}
D3DXSHMultiply3(pOut,pF,pG) {
    return DllCall("d3dx9_37\D3DXSHMultiply3","uint",pOut,"uint",pF,"uint",pG)
}
D3DXSHMultiply4(pOut,pF,pG) {
    return DllCall("d3dx9_37\D3DXSHMultiply4","uint",pOut,"uint",pF,"uint",pG)
}
D3DXSHMultiply5(pOut,pF,pG) {
    return DllCall("d3dx9_37\D3DXSHMultiply5","uint",pOut,"uint",pF,"uint",pG)
}
D3DXSHMultiply6(pOut,pF,pG) {
    return DllCall("d3dx9_37\D3DXSHMultiply6","uint",pOut,"uint",pF,"uint",pG)
}
D3DXSHEvalDirectionalLight(Order,pDir,RIntensity,GIntensity,BIntensity,ByRef pROut,ByRef pGOut,ByRef pBOut) {
    return DllCall("d3dx9_37\D3DXSHEvalDirectionalLight","uint",Order,"uint",pDir,"float",RIntensity,"float",GIntensity,"float",BIntensity,"float*",pROut,"float*",pGOut,"float*",pBOut)
}
D3DXSHEvalSphericalLight(Order,pPos,Radius,RIntensity,GIntensity,BIntensity,ByRef pROut,ByRef pGOut,ByRef pBOut) {
    return DllCall("d3dx9_37\D3DXSHEvalSphericalLight","uint",Order,"uint",pPos,"float",Radius,"float",RIntensity,"float",GIntensity,"float",BIntensity,"float*",pROut,"float*",pGOut,"float*",pBOut)
}
D3DXSHEvalConeLight(Order,pDir,Radius,RIntensity,GIntensity,BIntensity,ByRef pROut,ByRef pGOut,ByRef pBOut) {
    return DllCall("d3dx9_37\D3DXSHEvalConeLight","uint",Order,"uint",pDir,"float",Radius,"float",RIntensity,"float",GIntensity,"float",BIntensity,"float*",pROut,"float*",pGOut,"float*",pBOut)
}
D3DXSHEvalHemisphereLight(Order,pDir,Top_r,Top_g,Top_b,Top_a,Bottom_r,Bottom_g,Bottom_b,Bottom_a,ByRef pROut,ByRef pGOut,ByRef pBOut) {
    return DllCall("d3dx9_37\D3DXSHEvalHemisphereLight","uint",Order,"uint",pDir,"float",Top_r,"float",Top_g,"float",Top_b,"float",Top_a,"float",Bottom_r,"float",Bottom_g,"float",Bottom_b,"float",Bottom_a,"float*",pROut,"float*",pGOut,"float*",pBOut)
}
D3DXSHProjectCubeMap(uOrder,pCubeMap,ByRef pROut,ByRef pGOut,ByRef pBOut) {
    return DllCall("d3dx9_37\D3DXSHProjectCubeMap","uint",uOrder,"uint",pCubeMap,"float*",pROut,"float*",pGOut,"float*",pBOut)
}


Struct(ByRef buf, p*) {
    VarSetCapacity(tbuf, 8)
    size := 0
    Loop % p.Length()//2
        size += NumPut(0, tbuf, 0, p[A_Index*2-1]) - &tbuf
    VarSetCapacity(buf, size, 0), addr := &buf
    Loop % p.Length()//2
        addr := NumPut(p[A_Index*2], addr+0, 0, p[A_Index*2-1])
    return &buf
}

StdOut(s, t) {
    FileAppend % t ": " s "`n", *
}
lexikos
Posts: 7057
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: Direct3D proof of concept / Steam BPM overlay

04 Mar 2017, 20:13

Steam BPM Overlay

So why was I looking for a minimal program which uses Direct3D? Steam Big Picture Mode's overlay does not work in games which don't use Direct3D or OpenGL. As a result, Steam doesn't recognize the game for the purpose of setting the appropriate Steam Controller configuration. So what I did with the script was this:
  • Changed it to always use the DWM direct-render method.
  • Removed the spinning triangle and FPS tooltip.
  • Added XInput_Init() (requires XInput.ahk).
... and then a bit of setup (which you'll need to do if you want the same results):
  • Compile the script.
  • Add the script executable to Steam as a "game".
  • Configure the controller as needed for this "game".
  • Launch the game from Steam (from Big Picture Mode if necessary).
The end result is that the "game" opens a full-screen window which is initially invisible, but pressing the Steam button on the Steam Controller opens the Big Picture Mode overlay. Other open windows can still be seen through the overlay, which is semi-transparent. I can then configure the controller via the overlay, then Alt+Tab back to the actual game and play.

Limitations:
  • Mouse and keyboard input doesn't work in the overlay. I have no idea how Steam hooks mouse and keyboard input (or in this case, doesn't).
  • You can't click through the window. As I mentioned above, the DWM direct-render trick prevents the WS_EX_TRANSPARENT style from working. Use hotkeys like Alt+Tab or Win+D to get away, or Alt+F4 to close it.
  • The overlay sometimes acts funky - the buttons for binding controls sometimes stop working, and as soon as you close the game, Steam crashes. I don't know if this is a general Steam bug, or if it's specific to this script, or because of the fact that I'm running two "games" through Steam at the same time.
Ideas for the future (for someone else to implement): ;)
  • Mouse input could be passed through by detecting clicks with OnMessage, punching a hole through the window with WinSet Region and then sending a click. I've seen this trick used many years ago, and I've confirmed that WinSet Region does affect the script's window.
  • Keyboard input could be passed through by catching keyboard messages with OnMessage and passing them along with PostMessage or ControlSend.

Code: Select all

#SingleInstance Force

if !(!DllCall("dwmapi\DwmIsCompositionEnabled","int*",HasDwm) && HasDwm)
{
    MsgBox 16,, This app requires Vista or later with DWM enabled.
    ExitApp
}
if (A_PtrSize = 8)
{
    MsgBox 16,, This script requires AutoHotkey 32-bit.
    ExitApp
}

; Initialize XInput. Steam hooks into this. If not loaded,
; Steam will not initialize the controller configuration.
XInput_Init()

Gui, +LastFound
GuiHwnd := WinExist()

Gui, -Caption -DPIScale +E0x20
; Gui, +AlwaysOnTop

GuiW := A_ScreenWidth
GuiH := A_ScreenHeight
Gui, Show, X0 Y0 W%GuiW% H%GuiH% Hide
WinGetPos,,, GuiW, GuiH

gosub DirectX_Defines

d3d := Direct3DCreate9(D3D_SDK_VERSION)
if !d3d
{
    MsgBox, 16, Error, Direct3DCreate9 failed.
    ExitApp
}

if !IDirect3D9_CheckDeviceMultiSampleType(d3d
        , D3DADAPTER_DEFAULT
        , D3DDEVTYPE_HAL
        , D3DFMT_A8R8G8B8
        , true
        , D3DMULTISAMPLE_NONMASKABLE
        , multisample_quality)
    multisample := true

gosub PreparePresentationParameters

hr := IDirect3D9_CreateDevice(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, GuiHwnd
                        , D3DCREATE_SOFTWARE_VERTEXPROCESSING
                        , &pp, dev)
if hr
{
    SetFormat, Integer, H
    hr &= 0xFFFFFFFF
    MsgBox, 16, Error, IDirect3D9_CreateDevice returned error code %hr%.
    ExitApp
}

OnMessage(0x5, "OnSize") ; WM_SIZE
OnMessage(0x14, "OnErase") ; WM_ERASEBKGND
OnMessage(0x84, "OnHitTest") ; WM_NCHITTEST

DllCall("QueryPerformanceFrequency","int64*",perf_freq)

; Set up temporary surfaces, etc.
RecreateResources()

DllCall("dwmapi\DwmExtendFrameIntoClientArea","uint",GuiHwnd,"uint"
    , Struct(rect,"int",-1,"int",-1,"int",-1,"int",-1))

; WinSet Region, 0-0 W500 H500

Gui, Show

SetTimer, PaintLoop, -1
return

PreparePresentationParameters:
VarSetCapacity(pp, 56, 0) ; D3DPRESENT_PARAMETERS
NumPut(true, pp, 32) ; Windowed
NumPut(D3DSWAPEFFECT_DISCARD, pp, 24) ; SwapEffect
NumPut(D3DFMT_A8R8G8B8, pp, 8) ; BackBufferFormat
if (multisample) {
    NumPut(D3DMULTISAMPLE_NONMASKABLE, pp, 16)
    NumPut(multisample_quality-1, pp, 20)
}
return

; Release resources that must be released before resetting the device.
ReleaseResources()
{
    global
    D3DRelease(temp_surface), temp_surface:=0
}

; Recreate resources that must be recreated after the device is lost.
RecreateResources()
{
    global
    ; Create a 1x1 surface for retrieving pixel data to hit-test.
    ERRq(IDirect3DDevice9_CreateRenderTarget(dev, 1, 1, D3DFMT_A8R8G8B8
        , D3DMULTISAMPLE_NONE, 0, true, temp_surface, NULL), "CreateRenderTarget")
}

PaintLoop:
SetBatchLines, -1
Loop {
    Critical, 1000 ; Prevent OnSize -> device reset while rendering.
    OnPaint(0,0,0xF,GuiHwnd)
    Critical, Off

    ; DllCall("QueryPerformanceCounter","int64*",render_this)
    ; if (render_last) {
        ; render_ticks += render_this-render_last
        ; render_count += 1
        ; ToolTip % 1/(render_ticks/perf_freq/render_count) " fps"
    ; }
    ; render_last := render_this

    Sleep, -1
}
return

OnErase() { ; Do all rendering in OnPaint().
    Critical 1000
    if A_Gui
        return 1
}

OnSize()
{
    global
    Critical 1000
    if !A_Gui
        return
    ; Reset pp since it is modified by CreateDevice() and Reset().
    gosub PreparePresentationParameters
    ; Reset the device to resize its backbuffer.
    Gui, +LastFound
    WinGetPos,,, GuiW, GuiH
    ReleaseResources()
    ERRq(IDirect3DDevice9_Reset(dev, &pp), "Reset")
    RecreateResources()
}

OnHitTest(wParam, lParam, msg, hwnd)
{
    return -1 ; HTTRANSPARENT
}

OnPaint(wParam, lParam, msg, hwnd)
{
    local vp ; Viewport
        , w, h, matrix, vEye, vAt, vUp ; Transformations
        , light, verts ; Structures for content
        , back_buffer, locked_bits, pitch, locked_rect ; UpdateLayeredWindow
    static PI=3.141592653589

    GetClientSize(hwnd, w, h)
    ; Clear the display.
    if ERRq(IDirect3DDevice9_Clear(dev, 1, NULL, D3DCLEAR_TARGET, 0x000000, 1.0, 0), "Clear")
    {   ; Device lost?
        return 0
    }
    
    ;
    ; Set up the camera.
    ;
    VarSetCapacity(matrix,64)
    
    D3DXMatrixPerspectiveFovLH(&matrix, PI/4, w/h, 1.0, 100.0)
    ERRq(IDirect3DDevice9_SetTransform(dev, D3DTS_PROJECTION, &matrix), "SetTransform")
    
    D3DXMatrixLookAtLH(&matrix
        , D3DVector(vEye,0,0,5)  ; eye point
        , D3DVector(vAt, 0,0,0)  ; camera look-at target
        , D3DVector(vUp, 0,1,0)) ; current world's up
    ERRq(IDirect3DDevice9_SetTransform(dev, D3DTS_VIEW, &matrix), "SetTransform")
    
    ; Rotate the world!
    D3DXMatrixRotationY(&matrix, Mod(A_TickCount,3000) / 3000.0 * 2*PI)
    ERRq(IDirect3DDevice9_SetTransform(dev, D3DTS_WORLDMATRIX_0, &matrix), "SetTransform")
    
    ;
    ; Set up the device.
    ;
    ; ERRq(IDirect3DDevice9_SetRenderState(dev, D3DRS_CULLMODE, D3DCULL_NONE), "SetRenderState:D3DRS_CULLMODE")
    ; ERRq(IDirect3DDevice9_SetRenderState(dev, D3DRS_LIGHTING, false), "SetRenderState:D3DRS_LIGHTING")
    ; ERRq(IDirect3DDevice9_SetRenderState(dev, D3DRS_ALPHABLENDENABLE, true), "SetRenderState:D3DRS_ALPHABLENDENABLE")
    ; ERRq(IDirect3DDevice9_SetRenderState(dev, D3DRS_SRCBLEND, D3DBLEND_SRCALPHA), "SetRenderState:D3DRS_SRCBLEND")
    ; ERRq(IDirect3DDevice9_SetRenderState(dev, D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA), "SetRenderState:D3DRS_DESTBLEND")
    
    ;
    ; Render an empty scene
    ;
    ERRq(IDirect3DDevice9_BeginScene(dev), "BeginScene")
    ERRq(IDirect3DDevice9_EndScene(dev), "EndScene")
    ERRq(IDirect3DDevice9_Present(dev, NULL, NULL, NULL, NULL), "Present")
    
    ; Since we didn't call BeginPaint(), the invalidated region of
    ; the window is left invalid, and OnPaint() essentially loops.
    return 0
}

CreateDIBSection(w, h, bpp, hDC=0, ByRef ppvBits=0)
{
    hdcUsed := hDC ? hDC : DllCall("GetDC", "UInt", 0)
    if (hdcUsed)
    {
        VarSetCapacity(bi, 40, 0) ; BITMAPINFO(HEADER)
        NumPut(40, bi,  0)              ; biSize
        NumPut(1,  bi, 12, "UShort")    ; biPlanes
        NumPut(0,  bi, 16)              ; biCompression = BI_RGB (none)
        NumPut(w,  bi,  4)              ; biWidth
        NumPut(h,  bi,  8)              ; biHeight
        NumPut(bpp,bi, 14, "UShort")    ; biBitCount
        
        hbmp := DllCall("CreateDIBSection"
            , "UInt" , hDC
            , "UInt" , &bi   ; defines format, attributes, etc.
            , "UInt" , 0     ; iUsage = DIB_RGB_COLORS
            , "UInt*", ppvBits ; gets a pointer to the bitmap data
            , "UInt" , 0
            , "UInt" , 0)

        if (hdcUsed != hDC)
            DllCall("ReleaseDC", "UInt", 0, "UInt", hdcUsed)

        return hbmp
    }
    return 0
}

ERRq(hresult, tag) {
    if !hresult
        return
    fi := A_FormatInteger
    SetFormat, Integer, H
    hresult &= 0xFFFFFFFF
    SetFormat, Integer, %fi%
    StdOut(hresult, "Error calling " tag)
    return hresult
}

D3DVector(ByRef v, x, y, z) {
    VarSetCapacity(v,12), NumPut(z,NumPut(y,NumPut(x,v,0,"float"),0,"float"),0,"float")
    return &v
}
D3DRelease(ppv) { ; COM_Release. So far the only required COM_* function...
	Return	DllCall(NumGet(NumGet(1*ppv)+8), "Uint", ppv)
}

GetClientSize(hwnd, ByRef w, ByRef h)
{
    VarSetCapacity(rc, 16)
    DllCall("GetClientRect", "uint", hwnd, "uint", &rc)
    w := NumGet(rc, 8, "int")
    h := NumGet(rc, 12, "int")
}

; GuiEscape:
GuiClose:
ExitApp


DirectX_Defines:
;
; Constants
;
NULL = 0

D3D_SDK_VERSION = 32

D3DADAPTER_DEFAULT = 0

D3DCREATE_FPU_PRESERVE                  = 0x00000002
D3DCREATE_MULTITHREADED                 = 0x00000004
D3DCREATE_PUREDEVICE                    = 0x00000010
D3DCREATE_SOFTWARE_VERTEXPROCESSING     = 0x00000020
D3DCREATE_HARDWARE_VERTEXPROCESSING     = 0x00000040
D3DCREATE_MIXED_VERTEXPROCESSING        = 0x00000080
D3DCREATE_DISABLE_DRIVER_MANAGEMENT     = 0x00000100
D3DCREATE_ADAPTERGROUP_DEVICE           = 0x00000200
D3DCREATE_DISABLE_DRIVER_MANAGEMENT_EX  = 0x00000400
D3DCREATE_NOWINDOWCHANGES				= 0x00000800

D3DSWAPEFFECT_DISCARD = 1
D3DSWAPEFFECT_FLIP = 2
D3DSWAPEFFECT_COPY = 3

D3DCLEAR_TARGET   = 0x00000001
D3DCLEAR_ZBUFFER  = 0x00000002
D3DCLEAR_STENCIL  = 0x00000004

D3DPRESENTFLAG_LOCKABLE_BACKBUFFER     = 0x00000001
D3DPRESENTFLAG_DISCARD_DEPTHSTENCIL    = 0x00000002
D3DPRESENTFLAG_DEVICECLIP              = 0x00000004
D3DPRESENTFLAG_VIDEO                   = 0x00000010
;
; Enumerations
;   TODO: Write a script to automatically generate these from d3d9types.h
;
D3DDEVTYPE_HAL         = 1
D3DDEVTYPE_REF         = 2
D3DDEVTYPE_SW          = 3
D3DDEVTYPE_NULLREF     = 4

D3DTS_VIEW = 2
D3DTS_PROJECTION = 3
D3DTS_TEXTURE0 = 16
D3DTS_TEXTURE1 = 17
D3DTS_TEXTURE2 = 18
D3DTS_TEXTURE3 = 19
D3DTS_TEXTURE4 = 20
D3DTS_TEXTURE5 = 21
D3DTS_TEXTURE6 = 22
D3DTS_TEXTURE7 = 23
;#define D3DTS_WORLDMATRIX(index) (D3DTRANSFORMSTATETYPE)(index + 256)
D3DTS_WORLDMATRIX_0 = 256

D3DRS_ZENABLE = 7
D3DRS_FILLMODE = 8
D3DRS_SHADEMODE = 9
D3DRS_ZWRITEENABLE = 14
D3DRS_ALPHATESTENABLE = 15
D3DRS_LASTPIXEL = 16
D3DRS_SRCBLEND = 19
D3DRS_DESTBLEND = 20
D3DRS_CULLMODE = 22
D3DRS_ZFUNC = 23
D3DRS_ALPHAREF = 24
D3DRS_ALPHAFUNC = 25
D3DRS_DITHERENABLE = 26
D3DRS_ALPHABLENDENABLE = 27
D3DRS_FOGENABLE = 28
D3DRS_SPECULARENABLE = 29
D3DRS_FOGCOLOR = 34
D3DRS_FOGTABLEMODE = 35
D3DRS_FOGSTART = 36
D3DRS_FOGEND = 37
D3DRS_FOGDENSITY = 38
D3DRS_RANGEFOGENABLE = 48
D3DRS_STENCILENABLE = 52
D3DRS_STENCILFAIL = 53
D3DRS_STENCILZFAIL = 54
D3DRS_STENCILPASS = 55
D3DRS_STENCILFUNC = 56
D3DRS_STENCILREF = 57
D3DRS_STENCILMASK = 58
D3DRS_STENCILWRITEMASK = 59
D3DRS_TEXTUREFACTOR = 60
D3DRS_WRAP0 = 128
D3DRS_WRAP1 = 129
D3DRS_WRAP2 = 130
D3DRS_WRAP3 = 131
D3DRS_WRAP4 = 132
D3DRS_WRAP5 = 133
D3DRS_WRAP6 = 134
D3DRS_WRAP7 = 135
D3DRS_CLIPPING = 136
D3DRS_LIGHTING = 137
D3DRS_AMBIENT = 139
D3DRS_FOGVERTEXMODE = 140
D3DRS_COLORVERTEX = 141
D3DRS_LOCALVIEWER = 142
D3DRS_NORMALIZENORMALS = 143
D3DRS_DIFFUSEMATERIALSOURCE = 145
D3DRS_SPECULARMATERIALSOURCE = 146
D3DRS_AMBIENTMATERIALSOURCE = 147
D3DRS_EMISSIVEMATERIALSOURCE = 148
D3DRS_VERTEXBLEND = 151
D3DRS_CLIPPLANEENABLE = 152
D3DRS_POINTSIZE = 154
D3DRS_POINTSIZE_MIN = 155
D3DRS_POINTSPRITEENABLE = 156
D3DRS_POINTSCALEENABLE = 157
D3DRS_POINTSCALE_A = 158
D3DRS_POINTSCALE_B = 159
D3DRS_POINTSCALE_C = 160
D3DRS_MULTISAMPLEANTIALIAS = 161
D3DRS_MULTISAMPLEMASK = 162
D3DRS_PATCHEDGESTYLE = 163
D3DRS_DEBUGMONITORTOKEN = 165
D3DRS_POINTSIZE_MAX = 166
D3DRS_INDEXEDVERTEXBLENDENABLE = 167
D3DRS_COLORWRITEENABLE = 168
D3DRS_TWEENFACTOR = 170
D3DRS_BLENDOP = 171
D3DRS_POSITIONDEGREE = 172
D3DRS_NORMALDEGREE = 173
D3DRS_SCISSORTESTENABLE = 174
D3DRS_SLOPESCALEDEPTHBIAS = 175
D3DRS_ANTIALIASEDLINEENABLE = 176
D3DRS_MINTESSELLATIONLEVEL = 178
D3DRS_MAXTESSELLATIONLEVEL = 179
D3DRS_ADAPTIVETESS_X = 180
D3DRS_ADAPTIVETESS_Y = 181
D3DRS_ADAPTIVETESS_Z = 182
D3DRS_ADAPTIVETESS_W = 183
D3DRS_ENABLEADAPTIVETESSELLATION = 184
D3DRS_TWOSIDEDSTENCILMODE = 185
D3DRS_CCW_STENCILFAIL = 186
D3DRS_CCW_STENCILZFAIL = 187
D3DRS_CCW_STENCILPASS = 188
D3DRS_CCW_STENCILFUNC = 189
D3DRS_COLORWRITEENABLE1 = 190
D3DRS_COLORWRITEENABLE2 = 191
D3DRS_COLORWRITEENABLE3 = 192
D3DRS_BLENDFACTOR = 193
D3DRS_SRGBWRITEENABLE = 194
D3DRS_DEPTHBIAS = 195
D3DRS_WRAP8 = 198
D3DRS_WRAP9 = 199
D3DRS_WRAP10 = 200
D3DRS_WRAP11 = 201
D3DRS_WRAP12 = 202
D3DRS_WRAP13 = 203
D3DRS_WRAP14 = 204
D3DRS_WRAP15 = 205
D3DRS_SEPARATEALPHABLENDENABLE = 206
D3DRS_SRCBLENDALPHA = 207
D3DRS_DESTBLENDALPHA = 208
D3DRS_BLENDOPALPHA = 209

D3DCULL_NONE = 1
D3DCULL_CW = 2
D3DCULL_CCW = 3

D3DFVF_RESERVED0        = 0x001
D3DFVF_POSITION_MASK    = 0x400E
D3DFVF_XYZ              = 0x002
D3DFVF_XYZRHW           = 0x004
D3DFVF_XYZB1            = 0x006
D3DFVF_XYZB2            = 0x008
D3DFVF_XYZB3            = 0x00a
D3DFVF_XYZB4            = 0x00c
D3DFVF_XYZB5            = 0x00e
D3DFVF_XYZW             = 0x4002

D3DFVF_NORMAL           = 0x010
D3DFVF_PSIZE            = 0x020
D3DFVF_DIFFUSE          = 0x040
D3DFVF_SPECULAR         = 0x080

D3DFVF_TEXCOUNT_MASK    = 0xf00
D3DFVF_TEXCOUNT_SHIFT   = 8
D3DFVF_TEX0             = 0x000
D3DFVF_TEX1             = 0x100
D3DFVF_TEX2             = 0x200
D3DFVF_TEX3             = 0x300
D3DFVF_TEX4             = 0x400
D3DFVF_TEX5             = 0x500
D3DFVF_TEX6             = 0x600
D3DFVF_TEX7             = 0x700
D3DFVF_TEX8             = 0x800

D3DFVF_LASTBETA_UBYTE4   = 0x1000
D3DFVF_LASTBETA_D3DCOLOR = 0x8000

D3DPT_POINTLIST = 1
D3DPT_LINELIST = 2
D3DPT_LINESTRIP = 3
D3DPT_TRIANGLELIST = 4
D3DPT_TRIANGLESTRIP = 5
D3DPT_TRIANGLEFAN = 6

D3DLIGHT_POINT = 1
D3DLIGHT_SPOT = 2
D3DLIGHT_DIRECTIONAL = 3

D3DBLEND_ZERO = 1
D3DBLEND_ONE = 2
D3DBLEND_SRCCOLOR = 3
D3DBLEND_INVSRCCOLOR = 4
D3DBLEND_SRCALPHA = 5
D3DBLEND_INVSRCALPHA = 6
D3DBLEND_DESTALPHA = 7
D3DBLEND_INVDESTALPHA = 8
D3DBLEND_DESTCOLOR = 9
D3DBLEND_INVDESTCOLOR = 10
D3DBLEND_SRCALPHASAT = 11
D3DBLEND_BOTHSRCALPHA = 12
D3DBLEND_BOTHINVSRCALPHA = 13
D3DBLEND_BLENDFACTOR = 14
D3DBLEND_INVBLENDFACTOR = 15
D3DBLEND_SRCCOLOR2 = 16
D3DBLEND_INVSRCCOLOR2 = 17

D3DBLENDOP_ADD              = 1
D3DBLENDOP_SUBTRACT         = 2
D3DBLENDOP_REVSUBTRACT      = 3
D3DBLENDOP_MIN              = 4
D3DBLENDOP_MAX              = 5

; BackBuffer/Display Formats
D3DFMT_A8R8G8B8             = 21
D3DFMT_X8R8G8B8             = 22
D3DFMT_R5G6B5               = 23
D3DFMT_X1R5G5B5             = 24
D3DFMT_A1R5G5B5             = 25
D3DFMT_A2R10G10B10          = 35

D3DMULTISAMPLE_NONE = 0
D3DMULTISAMPLE_NONMASKABLE  = 1
D3DMULTISAMPLE_2_SAMPLES = 2
D3DMULTISAMPLE_3_SAMPLES = 3
D3DMULTISAMPLE_4_SAMPLES = 4
D3DMULTISAMPLE_5_SAMPLES = 5
D3DMULTISAMPLE_6_SAMPLES = 6
D3DMULTISAMPLE_7_SAMPLES = 7
D3DMULTISAMPLE_8_SAMPLES = 8
D3DMULTISAMPLE_9__SAMPLES = 9
D3DMULTISAMPLE_10_SAMPLES = 10
D3DMULTISAMPLE_11_SAMPLES = 11
D3DMULTISAMPLE_12_SAMPLES = 12
D3DMULTISAMPLE_13_SAMPLES = 13
D3DMULTISAMPLE_14_SAMPLES = 14
D3DMULTISAMPLE_15_SAMPLES = 15
D3DMULTISAMPLE_16_SAMPLES = 16

D3DBACKBUFFER_TYPE_MONO = 0
D3DBACKBUFFER_TYPE_LEFT = 1
D3DBACKBUFFER_TYPE_RIGHT = 2

D3DPOOL_DEFAULT = 0
D3DPOOL_MANAGED = 1
D3DPOOL_SYSTEMMEM = 2
D3DPOOL_SCRATCH = 3

D3DTEXF_NONE = 0
D3DTEXF_POINT = 1
D3DTEXF_LINEAR = 2
D3DTEXF_ANISOTROPIC = 3
D3DTEXF_PYRAMIDALQUAD = 6
D3DTEXF_GAUSSIANQUAD = 7
D3DTEXF_CONVOLUTIONMONO = 8
;
; Interface IDs
;
IDirect3D9 := "81BDCBCA-64D4-426d-AE8D-AD0147F4275C"
IDirect3DDevice9 := "D0223B96-BF7A-43fd-92BD-A43B0D82B9EB"
IDirect3DStateBlock9 := "B07C4FE5-310D-4ba8-A23C-4F0F206F218B"
IDirect3DResource9 := "05EEC05D-8F7D-4362-B999-D1BAF357C704"
IDirect3DVertexDeclaration9 := "DD13C59C-36FA-4098-A8FB-C7ED39DC8546"
IDirect3DVertexShader9 := "EFC5557E-6265-4613-8A94-43857889EB36"
IDirect3DPixelShader9 := "6D3BDBDC-5B02-4415-B852-CE5E8BCCB289"
IDirect3DBaseTexture9 := "580CA87E-1D3C-4d54-991D-B7D3E3C298CE"
IDirect3DTexture9 := "85C31227-3DE5-4f00-9B3A-F11AC38C18B5"
IDirect3DVolumeTexture9 := "2518526C-E789-4111-A7B9-47EF328D13E6"
IDirect3DCubeTexture9 := "FFF32F81-D953-473a-9223-93D652ABA93F"
IDirect3DVertexBuffer9 := "B64BB1B5-FD70-4df6-BF91-19D0A12455E3"
IDirect3DIndexBuffer9 := "7C9DD65E-D3F7-4529-ACEE-785830ACDE35"
IDirect3DSurface9 := "0CFBAF3A-9FF6-429a-99B3-A2796AF8B89B"
IDirect3DVolume9 := "24F416E6-1F67-4aa7-B88E-D33F6F3128A1"
IDirect3DSwapChain9 := "794950F2-ADFC-458a-905E-10A10B0B503B"
IDirect3DQuery9 := "d9771460-a695-4f26-bbd3-27b840b541cc"
return

; =============================================================================
;                               Direct3D Functions
; =============================================================================
Direct3DCreate9(SDKVersion) {
    if !DllCall("GetModuleHandle","str","d3d9")
        DllCall("LoadLibrary","str","d3d9")
    return DllCall("d3d9\Direct3DCreate9", "uint", SDKVersion)
}

; ==============================================================================
;                               Direct3D Interfaces
; ==============================================================================
;
; IDirect3D9
;
IDirect3D9_RegisterSoftwareDevice(this,pInitializeFunction) {
    return DllCall(NumGet(NumGet(this+0)+12),"uint",this,"uint",pInitializeFunction)
}
IDirect3D9_GetAdapterCount(this) {
    return DllCall(NumGet(NumGet(this+0)+16),"uint",this)
}
IDirect3D9_GetAdapterIdentifier(this,Adapter,Flags,pIdentifier) {
    return DllCall(NumGet(NumGet(this+0)+20),"uint",this,"uint",Adapter,"uint",Flags,"uint",pIdentifier)
}
IDirect3D9_GetAdapterModeCount(this,Adapter,Format) {
    return DllCall(NumGet(NumGet(this+0)+24),"uint",this,"uint",Adapter,"uint",Format)
}
IDirect3D9_EnumAdapterModes(this,Adapter,Format,Mode,pMode) {
    return DllCall(NumGet(NumGet(this+0)+28),"uint",this,"uint",Adapter,"uint",Format,"uint",Mode,"uint",pMode)
}
IDirect3D9_GetAdapterDisplayMode(this,Adapter,pMode) {
    return DllCall(NumGet(NumGet(this+0)+32),"uint",this,"uint",Adapter,"uint",pMode)
}
IDirect3D9_CheckDeviceType(this,Adapter,DevType,AdapterFormat,BackBufferFormat,bWindowed) {
    return DllCall(NumGet(NumGet(this+0)+36),"uint",this,"uint",Adapter,"uint",DevType,"uint",AdapterFormat,"uint",BackBufferFormat,"int",bWindowed)
}
IDirect3D9_CheckDeviceFormat(this,Adapter,DeviceType,AdapterFormat,Usage,RType,CheckFormat) {
    return DllCall(NumGet(NumGet(this+0)+40),"uint",this,"uint",Adapter,"uint",DeviceType,"uint",AdapterFormat,"uint",Usage,"uint",RType,"uint",CheckFormat)
}
IDirect3D9_CheckDeviceMultiSampleType(this,Adapter,DeviceType,SurfaceFormat,Windowed,MultiSampleType,ByRef pQualityLevels) {
    return DllCall(NumGet(NumGet(this+0)+44),"uint",this,"uint",Adapter,"uint",DeviceType,"uint",SurfaceFormat,"int",Windowed,"uint",MultiSampleType,"uint*",pQualityLevels)
}
IDirect3D9_CheckDepthStencilMatch(this,Adapter,DeviceType,AdapterFormat,RenderTargetFormat,DepthStencilFormat) {
    return DllCall(NumGet(NumGet(this+0)+48),"uint",this,"uint",Adapter,"uint",DeviceType,"uint",AdapterFormat,"uint",RenderTargetFormat,"uint",DepthStencilFormat)
}
IDirect3D9_CheckDeviceFormatConversion(this,Adapter,DeviceType,SourceFormat,TargetFormat) {
    return DllCall(NumGet(NumGet(this+0)+52),"uint",this,"uint",Adapter,"uint",DeviceType,"uint",SourceFormat,"uint",TargetFormat)
}
IDirect3D9_GetDeviceCaps(this,Adapter,DeviceType,pCaps) {
    return DllCall(NumGet(NumGet(this+0)+56),"uint",this,"uint",Adapter,"uint",DeviceType,"uint",pCaps)
}
IDirect3D9_GetAdapterMonitor(this,Adapter) {
    return DllCall(NumGet(NumGet(this+0)+60),"uint",this,"uint",Adapter)
}
IDirect3D9_CreateDevice(this,Adapter,DeviceType,hFocusWindow,BehaviorFlags,pPresentationParameters,ByRef ppReturnedDeviceInterface) {
    return DllCall(NumGet(NumGet(this+0)+64),"uint",this,"uint",Adapter,"uint",DeviceType,"uint",hFocusWindow,"uint",BehaviorFlags,"uint",pPresentationParameters,"uint*",ppReturnedDeviceInterface)
}
;
; IDirect3DDevice9
;
IDirect3DDevice9_TestCooperativeLevel(this) {
    return DllCall(NumGet(NumGet(this+0)+12),"uint",this)
}
IDirect3DDevice9_GetAvailableTextureMem(this) {
    return DllCall(NumGet(NumGet(this+0)+16),"uint",this)
}
IDirect3DDevice9_EvictManagedResources(this) {
    return DllCall(NumGet(NumGet(this+0)+20),"uint",this)
}
IDirect3DDevice9_GetDirect3D(this,ByRef ppD3D9) {
    return DllCall(NumGet(NumGet(this+0)+24),"uint",this,"uint*",ppD3D9)
}
IDirect3DDevice9_GetDeviceCaps(this,pCaps) {
    return DllCall(NumGet(NumGet(this+0)+28),"uint",this,"uint",pCaps)
}
IDirect3DDevice9_GetDisplayMode(this,iSwapChain,pMode) {
    return DllCall(NumGet(NumGet(this+0)+32),"uint",this,"uint",iSwapChain,"uint",pMode)
}
IDirect3DDevice9_GetCreationParameters(this,pParameters) {
    return DllCall(NumGet(NumGet(this+0)+36),"uint",this,"uint",pParameters)
}
IDirect3DDevice9_SetCursorProperties(this,XHotSpot,YHotSpot,pCursorBitmap) {
    return DllCall(NumGet(NumGet(this+0)+40),"uint",this,"uint",XHotSpot,"uint",YHotSpot,"uint",pCursorBitmap)
}
IDirect3DDevice9_SetCursorPosition(this,X,Y,Flags) {
    DllCall(NumGet(NumGet(this+0)+44),"uint",this,"int",X,"int",Y,"uint",Flags)
}
IDirect3DDevice9_ShowCursor(this,bShow) {
    return DllCall(NumGet(NumGet(this+0)+48),"uint",this,"int",bShow)
}
IDirect3DDevice9_CreateAdditionalSwapChain(this,pPresentationParameters,ByRef pSwapChain) {
    return DllCall(NumGet(NumGet(this+0)+52),"uint",this,"uint",pPresentationParameters,"uint*",pSwapChain)
}
IDirect3DDevice9_GetSwapChain(this,iSwapChain,ByRef pSwapChain) {
    return DllCall(NumGet(NumGet(this+0)+56),"uint",this,"uint",iSwapChain,"uint*",pSwapChain)
}
IDirect3DDevice9_GetNumberOfSwapChains(this) {
    return DllCall(NumGet(NumGet(this+0)+60),"uint",this)
}
IDirect3DDevice9_Reset(this,pPresentationParameters) {
    return DllCall(NumGet(NumGet(this+0)+64),"uint",this,"uint",pPresentationParameters)
}
IDirect3DDevice9_Present(this,pSourceRect,pDestRect,hDestWindowOverride,pDirtyRegion) {
    return DllCall(NumGet(NumGet(this+0)+68),"uint",this,"uint",pSourceRect,"uint",pDestRect,"uint",hDestWindowOverride,"uint",pDirtyRegion)
}
IDirect3DDevice9_GetBackBuffer(this,iSwapChain,iBackBuffer,Type,ByRef ppBackBuffer) {
    return DllCall(NumGet(NumGet(this+0)+72),"uint",this,"uint",iSwapChain,"uint",iBackBuffer,"uint",Type,"uint*",ppBackBuffer)
}
IDirect3DDevice9_GetRasterStatus(this,iSwapChain,pRasterStatus) {
    return DllCall(NumGet(NumGet(this+0)+76),"uint",this,"uint",iSwapChain,"uint",pRasterStatus)
}
IDirect3DDevice9_SetDialogBoxMode(this,bEnableDialogs) {
    return DllCall(NumGet(NumGet(this+0)+80),"uint",this,"int",bEnableDialogs)
}
IDirect3DDevice9_SetGammaRamp(this,iSwapChain,Flags,pRamp) {
    DllCall(NumGet(NumGet(this+0)+84),"uint",this,"uint",iSwapChain,"uint",Flags,"uint",pRamp)
}
IDirect3DDevice9_GetGammaRamp(this,iSwapChain,pRamp) {
    DllCall(NumGet(NumGet(this+0)+88),"uint",this,"uint",iSwapChain,"uint",pRamp)
}
IDirect3DDevice9_CreateTexture(this,Width,Height,Levels,Usage,Format,Pool,ByRef ppTexture,pSharedHandle) {
    return DllCall(NumGet(NumGet(this+0)+92),"uint",this,"uint",Width,"uint",Height,"uint",Levels,"uint",Usage,"uint",Format,"uint",Pool,"uint*",ppTexture,"uint",pSharedHandle)
}
IDirect3DDevice9_CreateVolumeTexture(this,Width,Height,Depth,Levels,Usage,Format,Pool,ByRef ppVolumeTexture,pSharedHandle) {
    return DllCall(NumGet(NumGet(this+0)+96),"uint",this,"uint",Width,"uint",Height,"uint",Depth,"uint",Levels,"uint",Usage,"uint",Format,"uint",Pool,"uint*",ppVolumeTexture,"uint",pSharedHandle)
}
IDirect3DDevice9_CreateCubeTexture(this,EdgeLength,Levels,Usage,Format,Pool,ByRef ppCubeTexture,pSharedHandle) {
    return DllCall(NumGet(NumGet(this+0)+100),"uint",this,"uint",EdgeLength,"uint",Levels,"uint",Usage,"uint",Format,"uint",Pool,"uint*",ppCubeTexture,"uint",pSharedHandle)
}
IDirect3DDevice9_CreateVertexBuffer(this,Length,Usage,FVF,Pool,ByRef ppVertexBuffer,pSharedHandle) {
    return DllCall(NumGet(NumGet(this+0)+104),"uint",this,"uint",Length,"uint",Usage,"uint",FVF,"uint",Pool,"uint*",ppVertexBuffer,"uint",pSharedHandle)
}
IDirect3DDevice9_CreateIndexBuffer(this,Length,Usage,Format,Pool,ByRef ppIndexBuffer,pSharedHandle) {
    return DllCall(NumGet(NumGet(this+0)+108),"uint",this,"uint",Length,"uint",Usage,"uint",Format,"uint",Pool,"uint*",ppIndexBuffer,"uint",pSharedHandle)
}
IDirect3DDevice9_CreateRenderTarget(this,Width,Height,Format,MultiSample,MultisampleQuality,Lockable,ByRef ppSurface,pSharedHandle) {
    return DllCall(NumGet(NumGet(this+0)+112),"uint",this,"uint",Width,"uint",Height,"uint",Format,"uint",MultiSample,"uint",MultisampleQuality,"int",Lockable,"uint*",ppSurface,"uint",pSharedHandle)
}
IDirect3DDevice9_CreateDepthStencilSurface(this,Width,Height,Format,MultiSample,MultisampleQuality,Discard,ByRef ppSurface,pSharedHandle) {
    return DllCall(NumGet(NumGet(this+0)+116),"uint",this,"uint",Width,"uint",Height,"uint",Format,"uint",MultiSample,"uint",MultisampleQuality,"int",Discard,"uint*",ppSurface,"uint",pSharedHandle)
}
IDirect3DDevice9_UpdateSurface(this,pSourceSurface,pSourceRect,pDestinationSurface,pDestPoint) {
    return DllCall(NumGet(NumGet(this+0)+120),"uint",this,"uint",pSourceSurface,"uint",pSourceRect,"uint",pDestinationSurface,"uint",pDestPoint)
}
IDirect3DDevice9_UpdateTexture(this,pSourceTexture,pDestinationTexture) {
    return DllCall(NumGet(NumGet(this+0)+124),"uint",this,"uint",pSourceTexture,"uint",pDestinationTexture)
}
IDirect3DDevice9_GetRenderTargetData(this,pRenderTarget,pDestSurface) {
    return DllCall(NumGet(NumGet(this+0)+128),"uint",this,"uint",pRenderTarget,"uint",pDestSurface)
}
IDirect3DDevice9_GetFrontBufferData(this,iSwapChain,pDestSurface) {
    return DllCall(NumGet(NumGet(this+0)+132),"uint",this,"uint",iSwapChain,"uint",pDestSurface)
}
IDirect3DDevice9_StretchRect(this,pSourceSurface,pSourceRect,pDestSurface,pDestRect,Filter) {
    return DllCall(NumGet(NumGet(this+0)+136),"uint",this,"uint",pSourceSurface,"uint",pSourceRect,"uint",pDestSurface,"uint",pDestRect,"uint",Filter)
}
IDirect3DDevice9_ColorFill(this,pSurface,pRect,color) {
    return DllCall(NumGet(NumGet(this+0)+140),"uint",this,"uint",pSurface,"uint",pRect,"uint",color)
}
IDirect3DDevice9_CreateOffscreenPlainSurface(this,Width,Height,Format,Pool,ByRef ppSurface,pSharedHandle) {
    return DllCall(NumGet(NumGet(this+0)+144),"uint",this,"uint",Width,"uint",Height,"uint",Format,"uint",Pool,"uint*",ppSurface,"uint",pSharedHandle)
}
IDirect3DDevice9_SetRenderTarget(this,RenderTargetIndex,pRenderTarget) {
    return DllCall(NumGet(NumGet(this+0)+148),"uint",this,"uint",RenderTargetIndex,"uint",pRenderTarget)
}
IDirect3DDevice9_GetRenderTarget(this,RenderTargetIndex,ByRef ppRenderTarget) {
    return DllCall(NumGet(NumGet(this+0)+152),"uint",this,"uint",RenderTargetIndex,"uint*",ppRenderTarget)
}
IDirect3DDevice9_SetDepthStencilSurface(this,pNewZStencil) {
    return DllCall(NumGet(NumGet(this+0)+156),"uint",this,"uint",pNewZStencil)
}
IDirect3DDevice9_GetDepthStencilSurface(this,ByRef ppZStencilSurface) {
    return DllCall(NumGet(NumGet(this+0)+160),"uint",this,"uint*",ppZStencilSurface)
}
IDirect3DDevice9_BeginScene(this) {
    return DllCall(NumGet(NumGet(this+0)+164),"uint",this)
}
IDirect3DDevice9_EndScene(this) {
    return DllCall(NumGet(NumGet(this+0)+168),"uint",this)
}
IDirect3DDevice9_Clear(this,Count,pRects,Flags,Color,Z,Stencil) {
    return DllCall(NumGet(NumGet(this+0)+172),"uint",this,"uint",Count,"uint",pRects,"uint",Flags,"uint",Color,"float",Z,"uint",Stencil)
}
IDirect3DDevice9_SetTransform(this,State,pMatrix) {
    return DllCall(NumGet(NumGet(this+0)+176),"uint",this,"uint",State,"uint",pMatrix)
}
IDirect3DDevice9_GetTransform(this,State,pMatrix) {
    return DllCall(NumGet(NumGet(this+0)+180),"uint",this,"uint",State,"uint",pMatrix)
}
IDirect3DDevice9_MultiplyTransform(this,param2,param3) {
    return DllCall(NumGet(NumGet(this+0)+184),"uint",this,"uint",param2,"uint",param3)
}
IDirect3DDevice9_SetViewport(this,pViewport) {
    return DllCall(NumGet(NumGet(this+0)+188),"uint",this,"uint",pViewport)
}
IDirect3DDevice9_GetViewport(this,pViewport) {
    return DllCall(NumGet(NumGet(this+0)+192),"uint",this,"uint",pViewport)
}
IDirect3DDevice9_SetMaterial(this,pMaterial) {
    return DllCall(NumGet(NumGet(this+0)+196),"uint",this,"uint",pMaterial)
}
IDirect3DDevice9_GetMaterial(this,pMaterial) {
    return DllCall(NumGet(NumGet(this+0)+200),"uint",this,"uint",pMaterial)
}
IDirect3DDevice9_SetLight(this,Index,param3) {
    return DllCall(NumGet(NumGet(this+0)+204),"uint",this,"uint",Index,"uint",param3)
}
IDirect3DDevice9_GetLight(this,Index,param3) {
    return DllCall(NumGet(NumGet(this+0)+208),"uint",this,"uint",Index,"uint",param3)
}
IDirect3DDevice9_LightEnable(this,Index,Enable) {
    return DllCall(NumGet(NumGet(this+0)+212),"uint",this,"uint",Index,"int",Enable)
}
IDirect3DDevice9_GetLightEnable(this,Index,ByRef pEnable) {
    return DllCall(NumGet(NumGet(this+0)+216),"uint",this,"uint",Index,"int*",pEnable)
}
IDirect3DDevice9_SetClipPlane(this,Index,ByRef pPlane) {
    return DllCall(NumGet(NumGet(this+0)+220),"uint",this,"uint",Index,"float*",pPlane)
}
IDirect3DDevice9_GetClipPlane(this,Index,ByRef pPlane) {
    return DllCall(NumGet(NumGet(this+0)+224),"uint",this,"uint",Index,"float*",pPlane)
}
IDirect3DDevice9_SetRenderState(this,State,Value) {
    return DllCall(NumGet(NumGet(this+0)+228),"uint",this,"uint",State,"uint",Value)
}
IDirect3DDevice9_GetRenderState(this,State,ByRef pValue) {
    return DllCall(NumGet(NumGet(this+0)+232),"uint",this,"uint",State,"uint*",pValue)
}
IDirect3DDevice9_CreateStateBlock(this,Type,ByRef ppSB) {
    return DllCall(NumGet(NumGet(this+0)+236),"uint",this,"uint",Type,"uint*",ppSB)
}
IDirect3DDevice9_BeginStateBlock(this) {
    return DllCall(NumGet(NumGet(this+0)+240),"uint",this)
}
IDirect3DDevice9_EndStateBlock(this,ByRef ppSB) {
    return DllCall(NumGet(NumGet(this+0)+244),"uint",this,"uint*",ppSB)
}
IDirect3DDevice9_SetClipStatus(this,pClipStatus) {
    return DllCall(NumGet(NumGet(this+0)+248),"uint",this,"uint",pClipStatus)
}
IDirect3DDevice9_GetClipStatus(this,pClipStatus) {
    return DllCall(NumGet(NumGet(this+0)+252),"uint",this,"uint",pClipStatus)
}
IDirect3DDevice9_GetTexture(this,Stage,ByRef ppTexture) {
    return DllCall(NumGet(NumGet(this+0)+256),"uint",this,"uint",Stage,"uint*",ppTexture)
}
IDirect3DDevice9_SetTexture(this,Stage,pTexture) {
    return DllCall(NumGet(NumGet(this+0)+260),"uint",this,"uint",Stage,"uint",pTexture)
}
IDirect3DDevice9_GetTextureStageState(this,Stage,Type,ByRef pValue) {
    return DllCall(NumGet(NumGet(this+0)+264),"uint",this,"uint",Stage,"uint",Type,"uint*",pValue)
}
IDirect3DDevice9_SetTextureStageState(this,Stage,Type,Value) {
    return DllCall(NumGet(NumGet(this+0)+268),"uint",this,"uint",Stage,"uint",Type,"uint",Value)
}
IDirect3DDevice9_GetSamplerState(this,Sampler,Type,ByRef pValue) {
    return DllCall(NumGet(NumGet(this+0)+272),"uint",this,"uint",Sampler,"uint",Type,"uint*",pValue)
}
IDirect3DDevice9_SetSamplerState(this,Sampler,Type,Value) {
    return DllCall(NumGet(NumGet(this+0)+276),"uint",this,"uint",Sampler,"uint",Type,"uint",Value)
}
IDirect3DDevice9_ValidateDevice(this,ByRef pNumPasses) {
    return DllCall(NumGet(NumGet(this+0)+280),"uint",this,"uint*",pNumPasses)
}
IDirect3DDevice9_SetPaletteEntries(this,PaletteNumber,pEntries) {
    return DllCall(NumGet(NumGet(this+0)+284),"uint",this,"uint",PaletteNumber,"uint",pEntries)
}
IDirect3DDevice9_GetPaletteEntries(this,PaletteNumber,pEntries) {
    return DllCall(NumGet(NumGet(this+0)+288),"uint",this,"uint",PaletteNumber,"uint",pEntries)
}
IDirect3DDevice9_SetCurrentTexturePalette(this,PaletteNumber) {
    return DllCall(NumGet(NumGet(this+0)+292),"uint",this,"uint",PaletteNumber)
}
IDirect3DDevice9_GetCurrentTexturePalette(this,ByRef PaletteNumber) {
    return DllCall(NumGet(NumGet(this+0)+296),"uint",this,"uint*",PaletteNumber)
}
IDirect3DDevice9_SetScissorRect(this,pRect) {
    return DllCall(NumGet(NumGet(this+0)+300),"uint",this,"uint",pRect)
}
IDirect3DDevice9_GetScissorRect(this,pRect) {
    return DllCall(NumGet(NumGet(this+0)+304),"uint",this,"uint",pRect)
}
IDirect3DDevice9_SetSoftwareVertexProcessing(this,bSoftware) {
    return DllCall(NumGet(NumGet(this+0)+308),"uint",this,"int",bSoftware)
}
IDirect3DDevice9_GetSoftwareVertexProcessing(this) {
    return DllCall(NumGet(NumGet(this+0)+312),"uint",this)
}
IDirect3DDevice9_SetNPatchMode(this,nSegments) {
    return DllCall(NumGet(NumGet(this+0)+316),"uint",this,"float",nSegments)
}
IDirect3DDevice9_GetNPatchMode(this) {
    return DllCall(NumGet(NumGet(this+0)+320),"uint",this)
}
IDirect3DDevice9_DrawPrimitive(this,PrimitiveType,StartVertex,PrimitiveCount) {
    return DllCall(NumGet(NumGet(this+0)+324),"uint",this,"uint",PrimitiveType,"uint",StartVertex,"uint",PrimitiveCount)
}
IDirect3DDevice9_DrawIndexedPrimitive(this,param2,BaseVertexIndex,MinVertexIndex,NumVertices,startIndex,primCount) {
    return DllCall(NumGet(NumGet(this+0)+328),"uint",this,"uint",param2,"int",BaseVertexIndex,"uint",MinVertexIndex,"uint",NumVertices,"uint",startIndex,"uint",primCount)
}
IDirect3DDevice9_DrawPrimitiveUP(this,PrimitiveType,PrimitiveCount,pVertexStreamZeroData,VertexStreamZeroStride) {
    return DllCall(NumGet(NumGet(this+0)+332),"uint",this,"uint",PrimitiveType,"uint",PrimitiveCount,"uint",pVertexStreamZeroData,"uint",VertexStreamZeroStride)
}
IDirect3DDevice9_DrawIndexedPrimitiveUP(this,PrimitiveType,MinVertexIndex,NumVertices,PrimitiveCount,pIndexData,IndexDataFormat,pVertexStreamZeroData,VertexStreamZeroStride) {
    return DllCall(NumGet(NumGet(this+0)+336),"uint",this,"uint",PrimitiveType,"uint",MinVertexIndex,"uint",NumVertices,"uint",PrimitiveCount,"uint",pIndexData,"uint",IndexDataFormat,"uint",pVertexStreamZeroData,"uint",VertexStreamZeroStride)
}
IDirect3DDevice9_ProcessVertices(this,SrcStartIndex,DestIndex,VertexCount,pDestBuffer,pVertexDecl,Flags) {
    return DllCall(NumGet(NumGet(this+0)+340),"uint",this,"uint",SrcStartIndex,"uint",DestIndex,"uint",VertexCount,"uint",pDestBuffer,"uint",pVertexDecl,"uint",Flags)
}
IDirect3DDevice9_CreateVertexDeclaration(this,pVertexElements,ByRef ppDecl) {
    return DllCall(NumGet(NumGet(this+0)+344),"uint",this,"uint",pVertexElements,"uint*",ppDecl)
}
IDirect3DDevice9_SetVertexDeclaration(this,pDecl) {
    return DllCall(NumGet(NumGet(this+0)+348),"uint",this,"uint",pDecl)
}
IDirect3DDevice9_GetVertexDeclaration(this,ByRef ppDecl) {
    return DllCall(NumGet(NumGet(this+0)+352),"uint",this,"uint*",ppDecl)
}
IDirect3DDevice9_SetFVF(this,FVF) {
    return DllCall(NumGet(NumGet(this+0)+356),"uint",this,"uint",FVF)
}
IDirect3DDevice9_GetFVF(this,ByRef pFVF) {
    return DllCall(NumGet(NumGet(this+0)+360),"uint",this,"uint*",pFVF)
}
IDirect3DDevice9_CreateVertexShader(this,ByRef pFunction,ByRef ppShader) {
    return DllCall(NumGet(NumGet(this+0)+364),"uint",this,"uint*",pFunction,"uint*",ppShader)
}
IDirect3DDevice9_SetVertexShader(this,pShader) {
    return DllCall(NumGet(NumGet(this+0)+368),"uint",this,"uint",pShader)
}
IDirect3DDevice9_GetVertexShader(this,ByRef ppShader) {
    return DllCall(NumGet(NumGet(this+0)+372),"uint",this,"uint*",ppShader)
}
IDirect3DDevice9_SetVertexShaderConstantF(this,StartRegister,ByRef pConstantData,Vector4fCount) {
    return DllCall(NumGet(NumGet(this+0)+376),"uint",this,"uint",StartRegister,"float*",pConstantData,"uint",Vector4fCount)
}
IDirect3DDevice9_GetVertexShaderConstantF(this,StartRegister,ByRef pConstantData,Vector4fCount) {
    return DllCall(NumGet(NumGet(this+0)+380),"uint",this,"uint",StartRegister,"float*",pConstantData,"uint",Vector4fCount)
}
IDirect3DDevice9_SetVertexShaderConstantI(this,StartRegister,ByRef pConstantData,Vector4iCount) {
    return DllCall(NumGet(NumGet(this+0)+384),"uint",this,"uint",StartRegister,"int*",pConstantData,"uint",Vector4iCount)
}
IDirect3DDevice9_GetVertexShaderConstantI(this,StartRegister,ByRef pConstantData,Vector4iCount) {
    return DllCall(NumGet(NumGet(this+0)+388),"uint",this,"uint",StartRegister,"int*",pConstantData,"uint",Vector4iCount)
}
IDirect3DDevice9_SetVertexShaderConstantB(this,StartRegister,ByRef pConstantData,BoolCount) {
    return DllCall(NumGet(NumGet(this+0)+392),"uint",this,"uint",StartRegister,"int*",pConstantData,"uint",BoolCount)
}
IDirect3DDevice9_GetVertexShaderConstantB(this,StartRegister,ByRef pConstantData,BoolCount) {
    return DllCall(NumGet(NumGet(this+0)+396),"uint",this,"uint",StartRegister,"int*",pConstantData,"uint",BoolCount)
}
IDirect3DDevice9_SetStreamSource(this,StreamNumber,pStreamData,OffsetInBytes,Stride) {
    return DllCall(NumGet(NumGet(this+0)+400),"uint",this,"uint",StreamNumber,"uint",pStreamData,"uint",OffsetInBytes,"uint",Stride)
}
IDirect3DDevice9_GetStreamSource(this,StreamNumber,ByRef ppStreamData,ByRef pOffsetInBytes,ByRef pStride) {
    return DllCall(NumGet(NumGet(this+0)+404),"uint",this,"uint",StreamNumber,"uint*",ppStreamData,"uint*",pOffsetInBytes,"uint*",pStride)
}
IDirect3DDevice9_SetStreamSourceFreq(this,StreamNumber,Setting) {
    return DllCall(NumGet(NumGet(this+0)+408),"uint",this,"uint",StreamNumber,"uint",Setting)
}
IDirect3DDevice9_GetStreamSourceFreq(this,StreamNumber,ByRef pSetting) {
    return DllCall(NumGet(NumGet(this+0)+412),"uint",this,"uint",StreamNumber,"uint*",pSetting)
}
IDirect3DDevice9_SetIndices(this,pIndexData) {
    return DllCall(NumGet(NumGet(this+0)+416),"uint",this,"uint",pIndexData)
}
IDirect3DDevice9_GetIndices(this,ByRef ppIndexData) {
    return DllCall(NumGet(NumGet(this+0)+420),"uint",this,"uint*",ppIndexData)
}
IDirect3DDevice9_CreatePixelShader(this,ByRef pFunction,ByRef ppShader) {
    return DllCall(NumGet(NumGet(this+0)+424),"uint",this,"uint*",pFunction,"uint*",ppShader)
}
IDirect3DDevice9_SetPixelShader(this,pShader) {
    return DllCall(NumGet(NumGet(this+0)+428),"uint",this,"uint",pShader)
}
IDirect3DDevice9_GetPixelShader(this,ByRef ppShader) {
    return DllCall(NumGet(NumGet(this+0)+432),"uint",this,"uint*",ppShader)
}
IDirect3DDevice9_SetPixelShaderConstantF(this,StartRegister,ByRef pConstantData,Vector4fCount) {
    return DllCall(NumGet(NumGet(this+0)+436),"uint",this,"uint",StartRegister,"float*",pConstantData,"uint",Vector4fCount)
}
IDirect3DDevice9_GetPixelShaderConstantF(this,StartRegister,ByRef pConstantData,Vector4fCount) {
    return DllCall(NumGet(NumGet(this+0)+440),"uint",this,"uint",StartRegister,"float*",pConstantData,"uint",Vector4fCount)
}
IDirect3DDevice9_SetPixelShaderConstantI(this,StartRegister,ByRef pConstantData,Vector4iCount) {
    return DllCall(NumGet(NumGet(this+0)+444),"uint",this,"uint",StartRegister,"int*",pConstantData,"uint",Vector4iCount)
}
IDirect3DDevice9_GetPixelShaderConstantI(this,StartRegister,ByRef pConstantData,Vector4iCount) {
    return DllCall(NumGet(NumGet(this+0)+448),"uint",this,"uint",StartRegister,"int*",pConstantData,"uint",Vector4iCount)
}
IDirect3DDevice9_SetPixelShaderConstantB(this,StartRegister,ByRef pConstantData,BoolCount) {
    return DllCall(NumGet(NumGet(this+0)+452),"uint",this,"uint",StartRegister,"int*",pConstantData,"uint",BoolCount)
}
IDirect3DDevice9_GetPixelShaderConstantB(this,StartRegister,ByRef pConstantData,BoolCount) {
    return DllCall(NumGet(NumGet(this+0)+456),"uint",this,"uint",StartRegister,"int*",pConstantData,"uint",BoolCount)
}
IDirect3DDevice9_DrawRectPatch(this,Handle,ByRef pNumSegs,pRectPatchInfo) {
    return DllCall(NumGet(NumGet(this+0)+460),"uint",this,"uint",Handle,"float*",pNumSegs,"uint",pRectPatchInfo)
}
IDirect3DDevice9_DrawTriPatch(this,Handle,ByRef pNumSegs,pTriPatchInfo) {
    return DllCall(NumGet(NumGet(this+0)+464),"uint",this,"uint",Handle,"float*",pNumSegs,"uint",pTriPatchInfo)
}
IDirect3DDevice9_DeletePatch(this,Handle) {
    return DllCall(NumGet(NumGet(this+0)+468),"uint",this,"uint",Handle)
}
IDirect3DDevice9_CreateQuery(this,Type,ByRef ppQuery) {
    return DllCall(NumGet(NumGet(this+0)+472),"uint",this,"uint",Type,"uint*",ppQuery)
}
;
; IDirect3DStateBlock9
;
IDirect3DStateBlock9_GetDevice(this,ByRef ppDevice) {
    return DllCall(NumGet(NumGet(this+0)+12),"uint",this,"uint*",ppDevice)
}
IDirect3DStateBlock9_Capture(this) {
    return DllCall(NumGet(NumGet(this+0)+16),"uint",this)
}
IDirect3DStateBlock9_Apply(this) {
    return DllCall(NumGet(NumGet(this+0)+20),"uint",this)
}
;
; IDirect3DSwapChain9
;
IDirect3DSwapChain9_Present(this,pSourceRect,pDestRect,hDestWindowOverride,pDirtyRegion,dwFlags) {
    return DllCall(NumGet(NumGet(this+0)+12),"uint",this,"uint",pSourceRect,"uint",pDestRect,"uint",hDestWindowOverride,"uint",pDirtyRegion,"uint",dwFlags)
}
IDirect3DSwapChain9_GetFrontBufferData(this,pDestSurface) {
    return DllCall(NumGet(NumGet(this+0)+16),"uint",this,"uint",pDestSurface)
}
IDirect3DSwapChain9_GetBackBuffer(this,iBackBuffer,Type,ByRef ppBackBuffer) {
    return DllCall(NumGet(NumGet(this+0)+20),"uint",this,"uint",iBackBuffer,"uint",Type,"uint*",ppBackBuffer)
}
IDirect3DSwapChain9_GetRasterStatus(this,pRasterStatus) {
    return DllCall(NumGet(NumGet(this+0)+24),"uint",this,"uint",pRasterStatus)
}
IDirect3DSwapChain9_GetDisplayMode(this,pMode) {
    return DllCall(NumGet(NumGet(this+0)+28),"uint",this,"uint",pMode)
}
IDirect3DSwapChain9_GetDevice(this,ByRef ppDevice) {
    return DllCall(NumGet(NumGet(this+0)+32),"uint",this,"uint*",ppDevice)
}
IDirect3DSwapChain9_GetPresentParameters(this,pPresentationParameters) {
    return DllCall(NumGet(NumGet(this+0)+36),"uint",this,"uint",pPresentationParameters)
}
;
; IDirect3DResource9
;
IDirect3DResource9_GetDevice(this,ByRef ppDevice) {
    return DllCall(NumGet(NumGet(this+0)+12),"uint",this,"uint*",ppDevice)
}
IDirect3DResource9_SetPrivateData(this,refguid,pData,SizeOfData,Flags) {
    return DllCall(NumGet(NumGet(this+0)+16),"uint",this,"uint",refguid,"uint",pData,"uint",SizeOfData,"uint",Flags)
}
IDirect3DResource9_GetPrivateData(this,refguid,pData,ByRef pSizeOfData) {
    return DllCall(NumGet(NumGet(this+0)+20),"uint",this,"uint",refguid,"uint",pData,"uint*",pSizeOfData)
}
IDirect3DResource9_FreePrivateData(this,refguid) {
    return DllCall(NumGet(NumGet(this+0)+24),"uint",this,"uint",refguid)
}
IDirect3DResource9_SetPriority(this,PriorityNew) {
    return DllCall(NumGet(NumGet(this+0)+28),"uint",this,"uint",PriorityNew)
}
IDirect3DResource9_GetPriority(this) {
    return DllCall(NumGet(NumGet(this+0)+32),"uint",this)
}
IDirect3DResource9_PreLoad(this) {
    DllCall(NumGet(NumGet(this+0)+36),"uint",this)
}
IDirect3DResource9_GetType(this) {
    return DllCall(NumGet(NumGet(this+0)+40),"uint",this)
}
;
; IDirect3DVertexDeclaration9
;
IDirect3DVertexDeclaration9_GetDevice(this,ByRef ppDevice) {
    return DllCall(NumGet(NumGet(this+0)+12),"uint",this,"uint*",ppDevice)
}
IDirect3DVertexDeclaration9_GetDeclaration(this,pElement,ByRef pNumElements) {
    return DllCall(NumGet(NumGet(this+0)+16),"uint",this,"uint",pElement,"uint*",pNumElements)
}
;
; IDirect3DVertexShader9
;
IDirect3DVertexShader9_GetDevice(this,ByRef ppDevice) {
    return DllCall(NumGet(NumGet(this+0)+12),"uint",this,"uint*",ppDevice)
}
IDirect3DVertexShader9_GetFunction(this,param2,ByRef pSizeOfData) {
    return DllCall(NumGet(NumGet(this+0)+16),"uint",this,"uint",param2,"uint*",pSizeOfData)
}
;
; IDirect3DPixelShader9
;
IDirect3DPixelShader9_GetDevice(this,ByRef ppDevice) {
    return DllCall(NumGet(NumGet(this+0)+12),"uint",this,"uint*",ppDevice)
}
IDirect3DPixelShader9_GetFunction(this,param2,ByRef pSizeOfData) {
    return DllCall(NumGet(NumGet(this+0)+16),"uint",this,"uint",param2,"uint*",pSizeOfData)
}
;
; IDirect3DBaseTexture9
;
IDirect3DBaseTexture9_GetDevice(this,ByRef ppDevice) {
    return DllCall(NumGet(NumGet(this+0)+12),"uint",this,"uint*",ppDevice)
}
IDirect3DBaseTexture9_SetPrivateData(this,refguid,pData,SizeOfData,Flags) {
    return DllCall(NumGet(NumGet(this+0)+16),"uint",this,"uint",refguid,"uint",pData,"uint",SizeOfData,"uint",Flags)
}
IDirect3DBaseTexture9_GetPrivateData(this,refguid,pData,ByRef pSizeOfData) {
    return DllCall(NumGet(NumGet(this+0)+20),"uint",this,"uint",refguid,"uint",pData,"uint*",pSizeOfData)
}
IDirect3DBaseTexture9_FreePrivateData(this,refguid) {
    return DllCall(NumGet(NumGet(this+0)+24),"uint",this,"uint",refguid)
}
IDirect3DBaseTexture9_SetPriority(this,PriorityNew) {
    return DllCall(NumGet(NumGet(this+0)+28),"uint",this,"uint",PriorityNew)
}
IDirect3DBaseTexture9_GetPriority(this) {
    return DllCall(NumGet(NumGet(this+0)+32),"uint",this)
}
IDirect3DBaseTexture9_PreLoad(this) {
    DllCall(NumGet(NumGet(this+0)+36),"uint",this)
}
IDirect3DBaseTexture9_GetType(this) {
    return DllCall(NumGet(NumGet(this+0)+40),"uint",this)
}
IDirect3DBaseTexture9_SetLOD(this,LODNew) {
    return DllCall(NumGet(NumGet(this+0)+44),"uint",this,"uint",LODNew)
}
IDirect3DBaseTexture9_GetLOD(this) {
    return DllCall(NumGet(NumGet(this+0)+48),"uint",this)
}
IDirect3DBaseTexture9_GetLevelCount(this) {
    return DllCall(NumGet(NumGet(this+0)+52),"uint",this)
}
IDirect3DBaseTexture9_SetAutoGenFilterType(this,FilterType) {
    return DllCall(NumGet(NumGet(this+0)+56),"uint",this,"uint",FilterType)
}
IDirect3DBaseTexture9_GetAutoGenFilterType(this) {
    return DllCall(NumGet(NumGet(this+0)+60),"uint",this)
}
IDirect3DBaseTexture9_GenerateMipSubLevels(this) {
    DllCall(NumGet(NumGet(this+0)+64),"uint",this)
}
;
; IDirect3DTexture9
;
IDirect3DTexture9_GetDevice(this,ByRef ppDevice) {
    return DllCall(NumGet(NumGet(this+0)+12),"uint",this,"uint*",ppDevice)
}
IDirect3DTexture9_SetPrivateData(this,refguid,pData,SizeOfData,Flags) {
    return DllCall(NumGet(NumGet(this+0)+16),"uint",this,"uint",refguid,"uint",pData,"uint",SizeOfData,"uint",Flags)
}
IDirect3DTexture9_GetPrivateData(this,refguid,pData,ByRef pSizeOfData) {
    return DllCall(NumGet(NumGet(this+0)+20),"uint",this,"uint",refguid,"uint",pData,"uint*",pSizeOfData)
}
IDirect3DTexture9_FreePrivateData(this,refguid) {
    return DllCall(NumGet(NumGet(this+0)+24),"uint",this,"uint",refguid)
}
IDirect3DTexture9_SetPriority(this,PriorityNew) {
    return DllCall(NumGet(NumGet(this+0)+28),"uint",this,"uint",PriorityNew)
}
IDirect3DTexture9_GetPriority(this) {
    return DllCall(NumGet(NumGet(this+0)+32),"uint",this)
}
IDirect3DTexture9_PreLoad(this) {
    DllCall(NumGet(NumGet(this+0)+36),"uint",this)
}
IDirect3DTexture9_GetType(this) {
    return DllCall(NumGet(NumGet(this+0)+40),"uint",this)
}
IDirect3DTexture9_SetLOD(this,LODNew) {
    return DllCall(NumGet(NumGet(this+0)+44),"uint",this,"uint",LODNew)
}
IDirect3DTexture9_GetLOD(this) {
    return DllCall(NumGet(NumGet(this+0)+48),"uint",this)
}
IDirect3DTexture9_GetLevelCount(this) {
    return DllCall(NumGet(NumGet(this+0)+52),"uint",this)
}
IDirect3DTexture9_SetAutoGenFilterType(this,FilterType) {
    return DllCall(NumGet(NumGet(this+0)+56),"uint",this,"uint",FilterType)
}
IDirect3DTexture9_GetAutoGenFilterType(this) {
    return DllCall(NumGet(NumGet(this+0)+60),"uint",this)
}
IDirect3DTexture9_GenerateMipSubLevels(this) {
    DllCall(NumGet(NumGet(this+0)+64),"uint",this)
}
IDirect3DTexture9_GetLevelDesc(this,Level,pDesc) {
    return DllCall(NumGet(NumGet(this+0)+68),"uint",this,"uint",Level,"uint",pDesc)
}
IDirect3DTexture9_GetSurfaceLevel(this,Level,ByRef ppSurfaceLevel) {
    return DllCall(NumGet(NumGet(this+0)+72),"uint",this,"uint",Level,"uint*",ppSurfaceLevel)
}
IDirect3DTexture9_LockRect(this,Level,pLockedRect,pRect,Flags) {
    return DllCall(NumGet(NumGet(this+0)+76),"uint",this,"uint",Level,"uint",pLockedRect,"uint",pRect,"uint",Flags)
}
IDirect3DTexture9_UnlockRect(this,Level) {
    return DllCall(NumGet(NumGet(this+0)+80),"uint",this,"uint",Level)
}
IDirect3DTexture9_AddDirtyRect(this,pDirtyRect) {
    return DllCall(NumGet(NumGet(this+0)+84),"uint",this,"uint",pDirtyRect)
}
;
; IDirect3DVolumeTexture9
;
IDirect3DVolumeTexture9_GetDevice(this,ByRef ppDevice) {
    return DllCall(NumGet(NumGet(this+0)+12),"uint",this,"uint*",ppDevice)
}
IDirect3DVolumeTexture9_SetPrivateData(this,refguid,pData,SizeOfData,Flags) {
    return DllCall(NumGet(NumGet(this+0)+16),"uint",this,"uint",refguid,"uint",pData,"uint",SizeOfData,"uint",Flags)
}
IDirect3DVolumeTexture9_GetPrivateData(this,refguid,pData,ByRef pSizeOfData) {
    return DllCall(NumGet(NumGet(this+0)+20),"uint",this,"uint",refguid,"uint",pData,"uint*",pSizeOfData)
}
IDirect3DVolumeTexture9_FreePrivateData(this,refguid) {
    return DllCall(NumGet(NumGet(this+0)+24),"uint",this,"uint",refguid)
}
IDirect3DVolumeTexture9_SetPriority(this,PriorityNew) {
    return DllCall(NumGet(NumGet(this+0)+28),"uint",this,"uint",PriorityNew)
}
IDirect3DVolumeTexture9_GetPriority(this) {
    return DllCall(NumGet(NumGet(this+0)+32),"uint",this)
}
IDirect3DVolumeTexture9_PreLoad(this) {
    DllCall(NumGet(NumGet(this+0)+36),"uint",this)
}
IDirect3DVolumeTexture9_GetType(this) {
    return DllCall(NumGet(NumGet(this+0)+40),"uint",this)
}
IDirect3DVolumeTexture9_SetLOD(this,LODNew) {
    return DllCall(NumGet(NumGet(this+0)+44),"uint",this,"uint",LODNew)
}
IDirect3DVolumeTexture9_GetLOD(this) {
    return DllCall(NumGet(NumGet(this+0)+48),"uint",this)
}
IDirect3DVolumeTexture9_GetLevelCount(this) {
    return DllCall(NumGet(NumGet(this+0)+52),"uint",this)
}
IDirect3DVolumeTexture9_SetAutoGenFilterType(this,FilterType) {
    return DllCall(NumGet(NumGet(this+0)+56),"uint",this,"uint",FilterType)
}
IDirect3DVolumeTexture9_GetAutoGenFilterType(this) {
    return DllCall(NumGet(NumGet(this+0)+60),"uint",this)
}
IDirect3DVolumeTexture9_GenerateMipSubLevels(this) {
    DllCall(NumGet(NumGet(this+0)+64),"uint",this)
}
IDirect3DVolumeTexture9_GetLevelDesc(this,Level,pDesc) {
    return DllCall(NumGet(NumGet(this+0)+68),"uint",this,"uint",Level,"uint",pDesc)
}
IDirect3DVolumeTexture9_GetVolumeLevel(this,Level,ByRef ppVolumeLevel) {
    return DllCall(NumGet(NumGet(this+0)+72),"uint",this,"uint",Level,"uint*",ppVolumeLevel)
}
IDirect3DVolumeTexture9_LockBox(this,Level,pLockedVolume,pBox,Flags) {
    return DllCall(NumGet(NumGet(this+0)+76),"uint",this,"uint",Level,"uint",pLockedVolume,"uint",pBox,"uint",Flags)
}
IDirect3DVolumeTexture9_UnlockBox(this,Level) {
    return DllCall(NumGet(NumGet(this+0)+80),"uint",this,"uint",Level)
}
IDirect3DVolumeTexture9_AddDirtyBox(this,pDirtyBox) {
    return DllCall(NumGet(NumGet(this+0)+84),"uint",this,"uint",pDirtyBox)
}
;
; IDirect3DCubeTexture9
;
IDirect3DCubeTexture9_GetDevice(this,ByRef ppDevice) {
    return DllCall(NumGet(NumGet(this+0)+12),"uint",this,"uint*",ppDevice)
}
IDirect3DCubeTexture9_SetPrivateData(this,refguid,pData,SizeOfData,Flags) {
    return DllCall(NumGet(NumGet(this+0)+16),"uint",this,"uint",refguid,"uint",pData,"uint",SizeOfData,"uint",Flags)
}
IDirect3DCubeTexture9_GetPrivateData(this,refguid,pData,ByRef pSizeOfData) {
    return DllCall(NumGet(NumGet(this+0)+20),"uint",this,"uint",refguid,"uint",pData,"uint*",pSizeOfData)
}
IDirect3DCubeTexture9_FreePrivateData(this,refguid) {
    return DllCall(NumGet(NumGet(this+0)+24),"uint",this,"uint",refguid)
}
IDirect3DCubeTexture9_SetPriority(this,PriorityNew) {
    return DllCall(NumGet(NumGet(this+0)+28),"uint",this,"uint",PriorityNew)
}
IDirect3DCubeTexture9_GetPriority(this) {
    return DllCall(NumGet(NumGet(this+0)+32),"uint",this)
}
IDirect3DCubeTexture9_PreLoad(this) {
    DllCall(NumGet(NumGet(this+0)+36),"uint",this)
}
IDirect3DCubeTexture9_GetType(this) {
    return DllCall(NumGet(NumGet(this+0)+40),"uint",this)
}
IDirect3DCubeTexture9_SetLOD(this,LODNew) {
    return DllCall(NumGet(NumGet(this+0)+44),"uint",this,"uint",LODNew)
}
IDirect3DCubeTexture9_GetLOD(this) {
    return DllCall(NumGet(NumGet(this+0)+48),"uint",this)
}
IDirect3DCubeTexture9_GetLevelCount(this) {
    return DllCall(NumGet(NumGet(this+0)+52),"uint",this)
}
IDirect3DCubeTexture9_SetAutoGenFilterType(this,FilterType) {
    return DllCall(NumGet(NumGet(this+0)+56),"uint",this,"uint",FilterType)
}
IDirect3DCubeTexture9_GetAutoGenFilterType(this) {
    return DllCall(NumGet(NumGet(this+0)+60),"uint",this)
}
IDirect3DCubeTexture9_GenerateMipSubLevels(this) {
    DllCall(NumGet(NumGet(this+0)+64),"uint",this)
}
IDirect3DCubeTexture9_GetLevelDesc(this,Level,pDesc) {
    return DllCall(NumGet(NumGet(this+0)+68),"uint",this,"uint",Level,"uint",pDesc)
}
IDirect3DCubeTexture9_GetCubeMapSurface(this,FaceType,Level,ByRef ppCubeMapSurface) {
    return DllCall(NumGet(NumGet(this+0)+72),"uint",this,"uint",FaceType,"uint",Level,"uint*",ppCubeMapSurface)
}
IDirect3DCubeTexture9_LockRect(this,FaceType,Level,pLockedRect,pRect,Flags) {
    return DllCall(NumGet(NumGet(this+0)+76),"uint",this,"uint",FaceType,"uint",Level,"uint",pLockedRect,"uint",pRect,"uint",Flags)
}
IDirect3DCubeTexture9_UnlockRect(this,FaceType,Level) {
    return DllCall(NumGet(NumGet(this+0)+80),"uint",this,"uint",FaceType,"uint",Level)
}
IDirect3DCubeTexture9_AddDirtyRect(this,FaceType,pDirtyRect) {
    return DllCall(NumGet(NumGet(this+0)+84),"uint",this,"uint",FaceType,"uint",pDirtyRect)
}
;
; IDirect3DVertexBuffer9
;
IDirect3DVertexBuffer9_GetDevice(this,ByRef ppDevice) {
    return DllCall(NumGet(NumGet(this+0)+12),"uint",this,"uint*",ppDevice)
}
IDirect3DVertexBuffer9_SetPrivateData(this,refguid,pData,SizeOfData,Flags) {
    return DllCall(NumGet(NumGet(this+0)+16),"uint",this,"uint",refguid,"uint",pData,"uint",SizeOfData,"uint",Flags)
}
IDirect3DVertexBuffer9_GetPrivateData(this,refguid,pData,ByRef pSizeOfData) {
    return DllCall(NumGet(NumGet(this+0)+20),"uint",this,"uint",refguid,"uint",pData,"uint*",pSizeOfData)
}
IDirect3DVertexBuffer9_FreePrivateData(this,refguid) {
    return DllCall(NumGet(NumGet(this+0)+24),"uint",this,"uint",refguid)
}
IDirect3DVertexBuffer9_SetPriority(this,PriorityNew) {
    return DllCall(NumGet(NumGet(this+0)+28),"uint",this,"uint",PriorityNew)
}
IDirect3DVertexBuffer9_GetPriority(this) {
    return DllCall(NumGet(NumGet(this+0)+32),"uint",this)
}
IDirect3DVertexBuffer9_PreLoad(this) {
    DllCall(NumGet(NumGet(this+0)+36),"uint",this)
}
IDirect3DVertexBuffer9_GetType(this) {
    return DllCall(NumGet(NumGet(this+0)+40),"uint",this)
}
IDirect3DVertexBuffer9_Lock(this,OffsetToLock,SizeToLock,ByRef ppbData,Flags) {
    return DllCall(NumGet(NumGet(this+0)+44),"uint",this,"uint",OffsetToLock,"uint",SizeToLock,"uint*",ppbData,"uint",Flags)
}
IDirect3DVertexBuffer9_Unlock(this) {
    return DllCall(NumGet(NumGet(this+0)+48),"uint",this)
}
IDirect3DVertexBuffer9_GetDesc(this,pDesc) {
    return DllCall(NumGet(NumGet(this+0)+52),"uint",this,"uint",pDesc)
}
;
; IDirect3DIndexBuffer9
;
IDirect3DIndexBuffer9_GetDevice(this,ByRef ppDevice) {
    return DllCall(NumGet(NumGet(this+0)+12),"uint",this,"uint*",ppDevice)
}
IDirect3DIndexBuffer9_SetPrivateData(this,refguid,pData,SizeOfData,Flags) {
    return DllCall(NumGet(NumGet(this+0)+16),"uint",this,"uint",refguid,"uint",pData,"uint",SizeOfData,"uint",Flags)
}
IDirect3DIndexBuffer9_GetPrivateData(this,refguid,pData,ByRef pSizeOfData) {
    return DllCall(NumGet(NumGet(this+0)+20),"uint",this,"uint",refguid,"uint",pData,"uint*",pSizeOfData)
}
IDirect3DIndexBuffer9_FreePrivateData(this,refguid) {
    return DllCall(NumGet(NumGet(this+0)+24),"uint",this,"uint",refguid)
}
IDirect3DIndexBuffer9_SetPriority(this,PriorityNew) {
    return DllCall(NumGet(NumGet(this+0)+28),"uint",this,"uint",PriorityNew)
}
IDirect3DIndexBuffer9_GetPriority(this) {
    return DllCall(NumGet(NumGet(this+0)+32),"uint",this)
}
IDirect3DIndexBuffer9_PreLoad(this) {
    DllCall(NumGet(NumGet(this+0)+36),"uint",this)
}
IDirect3DIndexBuffer9_GetType(this) {
    return DllCall(NumGet(NumGet(this+0)+40),"uint",this)
}
IDirect3DIndexBuffer9_Lock(this,OffsetToLock,SizeToLock,ByRef ppbData,Flags) {
    return DllCall(NumGet(NumGet(this+0)+44),"uint",this,"uint",OffsetToLock,"uint",SizeToLock,"uint*",ppbData,"uint",Flags)
}
IDirect3DIndexBuffer9_Unlock(this) {
    return DllCall(NumGet(NumGet(this+0)+48),"uint",this)
}
IDirect3DIndexBuffer9_GetDesc(this,pDesc) {
    return DllCall(NumGet(NumGet(this+0)+52),"uint",this,"uint",pDesc)
}
;
; IDirect3DSurface9
;
IDirect3DSurface9_GetDevice(this,ByRef ppDevice) {
    return DllCall(NumGet(NumGet(this+0)+12),"uint",this,"uint*",ppDevice)
}
IDirect3DSurface9_SetPrivateData(this,refguid,pData,SizeOfData,Flags) {
    return DllCall(NumGet(NumGet(this+0)+16),"uint",this,"uint",refguid,"uint",pData,"uint",SizeOfData,"uint",Flags)
}
IDirect3DSurface9_GetPrivateData(this,refguid,pData,ByRef pSizeOfData) {
    return DllCall(NumGet(NumGet(this+0)+20),"uint",this,"uint",refguid,"uint",pData,"uint*",pSizeOfData)
}
IDirect3DSurface9_FreePrivateData(this,refguid) {
    return DllCall(NumGet(NumGet(this+0)+24),"uint",this,"uint",refguid)
}
IDirect3DSurface9_SetPriority(this,PriorityNew) {
    return DllCall(NumGet(NumGet(this+0)+28),"uint",this,"uint",PriorityNew)
}
IDirect3DSurface9_GetPriority(this) {
    return DllCall(NumGet(NumGet(this+0)+32),"uint",this)
}
IDirect3DSurface9_PreLoad(this) {
    DllCall(NumGet(NumGet(this+0)+36),"uint",this)
}
IDirect3DSurface9_GetType(this) {
    return DllCall(NumGet(NumGet(this+0)+40),"uint",this)
}
IDirect3DSurface9_GetContainer(this,riid,ByRef ppContainer) {
    return DllCall(NumGet(NumGet(this+0)+44),"uint",this,"uint",riid,"uint*",ppContainer)
}
IDirect3DSurface9_GetDesc(this,pDesc) {
    return DllCall(NumGet(NumGet(this+0)+48),"uint",this,"uint",pDesc)
}
IDirect3DSurface9_LockRect(this,pLockedRect,pRect,Flags) {
    return DllCall(NumGet(NumGet(this+0)+52),"uint",this,"uint",pLockedRect,"uint",pRect,"uint",Flags)
}
IDirect3DSurface9_UnlockRect(this) {
    return DllCall(NumGet(NumGet(this+0)+56),"uint",this)
}
IDirect3DSurface9_GetDC(this,ByRef phdc) {
    return DllCall(NumGet(NumGet(this+0)+60),"uint",this,"uint*",phdc)
}
IDirect3DSurface9_ReleaseDC(this,hdc) {
    return DllCall(NumGet(NumGet(this+0)+64),"uint",this,"uint",hdc)
}
;
; IDirect3DVolume9
;
IDirect3DVolume9_GetDevice(this,ByRef ppDevice) {
    return DllCall(NumGet(NumGet(this+0)+12),"uint",this,"uint*",ppDevice)
}
IDirect3DVolume9_SetPrivateData(this,refguid,pData,SizeOfData,Flags) {
    return DllCall(NumGet(NumGet(this+0)+16),"uint",this,"uint",refguid,"uint",pData,"uint",SizeOfData,"uint",Flags)
}
IDirect3DVolume9_GetPrivateData(this,refguid,pData,ByRef pSizeOfData) {
    return DllCall(NumGet(NumGet(this+0)+20),"uint",this,"uint",refguid,"uint",pData,"uint*",pSizeOfData)
}
IDirect3DVolume9_FreePrivateData(this,refguid) {
    return DllCall(NumGet(NumGet(this+0)+24),"uint",this,"uint",refguid)
}
IDirect3DVolume9_GetContainer(this,riid,ByRef ppContainer) {
    return DllCall(NumGet(NumGet(this+0)+28),"uint",this,"uint",riid,"uint*",ppContainer)
}
IDirect3DVolume9_GetDesc(this,pDesc) {
    return DllCall(NumGet(NumGet(this+0)+32),"uint",this,"uint",pDesc)
}
IDirect3DVolume9_LockBox(this,pLockedVolume,pBox,Flags) {
    return DllCall(NumGet(NumGet(this+0)+36),"uint",this,"uint",pLockedVolume,"uint",pBox,"uint",Flags)
}
IDirect3DVolume9_UnlockBox(this) {
    return DllCall(NumGet(NumGet(this+0)+40),"uint",this)
}
;
; IDirect3DQuery9
;
IDirect3DQuery9_GetDevice(this,ByRef ppDevice) {
    return DllCall(NumGet(NumGet(this+0)+12),"uint",this,"uint*",ppDevice)
}
IDirect3DQuery9_GetType(this) {
    return DllCall(NumGet(NumGet(this+0)+16),"uint",this)
}
IDirect3DQuery9_GetDataSize(this) {
    return DllCall(NumGet(NumGet(this+0)+20),"uint",this)
}
IDirect3DQuery9_Issue(this,dwIssueFlags) {
    return DllCall(NumGet(NumGet(this+0)+24),"uint",this,"uint",dwIssueFlags)
}
IDirect3DQuery9_GetData(this,pData,dwSize,dwGetDataFlags) {
    return DllCall(NumGet(NumGet(this+0)+28),"uint",this,"uint",pData,"uint",dwSize,"uint",dwGetDataFlags)
}

; ==============================================================================
;                                 D3DX Functions
; ==============================================================================
D3DXFloat32To16Array(pOut,ByRef pIn,n) {
    return DllCall("d3dx9_37\D3DXFloat32To16Array","uint",pOut,"float*",pIn,"uint",n)
}
D3DXFloat16To32Array(ByRef pOut,pIn,n) {
    return DllCall("d3dx9_37\D3DXFloat16To32Array","float*",pOut,"uint",pIn,"uint",n)
}
D3DXVec2Normalize(pOut,pV) {
    return DllCall("d3dx9_37\D3DXVec2Normalize","uint",pOut,"uint",pV)
}
D3DXVec2Hermite(pOut,pV1,pT1,pV2,pT2,s) {
    return DllCall("d3dx9_37\D3DXVec2Hermite","uint",pOut,"uint",pV1,"uint",pT1,"uint",pV2,"uint",pT2,"float",s)
}
D3DXVec2CatmullRom(pOut,pV0,pV1,pV2,pV3,s) {
    return DllCall("d3dx9_37\D3DXVec2CatmullRom","uint",pOut,"uint",pV0,"uint",pV1,"uint",pV2,"uint",pV3,"float",s)
}
D3DXVec2BaryCentric(pOut,pV1,pV2,pV3,f,g) {
    return DllCall("d3dx9_37\D3DXVec2BaryCentric","uint",pOut,"uint",pV1,"uint",pV2,"uint",pV3,"float",f,"float",g)
}
D3DXVec2Transform(pOut,pV,pM) {
    return DllCall("d3dx9_37\D3DXVec2Transform","uint",pOut,"uint",pV,"uint",pM)
}
D3DXVec2TransformCoord(pOut,pV,pM) {
    return DllCall("d3dx9_37\D3DXVec2TransformCoord","uint",pOut,"uint",pV,"uint",pM)
}
D3DXVec2TransformNormal(pOut,pV,pM) {
    return DllCall("d3dx9_37\D3DXVec2TransformNormal","uint",pOut,"uint",pV,"uint",pM)
}
D3DXVec2TransformArray(pOut,OutStride,pV,VStride,pM,n) {
    return DllCall("d3dx9_37\D3DXVec2TransformArray","uint",pOut,"uint",OutStride,"uint",pV,"uint",VStride,"uint",pM,"uint",n)
}
D3DXVec2TransformCoordArray(pOut,OutStride,pV,VStride,pM,n) {
    return DllCall("d3dx9_37\D3DXVec2TransformCoordArray","uint",pOut,"uint",OutStride,"uint",pV,"uint",VStride,"uint",pM,"uint",n)
}
D3DXVec2TransformNormalArray(pOut,OutStride,pV,VStride,pM,n) {
    return DllCall("d3dx9_37\D3DXVec2TransformNormalArray","uint",pOut,"uint",OutStride,"uint",pV,"uint",VStride,"uint",pM,"uint",n)
}
D3DXVec3Normalize(pOut,pV) {
    return DllCall("d3dx9_37\D3DXVec3Normalize","uint",pOut,"uint",pV)
}
D3DXVec3Hermite(pOut,pV1,pT1,pV2,pT2,s) {
    return DllCall("d3dx9_37\D3DXVec3Hermite","uint",pOut,"uint",pV1,"uint",pT1,"uint",pV2,"uint",pT2,"float",s)
}
D3DXVec3CatmullRom(pOut,pV0,pV1,pV2,pV3,s) {
    return DllCall("d3dx9_37\D3DXVec3CatmullRom","uint",pOut,"uint",pV0,"uint",pV1,"uint",pV2,"uint",pV3,"float",s)
}
D3DXVec3BaryCentric(pOut,pV1,pV2,pV3,f,g) {
    return DllCall("d3dx9_37\D3DXVec3BaryCentric","uint",pOut,"uint",pV1,"uint",pV2,"uint",pV3,"float",f,"float",g)
}
D3DXVec3Transform(pOut,pV,pM) {
    return DllCall("d3dx9_37\D3DXVec3Transform","uint",pOut,"uint",pV,"uint",pM)
}
D3DXVec3TransformCoord(pOut,pV,pM) {
    return DllCall("d3dx9_37\D3DXVec3TransformCoord","uint",pOut,"uint",pV,"uint",pM)
}
D3DXVec3TransformNormal(pOut,pV,pM) {
    return DllCall("d3dx9_37\D3DXVec3TransformNormal","uint",pOut,"uint",pV,"uint",pM)
}
D3DXVec3TransformArray(pOut,OutStride,pV,VStride,pM,n) {
    return DllCall("d3dx9_37\D3DXVec3TransformArray","uint",pOut,"uint",OutStride,"uint",pV,"uint",VStride,"uint",pM,"uint",n)
}
D3DXVec3TransformCoordArray(pOut,OutStride,pV,VStride,pM,n) {
    return DllCall("d3dx9_37\D3DXVec3TransformCoordArray","uint",pOut,"uint",OutStride,"uint",pV,"uint",VStride,"uint",pM,"uint",n)
}
D3DXVec3TransformNormalArray(pOut,OutStride,pV,VStride,pM,n) {
    return DllCall("d3dx9_37\D3DXVec3TransformNormalArray","uint",pOut,"uint",OutStride,"uint",pV,"uint",VStride,"uint",pM,"uint",n)
}
D3DXVec3Project(pOut,pV,pViewport,pProjection,pView,pWorld) {
    return DllCall("d3dx9_37\D3DXVec3Project","uint",pOut,"uint",pV,"uint",pViewport,"uint",pProjection,"uint",pView,"uint",pWorld)
}
D3DXVec3Unproject(pOut,pV,pViewport,pProjection,pView,pWorld) {
    return DllCall("d3dx9_37\D3DXVec3Unproject","uint",pOut,"uint",pV,"uint",pViewport,"uint",pProjection,"uint",pView,"uint",pWorld)
}
D3DXVec3ProjectArray(pOut,OutStride,pV,VStride,pViewport,pProjection,pView,pWorld,n) {
    return DllCall("d3dx9_37\D3DXVec3ProjectArray","uint",pOut,"uint",OutStride,"uint",pV,"uint",VStride,"uint",pViewport,"uint",pProjection,"uint",pView,"uint",pWorld,"uint",n)
}
D3DXVec3UnprojectArray(pOut,OutStride,pV,VStride,pViewport,pProjection,pView,pWorld,n) {
    return DllCall("d3dx9_37\D3DXVec3UnprojectArray","uint",pOut,"uint",OutStride,"uint",pV,"uint",VStride,"uint",pViewport,"uint",pProjection,"uint",pView,"uint",pWorld,"uint",n)
}
D3DXVec4Cross(pOut,pV1,pV2,pV3) {
    return DllCall("d3dx9_37\D3DXVec4Cross","uint",pOut,"uint",pV1,"uint",pV2,"uint",pV3)
}
D3DXVec4Normalize(pOut,pV) {
    return DllCall("d3dx9_37\D3DXVec4Normalize","uint",pOut,"uint",pV)
}
D3DXVec4Hermite(pOut,pV1,pT1,pV2,pT2,s) {
    return DllCall("d3dx9_37\D3DXVec4Hermite","uint",pOut,"uint",pV1,"uint",pT1,"uint",pV2,"uint",pT2,"float",s)
}
D3DXVec4CatmullRom(pOut,pV0,pV1,pV2,pV3,s) {
    return DllCall("d3dx9_37\D3DXVec4CatmullRom","uint",pOut,"uint",pV0,"uint",pV1,"uint",pV2,"uint",pV3,"float",s)
}
D3DXVec4BaryCentric(pOut,pV1,pV2,pV3,f,g) {
    return DllCall("d3dx9_37\D3DXVec4BaryCentric","uint",pOut,"uint",pV1,"uint",pV2,"uint",pV3,"float",f,"float",g)
}
D3DXVec4Transform(pOut,pV,pM) {
    return DllCall("d3dx9_37\D3DXVec4Transform","uint",pOut,"uint",pV,"uint",pM)
}
D3DXVec4TransformArray(pOut,OutStride,pV,VStride,pM,n) {
    return DllCall("d3dx9_37\D3DXVec4TransformArray","uint",pOut,"uint",OutStride,"uint",pV,"uint",VStride,"uint",pM,"uint",n)
}
D3DXMatrixDeterminant(pM) {
    return DllCall("d3dx9_37\D3DXMatrixDeterminant","uint",pM)
}
D3DXMatrixDecompose(pOutScale,pOutRotation,pOutTranslation,pM) {
    return DllCall("d3dx9_37\D3DXMatrixDecompose","uint",pOutScale,"uint",pOutRotation,"uint",pOutTranslation,"uint",pM)
}
D3DXMatrixTranspose(pOut,pM) {
    return DllCall("d3dx9_37\D3DXMatrixTranspose","uint",pOut,"uint",pM)
}
D3DXMatrixMultiply(pOut,pM1,pM2) {
    return DllCall("d3dx9_37\D3DXMatrixMultiply","uint",pOut,"uint",pM1,"uint",pM2)
}
D3DXMatrixMultiplyTranspose(pOut,pM1,pM2) {
    return DllCall("d3dx9_37\D3DXMatrixMultiplyTranspose","uint",pOut,"uint",pM1,"uint",pM2)
}
D3DXMatrixInverse(pOut,ByRef pDeterminant,pM) {
    return DllCall("d3dx9_37\D3DXMatrixInverse","uint",pOut,"float*",pDeterminant,"uint",pM)
}
D3DXMatrixScaling(pOut,sx,sy,sz) {
    return DllCall("d3dx9_37\D3DXMatrixScaling","uint",pOut,"float",sx,"float",sy,"float",sz)
}
D3DXMatrixTranslation(pOut,x,y,z) {
    return DllCall("d3dx9_37\D3DXMatrixTranslation","uint",pOut,"float",x,"float",y,"float",z)
}
D3DXMatrixRotationX(pOut,Angle) {
    return DllCall("d3dx9_37\D3DXMatrixRotationX","uint",pOut,"float",Angle)
}
D3DXMatrixRotationY(pOut,Angle) {
    return DllCall("d3dx9_37\D3DXMatrixRotationY","uint",pOut,"float",Angle)
}
D3DXMatrixRotationZ(pOut,Angle) {
    return DllCall("d3dx9_37\D3DXMatrixRotationZ","uint",pOut,"float",Angle)
}
D3DXMatrixRotationAxis(pOut,pV,Angle) {
    return DllCall("d3dx9_37\D3DXMatrixRotationAxis","uint",pOut,"uint",pV,"float",Angle)
}
D3DXMatrixRotationQuaternion(pOut,pQ) {
    return DllCall("d3dx9_37\D3DXMatrixRotationQuaternion","uint",pOut,"uint",pQ)
}
D3DXMatrixRotationYawPitchRoll(pOut,Yaw,Pitch,Roll) {
    return DllCall("d3dx9_37\D3DXMatrixRotationYawPitchRoll","uint",pOut,"float",Yaw,"float",Pitch,"float",Roll)
}
D3DXMatrixTransformation(pOut,pScalingCenter,pScalingRotation,pScaling,pRotationCenter,pRotation,pTranslation) {
    return DllCall("d3dx9_37\D3DXMatrixTransformation","uint",pOut,"uint",pScalingCenter,"uint",pScalingRotation,"uint",pScaling,"uint",pRotationCenter,"uint",pRotation,"uint",pTranslation)
}
D3DXMatrixTransformation2D(pOut,pScalingCenter,ScalingRotation,pScaling,pRotationCenter,Rotation,pTranslation) {
    return DllCall("d3dx9_37\D3DXMatrixTransformation2D","uint",pOut,"uint",pScalingCenter,"float",ScalingRotation,"uint",pScaling,"uint",pRotationCenter,"float",Rotation,"uint",pTranslation)
}
D3DXMatrixAffineTransformation(pOut,Scaling,pRotationCenter,pRotation,pTranslation) {
    return DllCall("d3dx9_37\D3DXMatrixAffineTransformation","uint",pOut,"float",Scaling,"uint",pRotationCenter,"uint",pRotation,"uint",pTranslation)
}
D3DXMatrixAffineTransformation2D(pOut,Scaling,pRotationCenter,Rotation,pTranslation) {
    return DllCall("d3dx9_37\D3DXMatrixAffineTransformation2D","uint",pOut,"float",Scaling,"uint",pRotationCenter,"float",Rotation,"uint",pTranslation)
}
D3DXMatrixLookAtRH(pOut,pEye,pAt,pUp) {
    return DllCall("d3dx9_37\D3DXMatrixLookAtRH","uint",pOut,"uint",pEye,"uint",pAt,"uint",pUp)
}
D3DXMatrixLookAtLH(pOut,pEye,pAt,pUp) {
    return DllCall("d3dx9_37\D3DXMatrixLookAtLH","uint",pOut,"uint",pEye,"uint",pAt,"uint",pUp)
}
D3DXMatrixPerspectiveRH(pOut,w,h,zn,zf) {
    return DllCall("d3dx9_37\D3DXMatrixPerspectiveRH","uint",pOut,"float",w,"float",h,"float",zn,"float",zf)
}
D3DXMatrixPerspectiveLH(pOut,w,h,zn,zf) {
    return DllCall("d3dx9_37\D3DXMatrixPerspectiveLH","uint",pOut,"float",w,"float",h,"float",zn,"float",zf)
}
D3DXMatrixPerspectiveFovRH(pOut,fovy,Aspect,zn,zf) {
    return DllCall("d3dx9_37\D3DXMatrixPerspectiveFovRH","uint",pOut,"float",fovy,"float",Aspect,"float",zn,"float",zf)
}
D3DXMatrixPerspectiveFovLH(pOut,fovy,Aspect,zn,zf) {
    return DllCall("d3dx9_37\D3DXMatrixPerspectiveFovLH","uint",pOut,"float",fovy,"float",Aspect,"float",zn,"float",zf)
}
D3DXMatrixPerspectiveOffCenterRH(pOut,l,r,b,t,zn,zf) {
    return DllCall("d3dx9_37\D3DXMatrixPerspectiveOffCenterRH","uint",pOut,"float",l,"float",r,"float",b,"float",t,"float",zn,"float",zf)
}
D3DXMatrixPerspectiveOffCenterLH(pOut,l,r,b,t,zn,zf) {
    return DllCall("d3dx9_37\D3DXMatrixPerspectiveOffCenterLH","uint",pOut,"float",l,"float",r,"float",b,"float",t,"float",zn,"float",zf)
}
D3DXMatrixOrthoRH(pOut,w,h,zn,zf) {
    return DllCall("d3dx9_37\D3DXMatrixOrthoRH","uint",pOut,"float",w,"float",h,"float",zn,"float",zf)
}
D3DXMatrixOrthoLH(pOut,w,h,zn,zf) {
    return DllCall("d3dx9_37\D3DXMatrixOrthoLH","uint",pOut,"float",w,"float",h,"float",zn,"float",zf)
}
D3DXMatrixOrthoOffCenterRH(pOut,l,r,b,t,zn,zf) {
    return DllCall("d3dx9_37\D3DXMatrixOrthoOffCenterRH","uint",pOut,"float",l,"float",r,"float",b,"float",t,"float",zn,"float",zf)
}
D3DXMatrixOrthoOffCenterLH(pOut,l,r,b,t,zn,zf) {
    return DllCall("d3dx9_37\D3DXMatrixOrthoOffCenterLH","uint",pOut,"float",l,"float",r,"float",b,"float",t,"float",zn,"float",zf)
}
D3DXMatrixShadow(pOut,pLight,pPlane) {
    return DllCall("d3dx9_37\D3DXMatrixShadow","uint",pOut,"uint",pLight,"uint",pPlane)
}
D3DXMatrixReflect(pOut,pPlane) {
    return DllCall("d3dx9_37\D3DXMatrixReflect","uint",pOut,"uint",pPlane)
}
D3DXQuaternionToAxisAngle(pQ,pAxis,ByRef pAngle) {
    DllCall("d3dx9_37\D3DXQuaternionToAxisAngle","uint",pQ,"uint",pAxis,"float*",pAngle)
}
D3DXQuaternionRotationMatrix(pOut,pM) {
    return DllCall("d3dx9_37\D3DXQuaternionRotationMatrix","uint",pOut,"uint",pM)
}
D3DXQuaternionRotationAxis(pOut,pV,Angle) {
    return DllCall("d3dx9_37\D3DXQuaternionRotationAxis","uint",pOut,"uint",pV,"float",Angle)
}
D3DXQuaternionRotationYawPitchRoll(pOut,Yaw,Pitch,Roll) {
    return DllCall("d3dx9_37\D3DXQuaternionRotationYawPitchRoll","uint",pOut,"float",Yaw,"float",Pitch,"float",Roll)
}
D3DXQuaternionMultiply(pOut,pQ1,pQ2) {
    return DllCall("d3dx9_37\D3DXQuaternionMultiply","uint",pOut,"uint",pQ1,"uint",pQ2)
}
D3DXQuaternionNormalize(pOut,pQ) {
    return DllCall("d3dx9_37\D3DXQuaternionNormalize","uint",pOut,"uint",pQ)
}
D3DXQuaternionInverse(pOut,pQ) {
    return DllCall("d3dx9_37\D3DXQuaternionInverse","uint",pOut,"uint",pQ)
}
D3DXQuaternionLn(pOut,pQ) {
    return DllCall("d3dx9_37\D3DXQuaternionLn","uint",pOut,"uint",pQ)
}
D3DXQuaternionExp(pOut,pQ) {
    return DllCall("d3dx9_37\D3DXQuaternionExp","uint",pOut,"uint",pQ)
}
D3DXQuaternionSlerp(pOut,pQ1,pQ2,t) {
    return DllCall("d3dx9_37\D3DXQuaternionSlerp","uint",pOut,"uint",pQ1,"uint",pQ2,"float",t)
}
D3DXQuaternionSquad(pOut,pQ1,pA,pB,pC,t) {
    return DllCall("d3dx9_37\D3DXQuaternionSquad","uint",pOut,"uint",pQ1,"uint",pA,"uint",pB,"uint",pC,"float",t)
}
D3DXQuaternionSquadSetup(pAOut,pBOut,pCOut,pQ0,pQ1,pQ2,pQ3) {
    DllCall("d3dx9_37\D3DXQuaternionSquadSetup","uint",pAOut,"uint",pBOut,"uint",pCOut,"uint",pQ0,"uint",pQ1,"uint",pQ2,"uint",pQ3)
}
D3DXQuaternionBaryCentric(pOut,pQ1,pQ2,pQ3,f,g) {
    return DllCall("d3dx9_37\D3DXQuaternionBaryCentric","uint",pOut,"uint",pQ1,"uint",pQ2,"uint",pQ3,"float",f,"float",g)
}
D3DXPlaneNormalize(pOut,pP) {
    return DllCall("d3dx9_37\D3DXPlaneNormalize","uint",pOut,"uint",pP)
}
D3DXPlaneIntersectLine(pOut,pP,pV1,pV2) {
    return DllCall("d3dx9_37\D3DXPlaneIntersectLine","uint",pOut,"uint",pP,"uint",pV1,"uint",pV2)
}
D3DXPlaneFromPointNormal(pOut,pPoint,pNormal) {
    return DllCall("d3dx9_37\D3DXPlaneFromPointNormal","uint",pOut,"uint",pPoint,"uint",pNormal)
}
D3DXPlaneFromPoints(pOut,pV1,pV2,pV3) {
    return DllCall("d3dx9_37\D3DXPlaneFromPoints","uint",pOut,"uint",pV1,"uint",pV2,"uint",pV3)
}
D3DXPlaneTransform(pOut,pP,pM) {
    return DllCall("d3dx9_37\D3DXPlaneTransform","uint",pOut,"uint",pP,"uint",pM)
}
D3DXPlaneTransformArray(pOut,OutStride,pP,PStride,pM,n) {
    return DllCall("d3dx9_37\D3DXPlaneTransformArray","uint",pOut,"uint",OutStride,"uint",pP,"uint",PStride,"uint",pM,"uint",n)
}
D3DXColorAdjustSaturation(pOut,pC,s) {
    return DllCall("d3dx9_37\D3DXColorAdjustSaturation","uint",pOut,"uint",pC,"float",s)
}
D3DXColorAdjustContrast(pOut,pC,c) {
    return DllCall("d3dx9_37\D3DXColorAdjustContrast","uint",pOut,"uint",pC,"float",c)
}
D3DXFresnelTerm(CosTheta,RefractionIndex) {
    return DllCall("d3dx9_37\D3DXFresnelTerm","float",CosTheta,"float",RefractionIndex)
}
D3DXCreateMatrixStack(Flags,ppStack) {
    return DllCall("d3dx9_37\D3DXCreateMatrixStack","uint",Flags,"uint",ppStack)
}
D3DXSHEvalDirection(pOut,Order,pDir) {
    return DllCall("d3dx9_37\D3DXSHEvalDirection","uint",pOut,"uint",Order,"uint",pDir)
}
D3DXSHRotate(pOut,Order,pMatrix,pIn) {
    return DllCall("d3dx9_37\D3DXSHRotate","uint",pOut,"uint",Order,"uint",pMatrix,"uint",pIn)
}
D3DXSHRotateZ(pOut,Order,Angle,pIn) {
    return DllCall("d3dx9_37\D3DXSHRotateZ","uint",pOut,"uint",Order,"float",Angle,"uint",pIn)
}
D3DXSHAdd(pOut,Order,pA,pB) {
    return DllCall("d3dx9_37\D3DXSHAdd","uint",pOut,"uint",Order,"uint",pA,"uint",pB)
}
D3DXSHScale(pOut,Order,pIn,Scale) {
    return DllCall("d3dx9_37\D3DXSHScale","uint",pOut,"uint",Order,"uint",pIn,"float",Scale)
}
D3DXSHDot(Order,pA,pB) {
    return DllCall("d3dx9_37\D3DXSHDot","uint",Order,"uint",pA,"uint",pB)
}
D3DXSHMultiply2(pOut,pF,pG) {
    return DllCall("d3dx9_37\D3DXSHMultiply2","uint",pOut,"uint",pF,"uint",pG)
}
D3DXSHMultiply3(pOut,pF,pG) {
    return DllCall("d3dx9_37\D3DXSHMultiply3","uint",pOut,"uint",pF,"uint",pG)
}
D3DXSHMultiply4(pOut,pF,pG) {
    return DllCall("d3dx9_37\D3DXSHMultiply4","uint",pOut,"uint",pF,"uint",pG)
}
D3DXSHMultiply5(pOut,pF,pG) {
    return DllCall("d3dx9_37\D3DXSHMultiply5","uint",pOut,"uint",pF,"uint",pG)
}
D3DXSHMultiply6(pOut,pF,pG) {
    return DllCall("d3dx9_37\D3DXSHMultiply6","uint",pOut,"uint",pF,"uint",pG)
}
D3DXSHEvalDirectionalLight(Order,pDir,RIntensity,GIntensity,BIntensity,ByRef pROut,ByRef pGOut,ByRef pBOut) {
    return DllCall("d3dx9_37\D3DXSHEvalDirectionalLight","uint",Order,"uint",pDir,"float",RIntensity,"float",GIntensity,"float",BIntensity,"float*",pROut,"float*",pGOut,"float*",pBOut)
}
D3DXSHEvalSphericalLight(Order,pPos,Radius,RIntensity,GIntensity,BIntensity,ByRef pROut,ByRef pGOut,ByRef pBOut) {
    return DllCall("d3dx9_37\D3DXSHEvalSphericalLight","uint",Order,"uint",pPos,"float",Radius,"float",RIntensity,"float",GIntensity,"float",BIntensity,"float*",pROut,"float*",pGOut,"float*",pBOut)
}
D3DXSHEvalConeLight(Order,pDir,Radius,RIntensity,GIntensity,BIntensity,ByRef pROut,ByRef pGOut,ByRef pBOut) {
    return DllCall("d3dx9_37\D3DXSHEvalConeLight","uint",Order,"uint",pDir,"float",Radius,"float",RIntensity,"float",GIntensity,"float",BIntensity,"float*",pROut,"float*",pGOut,"float*",pBOut)
}
D3DXSHEvalHemisphereLight(Order,pDir,Top_r,Top_g,Top_b,Top_a,Bottom_r,Bottom_g,Bottom_b,Bottom_a,ByRef pROut,ByRef pGOut,ByRef pBOut) {
    return DllCall("d3dx9_37\D3DXSHEvalHemisphereLight","uint",Order,"uint",pDir,"float",Top_r,"float",Top_g,"float",Top_b,"float",Top_a,"float",Bottom_r,"float",Bottom_g,"float",Bottom_b,"float",Bottom_a,"float*",pROut,"float*",pGOut,"float*",pBOut)
}
D3DXSHProjectCubeMap(uOrder,pCubeMap,ByRef pROut,ByRef pGOut,ByRef pBOut) {
    return DllCall("d3dx9_37\D3DXSHProjectCubeMap","uint",uOrder,"uint",pCubeMap,"float*",pROut,"float*",pGOut,"float*",pBOut)
}


Struct(ByRef buf, p*) {
    VarSetCapacity(tbuf, 8)
    size := 0
    Loop % p.Length()//2
        size += NumPut(0, tbuf, 0, p[A_Index*2-1]) - &tbuf
    VarSetCapacity(buf, size, 0), addr := &buf
    Loop % p.Length()//2
        addr := NumPut(p[A_Index*2], addr+0, 0, p[A_Index*2-1])
    return &buf
}

StdOut(s, t) {
    FileAppend % t ": " s "`n", *
}
Attachments
bpm.jpg
bpm.jpg (217.83 KiB) Viewed 4702 times
Helgef
Posts: 4458
Joined: 17 Jul 2016, 01:02
Contact:

Re: Direct3D proof of concept / Steam BPM overlay

09 Mar 2017, 07:06

lexikos wrote: Demonstrates rendering a minimal 3D scene (a spinning triangle) to a semi-transparent window.
Impressive stuff. :wave:
I looked at the Direct3d stuff once, I decided it might be to much work, I guess that was an understatment :D

For reference, to run it, I needed to add

Code: Select all

StdOut(v*){
}
to avoid Call to nonexistent function error.

Thanks for sharing, cheers!
lexikos
Posts: 7057
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: Direct3D proof of concept / Steam BPM overlay

10 Mar 2017, 02:04

Thanks. I've added a definition of StdOut().
Notus
Posts: 7
Joined: 14 Jun 2016, 19:58

Re: Direct3D proof of concept / Steam BPM overlay

10 Mar 2017, 02:07

...wish I can understand at least 10% of Lexi's code.... impressive work as usual.
User avatar
jNizM
Posts: 2661
Joined: 30 Sep 2013, 01:33
GitHub: jNizM
Contact:

Re: Direct3D proof of concept / Steam BPM overlay

10 Mar 2017, 02:59

Direct3D proof crashes for me (compiled as 1.1.25.01 x86)

Edit:
As long my mouse is around the center of my monitor the tooltip is empty and as far as i move my mouse to the center the script crashes with the first fps entry in tooltip.
[AHK] 1.1.32.00 x64 Unicode | [WIN] 10 Pro (Version 2004) x64 | [GitHub] Profile
Donations are appreciated if I could help you
lexikos
Posts: 7057
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: Direct3D proof of concept / Steam BPM overlay

10 Mar 2017, 04:08

You can try removing OnMessage(0x84, "OnHitTest"). The hit-testing is non-essential. I see no other reason for the script to be dependent on mouse position.

I do not see how the tooltip can be empty. It's value does not depend on successful D3D rendering, only on basic system functions and logic. And even if those fail, the " fps" suffix will remain.
sGuest

Re: Direct3D proof of concept / Steam BPM overlay

10 Mar 2017, 04:44

All we need now is to be able to make a GUI in D3D 8-)
Big thanks for sharing :clap: really nice stuff !
User avatar
evilC
Posts: 4780
Joined: 27 Feb 2014, 12:30

Re: Direct3D proof of concept / Steam BPM overlay

10 Mar 2017, 14:47

Interesting stuff.
Is this potentially a solution for making overlays which can be injected into Fullscreen DX apps?

There was an OSD library which did this, but IIRC, it was DX8 only or something.
SpecialGuest
Posts: 26
Joined: 15 May 2016, 07:49

Re: Direct3D proof of concept / Steam BPM overlay

10 Mar 2017, 17:11

@evilC https://autohotkey.com/boards/viewtopic ... ctx#p80387 ?
That one was DX9 back then, not sure if it changed in the meantime..
lexikos
Posts: 7057
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: Direct3D proof of concept / Steam BPM overlay

10 Mar 2017, 22:07

This script has nothing to do with creating a Direct3D overlay. Putting aside the "Layered" mode and the single DWM API call, it just uses Direct3D9 in the same way as probably every other Direct3D9 based app, thereby acting as something for Steam to hook into.
malcev
Posts: 648
Joined: 12 Aug 2014, 12:37

Re: Direct3D proof of concept / Steam BPM overlay

09 Jul 2020, 18:45

evilC wrote:
10 Mar 2017, 14:47
Is this potentially a solution for making overlays which can be injected into Fullscreen DX apps?
Now I think it possible - just need to convert ImGui Autoit wrapper
https://www.autoitscript.com/forum/topic/203287-imgui-in-autoit-advanced-ui

Return to “Scripts and Functions”

Who is online

Users browsing this forum: connorshinn and 16 guests