Discussion:
Does D3DX8.CreateTextureFromResource work in vb6?
(too old to reply)
n***@hotmail.com
2007-10-20 09:08:28 UTC
Permalink
When I try like this

Set g_TEXT_Texture = g_d3dx.CreateTextureFromResource(g_D3DDevice,
App.hInstance, "101")

it causes the error

D3DXERR_INVALIDDATA

I think invalid data is not really the problem beacuse the same error
happens even if I make up a bogus name for the resource instead of
"101", it also happens if I make up a bogus number for the 2nd
parameter. Clearly it can't access any data in these cases, whether
invalid or not.

Unfortuanetly the definition of the last parameter isn't given in MSDN
and I'm only guessing it should be the name of the resource. It's
described like this:

"SrcResource
String that specifies the resource from which to create the texture. "

Does that sound like "101"?



Alternatively is there any other way to create a texture from memory
without it having to be already in the correct format?

What do people usually do for textures without having to keep seperate
files?
legalize+ (Richard [Microsoft Direct3D MVP])
2007-10-20 15:39:22 UTC
Permalink
[Please do not mail me a copy of your followup; and please pick only
one newsgroup to post to]
Post by n***@hotmail.com
When I try like this
Set g_TEXT_Texture = g_d3dx.CreateTextureFromResource(g_D3DDevice,
App.hInstance, "101")
it causes the error
D3DXERR_INVALIDDATA
Enable unmanaged debugging and look at the debug output for more
information.

However, I think you are unfamiliar with Win32 resources. Win32
resources are either identified by name or by ID. What do you have in
your resource .rc file? And no, .NET resources are not Win32 resources.
--
"The Direct3D Graphics Pipeline" -- DirectX 9 draft available for download
<http://www.xmission.com/~legalize/book/download/index.html>

Legalize Adulthood! <http://blogs.xmission.com/legalize/>
n***@hotmail.com
2007-10-20 23:34:14 UTC
Permalink
Post by legalize+ (Richard [Microsoft Direct3D MVP])
Post by n***@hotmail.com
Set g_TEXT_Texture = g_d3dx.CreateTextureFromResource(g_D3DDevice,
App.hInstance, "101")
Enable unmanaged debugging and look at the debug output for more
information.
However, I think you are unfamiliar with Win32 resources. Win32
resources are either identified by name or by ID. What do you have in
your resource .rc file? And no, .NET resources are not Win32 resources.
Hi.

I think I have the maximum debug options on, but I don't get any
errors, only some warnings about redundant setrenderstates which are
there anyway.

The resource ID is 101, two different .res editors don't show any name
other than that. However the CreateTextureFromResource documentation
doesn't specify if it is the ID or name or something else that's
required, but it must be a string.

It also doesn't specify if it's a VB resource or a Win32 resource. I
have a resource in a VB resource file.
legalize+ (Richard [Microsoft Direct3D MVP])
2007-10-21 01:06:36 UTC
Permalink
[Please do not mail me a copy of your followup]
Post by n***@hotmail.com
I think I have the maximum debug options on, but I don't get any
errors, only some warnings about redundant setrenderstates which are
there anyway.
Oh, I just noticed you're using VB6, but you're posting to the managed
code newsgroup.

VB6 doesn't use managed code.

Hmm. I'm surprised you don't get anything more; since this is a D3DX
function you will need to consume the debug D3DX, but I'm guessing
that whatever API layer you're using (I've never coded D3D in VB6)
doesn't consume the debug D3DX, so you won't get a message from D3DX
about the error.
Post by n***@hotmail.com
The resource ID is 101, two different .res editors don't show any name
other than that. However the CreateTextureFromResource documentation
doesn't specify if it is the ID or name or something else that's
required, but it must be a string.
In Win32 resources are identified by integer ID or by string. In
Win32, integer resources are simply casted to the string pointer type.
If you can't do the cast in VB6, then change your resource to be
identified by a string and not by an ID.
--
"The Direct3D Graphics Pipeline" -- DirectX 9 draft available for download
<http://www.xmission.com/~legalize/book/download/index.html>

Legalize Adulthood! <http://blogs.xmission.com/legalize/>
n***@hotmail.com
2007-10-21 13:57:50 UTC
Permalink
Post by legalize+ (Richard [Microsoft Direct3D MVP])
VB6 doesn't use managed code.
That function creates a texture in the managed memory pool, but I
suppose that's a different meaning.
Post by legalize+ (Richard [Microsoft Direct3D MVP])
Hmm. I'm surprised you don't get anything more; since this is a D3DX
function you will need to consume the debug D3DX, but I'm guessing
that whatever API layer you're using (I've never coded D3D in VB6)
doesn't consume the debug D3DX, so you won't get a message from D3DX
about the error.
Could be, it must be possible without relying on error messages tho. I
actually don't know what parameters I'm supposed to pass it. I've
still got a few more avenues to search in, but I'm really suprised
there's no clear way to do this common task.
legalize+ (Richard [Microsoft Direct3D MVP])
2007-10-22 12:32:42 UTC
Permalink
[Please do not mail me a copy of your followup]
Post by n***@hotmail.com
Post by legalize+ (Richard [Microsoft Direct3D MVP])
VB6 doesn't use managed code.
That function creates a texture in the managed memory pool, but I
suppose that's a different meaning.
Yes, its a different meaning.
Post by n***@hotmail.com
Post by legalize+ (Richard [Microsoft Direct3D MVP])
Hmm. I'm surprised you don't get anything more; since this is a D3DX
function you will need to consume the debug D3DX, but I'm guessing
that whatever API layer you're using (I've never coded D3D in VB6)
doesn't consume the debug D3DX, so you won't get a message from D3DX
about the error.
Could be, it must be possible without relying on error messages tho. I
actually don't know what parameters I'm supposed to pass it. I've
still got a few more avenues to search in, but I'm really suprised
there's no clear way to do this common task.
The easiest thing to do would be to identify your resource by a string
name and not by an ID number.
--
"The Direct3D Graphics Pipeline" -- DirectX 9 draft available for download
<http://www.xmission.com/~legalize/book/download/index.html>

Legalize Adulthood! <http://blogs.xmission.com/legalize/>
Loading...