Sign in to follow this  

Gettings D3DERR_INVALIDCALL

This topic is 2665 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello,

I'm using vb.net with SlimDX, and have a problem. When creating the device, it gives me this error:

SlimDX.Direct3D9.Direct3D9Exception: D3DERR_INVALIDCALL: Invalid call (-2005530516)
at SlimDX.Result.Throw[T](Object dataKey, Object dataValue)
at SlimDX.Result.Record[T](Int32 hr, Boolean failed, Object dataKey, Object dataValue)
at SlimDX.Direct3D9.Device..ctor(Direct3D direct3D, Int32 adapter, DeviceType deviceType, IntPtr controlHandle, CreateFlags createFlags, PresentParameters[] presentParameters)
at SmallGame.Form1.initializeGraphics() in C:\Users\Rene\Documents\Visual Studio 2010\Projects\SmallGame\SmallGame\Form1.vb:line 24
at SmallGame.Form1.Form1_Load(Object sender, EventArgs e) in C:\Users\Rene\Documents\Visual Studio 2010\Projects\SmallGame\SmallGame\Form1.vb:line 38

This is my code:
    Public Sub initializeGraphics()
DEVICE_PARAMETERS = New PresentParameters
DEVICE_PARAMETERS.BackBufferCount = 1
DEVICE_PARAMETERS.BackBufferFormat = SlimDX.Direct3D9.Format.X8B8G8R8
DEVICE_PARAMETERS.BackBufferHeight = Screen.PrimaryScreen.Bounds.Height
DEVICE_PARAMETERS.BackBufferWidth = Screen.PrimaryScreen.Bounds.Width
DEVICE_PARAMETERS.Windowed = True
DEVICE_PARAMETERS.SwapEffect = SwapEffect.Copy
ENGINE = New Direct3D
DEVICE = New Device(ENGINE, 0, DeviceType.Hardware, Me.Handle, CreateFlags.HardwareVertexProcessing, DEVICE_PARAMETERS)
End Sub



I've searched, and found some other topics with the same problem. This one. seems to have the same problem. Thier sulution was to call "ZeroMemory" on the DEVICE_PAMAMETERS, after doing "= New PresentParameters", but I don't know how to get the handle of an variable in vb.net.

Please help me,
-René

Share this post


Link to post
Share on other sites
I can't do VB.Net, but I can tell you what you can do instead of ZeroMemory.
Just search in the documentation for the DEVICE_PARAMETERS-Struct and set every single variable you see there to Zero.
ZeroMemory does basically the same.

Don't blame me if there is something similar to ZeroMemory in VB.Net, I've never done it. ;)

Share this post


Link to post
Share on other sites
Quote:
Original post by mind in a box
I can't do VB.Net, but I can tell you what you can do instead of ZeroMemory.
Just search in the documentation for the DEVICE_PARAMETERS-Struct and set every single variable you see there to Zero.
ZeroMemory does basically the same.

Don't blame me if there is something similar to ZeroMemory in VB.Net, I've never done it. ;)


Doesn't make a lot of sense... There is an ZeroMemory function in vb.net, but as I said, I just don't know how to get the handle/address of the variable.
    <DllImport("kernel32.dll")> _
Public Shared Sub ZeroMemory(ByVal addr As IntPtr, ByVal size As IntPtr)
End Sub

Share this post


Link to post
Share on other sites
I'm not a VB person, either, but it's probably something like:

ZeroMemory(DEVICE_PARAMETERS, Size)

Size is a bit more difficult and I'm just parroting what I found by googling. This might work:

Size = System.Runtime.InteropServices.Marshal.SizeOf(DEVICE_PARAMETERS)

Share this post


Link to post
Share on other sites
Quote:
Original post by Buckeye
I'm not a VB person, either, but it's probably something like:

ZeroMemory(DEVICE_PARAMETERS, Size)

Size is a bit more difficult and I'm just parroting what I found by googling. This might work:

Size = System.Runtime.InteropServices.Marshal.SizeOf(DEVICE_PARAMETERS)


Well, this is the code I have:
ZeroMemory(DEVICE_PARAMETERS, Marshal.SizeOf(DEVICE_PARAMETERS))


But the problem is, the first variable has to be an IntPtr (Or just be the handle of the variable), but idk how to get that.

Share this post


Link to post
Share on other sites
Did you find anything useful when you googled? I'm assuming you're working to try to solve the problem, also. I got 106,000 hits for "vb.net intptr handle variable."

This one seems to have some info.

If you're not familiar with VB, then perhaps the easiest approach is what mind in a box suggests.

Share this post


Link to post
Share on other sites
Quote:
Original post by Buckeye
Did you find anything useful when you googled? I'm assuming you're working to try to solve the problem, also. I got 106,000 hits for "vb.net intptr handle variable."

This one seems to have some info.

If you're not familiar with VB, then perhaps the easiest approach is what mind in a box suggests.


I have not found the article you have right there. I am very familiar to VB.Net, and have implemented it like so:
        DEVICE_PARAMETERS = New SlimDX.Direct3D9.PresentParameters
Dim VarHandle As IntPtr = GCHandle.ToIntPtr(GCHandle.Alloc(DEVICE_PARAMETERS))
ZeroMemory(VarHandle, Marshal.SizeOf(VarHandle))


It does however not work.
I have also tried what MindInABox said, and that also does not work. Keeps returning the same error.

Share this post


Link to post
Share on other sites
First of all, ZeroMemory is a macro. You won't be able to P/Invoke it.

Second, no where is it indicated that clearing out the memory is the problem. All you have is an InvalidCall result, which is so generic that it can mean anything from an invalid parameter to your graphics adapter not supporting a given setting. All types get their memory cleared in .NET anyway, so ZeroMemory isn't going to help you.

Your actual problem is probably either an invalid back buffer format, or that your graphics card doesn't support the chosen settings. Enable the debug runtimes and see if Direct3D gives any additional information about what is going wrong.

Share this post


Link to post
Share on other sites

This topic is 2665 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this