Michi558315

Hi ,

I want to put my textures in a resource-file in order to have one file left after compilation to make it more easy to handle. Well, I created the .res-file and put my 7 textures, which got the IDs 101-108, with "add picture" inside . I try to get a texture like shown below:


Code Snippet

'// necessary Declarations
'//////////////////////////////
Dim texture As Direct3DTexture8
Set g_d3dx = New D3DX8
Set g_dev = g_d3d.CreateDevice(g_lCurrentAdapter, devtype, g_focushwnd, g_behaviorflags, g_d3dpp)

'// Function
'///////////////////////////
Set texture = g_d3dx.CreateTextureFromResource(g_dev, App.hInstance, "101")

The result is an automation-error. Errornumber = -2005529767 (88760b59)

As far as I can see I did everthing right. g_dev is a valid d3dx8-object, app.hInstance should be ok as module-handle of my form and the string I use is the ID given by the resource-editor when putting the picture inside.

I also tried "original-name", "o-name.bmp" and "ID.bmp" as third parameter, but got the same error.


Any ideas why this doesn¡¯t work

Thx in advance



Re: Game Technologies: DirectX 101 VB6/DX8 CreateTexturefromResource parameters?

Wessam Bahnassi

What is the type of resource your textures are put in D3DX expects them to stay in RT_RCDATA type. An alternative would be to locate the resource's address yourself and pass it to D3DX's LoadFromMemory function instead.




Re: Game Technologies: DirectX 101 VB6/DX8 CreateTexturefromResource parameters?

Michi

Thank you very much for your reply.

I inserted the data in the resource-editor as "picture" first, but added them additionally as "custom". Now I¡¯ve replaced all "CUSTOM"-types by "RT_RCDATA" (including the quotation marks) but the error remains.

I also tried to create from memory, but the error remains here also

Code Snippet

'// necessary declarations

/////////////////////////////////////////////////////
Dim texture As Direct3DTexture8
Dim tex() As Byte
Dim byte_length As Long

'// Function

/////////////////////////////////////////////////////
tex = LoadResData(117, "RT_RCDATA")
byte_length = UBound(tex)
Set texture = g_d3dx.CreateTextureFromFileInMemory(g_dev, tex, byte_length)

It would be nice if there is some kind of tutorial describing how to do this with vb.

thank you





Re: Game Technologies: DirectX 101 VB6/DX8 CreateTexturefromResource parameters?

Wessam Bahnassi

The proper RT_RCDATA type is not a string resource type. It's an integer with the value 10. I suggest that you stick to the manual resource loading way. Are you sure you have valid data in tex and byte_length




Re: Game Technologies: DirectX 101 VB6/DX8 CreateTexturefromResource parameters?

Michi

Hi,

thanks for your reply and yes I stick to that. I thought using strings is the appropriate way to define the datatype.

This is from the VB-documentation under Hardcore Visual Basic => Anatomy of a ResourceBlock:

Code Snippet

You can load this resource into an array of bytes, as shown here:

abWavGrunt = LoadResData(ordWavGrunt, ¡°WAVE¡±)

Neither the dokumentation nor the web is very helpful or I¡¯m just overlooking the appropriate information so I¡¯m just guessing.

The data in tex and byte_length seem to be right. The filesize of the texture is specified with 811 kb in the data-properties and byte_length is exactly 786.485 so regarding overhead the data in byte_length should be ok. For the tex I don¡¯t know how to check for its validity, but it has of course as many bytes as byte_length.