|
-
Jan 18th, 2003, 03:02 PM
#1
Thread Starter
Junior Member
Locked Textures in DX8
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?
-
Jan 18th, 2003, 03:06 PM
#2
Frenzied Member
D3DLOCKED_RECT.pBits contains the address you should copy to.
Z.
-
Jan 19th, 2003, 01:09 AM
#3
Thread Starter
Junior Member
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):
Code:
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. 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.
Last edited by Cloral; Jan 19th, 2003 at 01:41 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|