Jump to content


Very annoying DirectX error


8 replies to this topic

#1 cypher543

    Member

  • Members
  • PipPip
  • 74 posts

Posted 03 May 2006 - 09:18 PM

I'm finally learning to work with DirectX... but the experience has not been good so far. I can't even get the device to start! I get the following error when I try to run my application:

Quote

Code: -2005530516
Message: Error in the application.
String: D3DERR_INVALIDCALL
I am using Visual Basic .NET 2005 Express and DirectX 9.0c. The code for my StartDirectX() method is below:
        If deviceCaps.DeviceCaps.SupportsHardwareTransformAndLight Then

            newFlags = CreateFlags.HardwareVertexProcessing

        Else

            newFlags = CreateFlags.SoftwareVertexProcessing

        End If


        If deviceCaps.DeviceCaps.SupportsPureDevice And newFlags = CreateFlags.HardwareVertexProcessing Then

            newFlags &= CreateFlags.PureDevice

        End If


        Dim presentParams As New PresentParameters

        presentParams.SwapEffect = SwapEffect.Discard

        presentParams.Windowed = True


        d3dDevice = New Device(defaultAdapter, DeviceType.Hardware, ContagionForm.Handle.ToInt32, newFlags, presentParams)
All of my variables have been defined:
Dim d3dDevice As Device

Dim defaultAdapter As Integer = Manager.Adapters.Default.Adapter

Dim deviceCaps As Caps = Manager.GetDeviceCaps(defaultAdapter, DeviceType.Hardware)

Dim newFlags As CreateFlags
So what is the problem? I can't believe DirectX doesn't give any more detail than "Error in the application"! Any ideas?

BTW, I did search the forums (using the error code as the string) before I posted, but the only topic I found that seemed to be relevant went off topic into a discussion about a college professor and never provided a clear answer to the problem.

#2 Jare

    Valued Member

  • Members
  • PipPipPip
  • 247 posts

Posted 03 May 2006 - 10:40 PM

cypher543 said:

newFlags &= CreateFlags.PureDevice
That might be it. Not really sure but looks like you're clearing everything except the PureDevice bit, when you probably want to SET the bit.

#3 cypher543

    Member

  • Members
  • PipPip
  • 74 posts

Posted 03 May 2006 - 11:18 PM

I thought that in VB.NET, adding a & before a = meant "append to the end of the variable". I just converted this from some C# code, so it may not be entirely accurate. :(

#4 Reedbeta

    DevMaster Staff

  • Administrators
  • 4979 posts
  • LocationBellevue, WA

Posted 03 May 2006 - 11:54 PM

Well, in C#, that does a bitwise AND of the left-hand-side with the right-hand-side and assigns it to the lhs. I don't know if &= has a meaning in VB, but what you probably want is 'newFlags = newFlags Or CreateFlags.PureDevice'. That will set the PureDevice bit within the newFlags bitfield.
reedbeta.com - developer blog, OpenGL demos, and other projects

#5 .oisyn

    DevMaster Staff

  • Moderators
  • 1822 posts

Posted 04 May 2006 - 12:06 AM

In VB, the & operator is used to concatenate strings. Don't know if they also work for enum-like types, but it seems to compile anyway :).
C++ addict
-
Currently working on: the 3D engine for Tomb Raider.

#6 cypher543

    Member

  • Members
  • PipPip
  • 74 posts

Posted 04 May 2006 - 06:42 PM

I changed it to:

Quote

newFlags = newFlags Or CreateFlags.PureDevice
Everything compiles now, but I just get a window with the image of whatever is behind it burned into the form. :( I have a render loop that is supposed the clear the screen to green.
    Public Sub Render()
        d3dDevice.Clear(ClearFlags.Target & ClearFlags.ZBuffer, Color.FromArgb(255, 0, 255, 0), 1.0F, 0)
        d3dDevice.BeginScene()

        ' Render stuff here

        d3dDevice.EndScene()
        d3dDevice.Present()
    End Sub
Then, Render() is called from the form's paint event.

#7 Jare

    Valued Member

  • Members
  • PipPipPip
  • 247 posts

Posted 04 May 2006 - 07:49 PM

Use the Debug runtime and see what errors it reports.

#8 Mjolnir

    Member

  • Members
  • PipPip
  • 42 posts

Posted 04 May 2006 - 08:20 PM

cypher543 said:

ClearFlags.Target & ClearFlags.ZBuffer
ClearFlags.Target Or ClearFlags.ZBuffer :sneaky: ?

#9 cypher543

    Member

  • Members
  • PipPip
  • 74 posts

Posted 04 May 2006 - 10:10 PM

Jare: It doesn't give me any errors...
Mjolnir: Well, that fixed it. Should have figured that out... oh well. Thanks!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users