Problem initializing textures

reanjr

Newcomer
Joined
Jul 25, 2003
Messages
19
I'm having some problems getting a Texture initialized.
I am receiving a Microsoft.DirectX.Direct3D.InvalidCallException in microsoft.directx.direct3d.dll

NOTE: I realize there are functions that load textures from files and streams, but I need to use this method for a Texture Management class to work.

-------------------------------------
Dim w, h as Integer
Dim Levels as Integer

w=32
h=32
Levels=1
dev = New Device(...)

'-- bad line here --
tex = New Texture(dev, w, h, Levels, Usage.RenderTarget, Format.X8R8G8B8, Pool.Managed)
-------------------------------------

Does anyone have any details on why this Constructor would throw this Exception? Or for that matter, exactly what numLevels is for and how it works (I think it can be used for MipMaps, but I can't find any documentation regarding this)
 
This worked for me:

Texture tex = null;
tex = new Texture(dev, 32, 32, 0, 0, Format.A8R8G8B8, Pool.Managed);

Setting the numLevels to 0, tells DirectX to figure out the levels itself.
Setting the usage to Usage.SoftwareProcessing or to 0 is what you'll want. Usage.RenderTarget will not work - that is what causes the exception.
The format can be whatever you'll need.
 
You can't use managed for renderTarget texture. If you want renderTarget use default. If you need normal texture use 0 as option
 
Back
Top