Cloral
Jan 18th, 2003, 02:02 PM
I'm trying to get some binary image data into a texture. I was instructed to lock the texture and then to copy the data into the location returned from the locking. The LockRect method of the DriectX8Texture doesn't seem to return any sort of an address though. Am I using the wrong function, or is there something else I need to be doing?
Zaei
Jan 18th, 2003, 02:06 PM
D3DLOCKED_RECT.pBits contains the address you should copy to.
Z.
Cloral
Jan 19th, 2003, 12:09 AM
Ah! Thanks. :)
edit:
Hmm.... I must still be doing something wrong. The texture comes out empty. Here is the code I am using to test this (I am aware that the transfer to binary data is a bit redundant in this particular method, but this is just to test it so that I will know it works for when I need it later):
Public Function getTextureFromFile(fileName As String) As Direct3DTexture8
'Load a texture from file
Dim img As ftImage, temp As Direct3DTexture8
Dim lr As D3DLOCKED_RECT
img = getImageFromFile(fileName)
'Init the texture
Set temp = man.forXFiles.CreateTexture(man.dxDevice, img.info.bmiHeader.biWidth, img.info.bmiHeader.biHeight, 1, DIB_RGB_COLORS, D3DFMT_R8G8B8, D3DPOOL_MANAGED)
temp.LockRect 0, lr, ByVal 0, 0
DXCopyMemory ByVal lr.pBits, img.data(0), (img.info.bmiHeader.biSizeImage + 1) * 3
temp.UnlockRect 0
Set getTextureFromFile = temp
End Function
Where the ftImage is by custom format to hold image data. It is formatted as given in this tutorial (http://rookscape.com/vbgaming/tutR.php). And I am sure that part of it works, because I've used this ftImage structure before with success. And the image size is 1024x1024, so there shouldn't be any sort of stretching.