Skip to main content
GameDev.net gamedev.net
🔒 Locked

Code works on one machine, not on another

Started by FieroAddict May 31, 2003 at 10:42 AM 11 replies 6.8k views
Original Post
FieroAddict
FieroAddict
I''ve been working on a game using the Sprite class in managed Direct3D. Well, it was working just fine on my desktop computer but when I tried moving it over to my new laptop to work on it all of my TextureLoader.FromStream() calls fail. At first I though maybe it was having trouble loading the larger textures because the laptop has 32MB of video memory and the desktop has 64MB, but I commented out the others and left a couple 16x16 textures and those fail too. I checked the device caps and it supports the same formats that my desktop card does. Anyone have an idea of what could make a function call like this fail from one machine to another? Thanks for any ideas.

    Public Shared Function Init(ByRef dev As Device, ByRef image As Stream) As Boolean
        theSprite = New Sprite(dev)
        srcTexture = TextureLoader.FromStream(dev, image, 0, 0, 0, Usage.Dynamic, Format.Unknown, Pool.Default, Filter.None, Filter.None, Color.Pink.ToArgb)
    End Function


Dave Hunt
Dave Hunt
If you wrap the FromStream() call in a try/catch, you can find out what the error is...
FieroAddict
FieroAddict
Well, I tried displaying the exception that was thrown in a message box... all it says is "Error in the application" as the exception message. Not very helpfull. I wonder if it has something to do with the ATI Mobility 7500... I going to have to try this on another video card and see if the problem still exists.
Dave Hunt
Dave Hunt
Check the ErrorCode member of the exception. It should tell what''s going on.
FieroAddict
FieroAddict
OK, I''m new to .NET error checking...

Now I have it catching a Direct3DXException and displaying an error code of -2005530518. I attempted to look up the number in the DirectX error code lookup, but didn''t find anything there. I''m still new to a lot about DirectX so I appriciate you helping me try to figure this out.

Apparently the program is loading the files OK into the stream... so it''s finding them OK. It seems weird that the FileLoader would work on my desktop with a GeForce 4200 but not with the laptop which has the ATI Mobility 7500.
FieroAddict
FieroAddict
I''m still having difficulty with this. I just can''t figure out why a simple Texture.FromStream, or even Texture.FromFile fails on my laptop but works on my desktop. I haven''t had a chance to check it out on another desktop yet. Any other suggestions may be helpful. If you need more info to help me out, let me know.

Thanks.
turtle1776
turtle1776
Check the SDK docs on the problematic command. Usually you will see a list of possible errors, which are usually listed as constants. In Direct Draw, you might have DDERR_SURFACEBUSY for example, which is -2005532242.

Unfortunately, the SDK doesn''t list the error codes as numbers, just their constant equivalients (in my example, DDERR_SURFACEBUSY), while the error you get is usually expressed in its numeric format.

Somebody probably knows an easier way around this, but the way I do it is create a print-to-screen function that prints all of the possible constants (I cut and paste them from the SDK into the code). What you will get is the numeric equivalents of these constants. I them write these down for future reference. One of them should match your error.

I''d tell you what it is, but I haven''t run into that particular error code before.
FieroAddict
FieroAddict
Well, even if I copy over the contents of my "bin" folder to the laptop and run it, it crashes at the same point. I have the DirectX 9.0a dev runtime and release runtimes installed. Even tried installing the "end user" runtimes just to see if it would change anything. Using Visual Studio .NET 2002 with .NET framework 1.0. Both computers are setup the same as far as VS.NET and OS. Hmpf.
FieroAddict
FieroAddict
Also tried writing a test app from scratch on the laptop and it still crashes on all texture loading function calls except for:

TextureLoader.FromStream(dev,stream)
TextureLoader.FromFile(dev,"filename")

But those distort the image and aren''t useful in my app. Are the parameters in the texture loading functions device dependant?
FieroAddict
FieroAddict
OK, as my final test I made a Setup project out of my program (which included automatically the directx dlls that my project is dependant on...

I ran the installer on my desktop computer and then ran the program that was installed, worked just fine. Ran the installer on my Dad''s desktop, ran the installed program and it too crashed at the TextureLoader function. His machine has the .NET framework and DirectX 9.0a installed... what''s the deal!?

This is the error message that poped up from the executable, maybe someone could help desipher it for me:


See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
Error in the application.
-2005530518 (D3DERR_NOTAVAILABLE)
at Microsoft.DirectX.Direct3D.TextureLoader.FromStream(Device device, Stream stream, Int32 readBytes, Int32 width, Int32 height, Int32 mipLevels, Usage usage, Format format, Pool pool, Filter filter, Filter mipFilter, Int32 colorKey, ImageInformation& srcInformation, PaletteEntry[]& palette)
at Microsoft.DirectX.Direct3D.TextureLoader.FromStream(Device device, Stream stream, Int32 width, Int32 height, Int32 mipLevels, Usage usage, Format format, Pool pool, Filter filter, Filter mipFilter, Int32 colorKey)
at Defender.MainMenuObject.Init(Device& dev, Stream& image)
at Defender.Form1.LoadResources()
at Defender.Form1.Form1_Load(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
Assembly Version: 1.0.3300.0
Win32 Version: 1.0.3705.0
CodeBase: file:///c:/winnt/microsoft.net/framework/v1.0.3705/mscorlib.dll

----------------------------------------
Defender
Assembly Version: 1.0.1238.31155
Win32 Version: 1.0.1238.31155
CodeBase: file:///C:/Program%20Files/Default%20Company%20Name/Setup1/Defender.exe

----------------------------------------
System.Windows.Forms
Assembly Version: 1.0.3300.0
Win32 Version: 1.0.3705.0
CodeBase: file:///c:/winnt/assembly/gac/system.windows.forms/1.0.3300.0__b77a5c561934e089/system.windows.forms.dll

----------------------------------------
System
Assembly Version: 1.0.3300.0
Win32 Version: 1.0.3705.0
CodeBase: file:///c:/winnt/assembly/gac/system/1.0.3300.0__b77a5c561934e089/system.dll

----------------------------------------
System.Drawing
Assembly Version: 1.0.3300.0
Win32 Version: 1.0.3705.0
CodeBase: file:///c:/winnt/assembly/gac/system.drawing/1.0.3300.0__b03f5f7f11d50a3a/system.drawing.dll

----------------------------------------
Microsoft.DirectX.Direct3D
Assembly Version: 1.0.900.0
Win32 Version: 5.3.0000000.900 built by: DIRECTX
CodeBase: file:///C:/Program%20Files/Default%20Company%20Name/Setup1/Microsoft.DirectX.Direct3D.DLL

----------------------------------------
Microsoft.DirectX
Assembly Version: 1.0.900.0
Win32 Version: 5.3.0000000.900 built by: DIRECTX
CodeBase: file:///C:/Program%20Files/Default%20Company%20Name/Setup1/Microsoft.DirectX.DLL

----------------------------------------
Microsoft.DirectX.DirectInput
Assembly Version: 1.0.900.0
Win32 Version: 5.3.0000000.900 built by: DIRECTX
CodeBase: file:///C:/Program%20Files/Default%20Company%20Name/Setup1/Microsoft.DirectX.DirectInput.DLL

----------------------------------------
Microsoft.VisualC
Assembly Version: 7.0.3300.0
Win32 Version: 7.00.9466
CodeBase: file:///c:/winnt/assembly/gac/microsoft.visualc/7.0.3300.0__b03f5f7f11d50a3a/microsoft.visualc.dll

----------------------------------------
Microsoft.DirectX.Direct3DX
Assembly Version: 1.0.900.0
Win32 Version: 5.3.0000000.900 built by: DIRECTX
CodeBase: file:///C:/Program%20Files/Default%20Company%20Name/Setup1/Microsoft.DirectX.Direct3DX.DLL

----------------------------------------

************** JIT Debugging **************
To enable just in time (JIT) debugging, the config file for this
application or machine (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the machine
rather than being handled by this dialog.


Same error code # as my laptop was giving me, except this time it gives me D3DERR_NOTAVAILABLE. What does this mean?
FieroAddict
FieroAddict
OK! I found that if I replace Usage.Dynamic with 0 everything works as it should. Maybe someone could fill me in with what the zero represents?
reillyhead
reillyhead
my GUESS it that you were trying to create the texture as a dynamic texture, which was supported on your desktop, but not your laptop.
Dynamic textures are not well supported on older hardware. This would explain why the texture surface was ''not available''.

So, by setting the usage to 0, you are not trying to create the texture as dynamic.

Later
Marc


Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.