' 0 QueryInterface as function(byval This as IDirect3DLight ptr, byval riid as const IID const ptr, byval ppvObject as any ptr ptr) as HRESULT
'	1 AddRef as function(byval This as IDirect3DLight ptr) as ULONG
'	2 Release as function(byval This as IDirect3DLight ptr) as ULONG
'	3 Initialize as function(byval This as IDirect3DLight ptr, byval d3d as IDirect3D ptr) as HRESULT
'	4 SetLight as function(byval This as IDirect3DLight ptr, byval data as D3DLIGHT ptr) as HRESULT
'	5 GetLight as function(byval This as IDirect3DLight ptr, byval data as D3DLIGHT ptr) as HRESULT
'                                                                                 

' ****************************************************************************************
function d3dlightPrototype() as hresult
  FatalError("D3D::light.#%i Function not implemented",D3DlightPROTOID)
  return DDERR_UNSUPPORTED  
  
  asm
    .balign 32
    _d3dlightProtoTable_:  
    #macro ProtoNum(X)
    mov dword ptr [D3DlightPROTOID],X
    jmp d3dlightPrototype
    .balign 32
    #endmacro
    ProtoNum(0)
    ProtoNum(1)
    ProtoNum(2)
    ProtoNum(3)
    ProtoNum(4)
    ProtoNum(5)
    ProtoNum(6)
    ProtoNum(7)
    ProtoNum(8)
    ProtoNum(9)
    ProtoNum(10)
    ProtoNum(11)
    ProtoNum(12)
    ProtoNum(13)
    ProtoNum(14)
    ProtoNum(15)
    ProtoNum(16)
    ProtoNum(17)
    ProtoNum(18)
    ProtoNum(19)
    ProtoNum(20)    
  end asm  
  
end function
' ****************************************************************************************
UndefAll()
#define P1 pTHIS as d3dlightObject ptr
function d3dlight_2_Release(P1) as hresult
  #ifdef MyDebugD3D
  Cout("IDirect3D2::light.Release (2)" + chr$(13,10) + _
  " >> THIS: "+hex$(cast(uinteger,pTHIS),8))
  #endif  
  if pTHIS=0 then ddrawError(DDERR_INVALIDPARAMS)
  if pTHIS->Interface <> itd3dlight then ddrawError(DDERR_INVALIDOBJECT)
  Delete pTHIS
  return DD_OK
end function
' ****************************************************************************************
#if 0
  UndefAll()
  #define P1 pTHIS    as d3dMaterial2Object ptr
  #define P2 pMat     as D3DMATERIAL ptr
  function d3dMaterial2_3_SetMaterial(P1,P2) as hresult
    #ifdef MyDebugD3D
    Cout("IDirect3D2::Material2.SetMaterial (3)" + chr$(13,10) + _
    " >> THIS: "+hexptr(pTHIS)+"  pMat: "+hexptr(pMat))
    #endif  
    if pTHIS=0 or pMat=0 then ddrawError(DDERR_INVALIDPARAMS)  
    if pTHIS->Interface <> itd3dMaterial2 then ddrawError(DDERR_INVALIDOBJECT)
    pTHIS->Props = *pMat
    return DD_OK
  end function
  ' ****************************************************************************************
  UndefAll()
  #define P1 pTHIS    as d3dMaterial2Object ptr
  #define P2 pMat     as D3DMATERIAL ptr
  function d3dMaterial2_4_GetMaterial(P1,P2) as hresult
    #ifdef MyDebugD3D
    Cout("IDirect3D2::Material2.GetMaterial (4)" + chr$(13,10) + _
    " >> THIS: "+hexptr(pTHIS)+"  pMat: "+hexptr(pMat))
    #endif  
    if pTHIS=0 or pMat=0 then ddrawError(DDERR_INVALIDPARAMS)  
    if pTHIS->Interface <> itd3dMaterial2 then ddrawError(DDERR_INVALIDOBJECT)
    *pMat = pTHIS->Props
    return DD_OK
  end function
  ' ****************************************************************************************
  UndefAll()
  #define P1 pTHIS    as d3dMaterial2Object ptr
  #define P2 pOwner   as d3dDevice2Object ptr
  #define P3 ppHandle as any ptr ptr
  function d3dMaterial2_5_GetHandle(P1,P2,P3) as hresult
    #ifdef MyDebugD3D
    Cout("IDirect3D2::Material2.GetHandle (5)" + chr$(13,10) + _
    " >> THIS: "+hexptr(pTHIS)+"  pOwner: "+hexptr(pOwner)+"  OUT: "+hexptr(ppHandle))
    #endif  
    if pTHIS=0 or ppHandle=0 then ddrawError(DDERR_INVALIDPARAMS)  
    if pTHIS->Interface <> itd3dMaterial2 then ddrawError(DDERR_INVALIDOBJECT)
    *ppHandle = pTHIS
    return DD_OK
  end function
#endif

' ****************************************************************************************
' ****************************************************************************************
' ****************************************************************************************
sub d3dlightFuncs(VTABLE() as any ptr)
  dim as any ptr PROTOTABLE
  asm mov dword ptr [PROTOTABLE], offset _d3dlightProtoTable_
  for CNT as integer = 0 to 20
    VTABLE(CNT) = PROTOTABLE+CNT*32
  next CNT  
  VTABLE(2) = @d3dlight_2_Release
  'VTABLE(3) = @d3dlight_3_SetMaterial
  'VTABLE(4) = @d3dlight_4_GetMaterial
  'VTABLE(5) = @d3dlight_5_GetHandle 
end sub