|
Function LoadBgTextureFile(ByVal lpszFile As String, Optional ByVal lpbgIndex As Long = -1) As Long
Dim lngIndex As Long
If Dir(lpszFile) = vbNullString Then
LoadBgTextureFile = -1
Exit Function
End If
if lpbgIndex >=0 then
'有了这个判断后,在后面的建立材建EX方法,就出现非法错误.取消则正确了.
lngIndex=lpbgIndex
else
If bgInfoSum < 1 Then
bgInfoSum = 1
Else
bgInfoSum = bgInfoSum + 1
End If
lngIndex = bgInfoSum - 1
ReDim Preserve bgInfo(lngIndex)
end if
Dim di As D3DXIMAGE_INFO
'把这个di定义放在函数最前面,在建立材建EX方法,就出现非法错误.放在这里就正确了.
With bgInfo(lngIndex)
'Set .Texture = x_d3dx8.CreateTextureFromFile(x_dev, lpszFile)
Set .Texture = x_d3dx8.CreateTextureFromFileEx(x_dev, lpszFile, _
D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, _
D3DPOOL_MANAGED, D3DX_FILTER_POINT, _
D3DX_FILTER_POINT, 0, di, ByVal 0)
.lpHeight = di.Height
.lpWidth = di.Width
End With
LoadBgTextureFile = lngIndex
End Function
------------------------------
不明白这是为什么.郁闷...... |
|