setting position of sphere

Hi! I am using DirectX 9.0 and VC++ .NET. I am trying to create a sphere (for collsion detection) but the application crashes on a particular line. The screen goes black and I have to use "shift + F5" to recover. I can't understand the reason as the same function (SetTransform) is working fine in another file of the same project. Please somebody help me. I am attaching the code and the line is marked in green. Following is the function (code) :-

void sphere::setPositionSphere()

{

D3DXMATRIX matWorld, matScale;

D3DXMatrixIdentity( &matWorld );

D3DXMatrixScaling( &matScale, 0.5f, 0.5f, 0.5f );

D3DXMatrixTranslation( &matWorld, countTarget/10, -0.5, 0.5 );

D3DXMatrixMultiply( &matWorld, &matScale, &matWorld );

D3DDevice->SetTransform( D3DTS_WORLD, &matWorld );

return;

}

Thank you.



Answer this question

setting position of sphere

  • Teenprogrammer

    Yes, but the error lookup tool says

    -858994360 = 0xccccc948 hex value, while 0xccccc948 = 3435972936 decimal ...


    So it seems like the -858994360 is an invalid code.


    after

    hr = D3DDevice->SetTransform(D3DTS_WORLD, &matWorld);

     


    u could write


    switch(hr)
    {
        case D3DERR_INVALIDCALL:
            ...
    }

     



    if u look at the SDK docs, this is the only error code returned by this method.

  • dgavarin

    checked the code with VS Error lookup tool ..... value comes up to be 0xccccc948 but the error message is blank. Sad
  • Abu-Bakr

    Have u looked what the return code of the function is
    i u have to do shift+f5 i supose u are running in fullscreen mode.
    try running in windowed mode and put some breaklines so u can see whats happening.




    HRESULT hr;

    hr = D3DDevice->SetTransform(D3DTS_WORLD, &matWorld);


     


    .... check value of hr and compare to return codes in the sdk docs ... that might give u an answer.

  • gddscy

    > The value of "hr" is shown as "-858994360". Any ideas

    You can use TCHAR * DXGetErrorString9(HRESULT hr) to convert an HRESULT value into a much more helpful string.  Look in the SDK documentation for more information on DXGetErrorString9.  You will need to include dxerr9.h and dxerr9.lib in your project.

  • RVRKID

    Folowing is the initialization code :-

    D3DPRESENT_PARAMETERS D3DParams;

    D3DDISPLAYMODE D3DDisplayMode;
    D3DNew = Direct3DCreate9( D3D_SDK_VERSION );

    D3DNew->GetAdapterDisplayMode(D3DADAPTER_DEFAULT,&D3DDisplayMode);
    ZeroMemory(&D3DParams,
    sizeof(D3DParams));

    D3DParams.Windowed = TRUE;
    D3DParams.SwapEffect = D3DSWAPEFFECT_DISCARD;
    D3DParams.BackBufferFormat = D3DDisplayMode.Format;
    D3DParams.EnableAutoDepthStencil = TRUE;
    D3DParams.AutoDepthStencilFormat = D3DFMT_D16;
    D3DParams.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;

    D3DNew->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hWnd,
    D3DCREATE_SOFTWARE_VERTEXPROCESSING,&D3DParams,&D3DDevice);


    Is there something wrong with it


  • XOR42

    I think this function does the same as the DXError Lookup tool at the SDK.
    But the return value seems to be invalid ...

    Its a decimal error code, so when u lookup the error, it aint found. The error code entered is different from the error code returned in the tool


    HRESULT: 0xccccc948 (3435972936)
    Name: Unknown
    Description: n/a
    Severity code: Failed
    Facility Code: Unknown (3276)
    Error Code: 0xc948 (51528)



    ... i just noticed the Win32 Error lookup tool disapeared from VS in VS2K beta2.
    If it is a windows error, that one might return the correct information.

  • coolazeem

    I am not using the DXUT library.
  • ram alisam

    Thanks for the help.

    Changing the application to windowed mode helped me to find the message that is coming up. The error is "access violation" in some memory address. The memory address belongs to "D3DDevice".

    Also, I cant find out any other function using the D3DDevice simultaneously. The value of "hr" is shown as "-858994360". Any ideas


  • alejoespinosa

    No really, but if there is an access violation error on the D3DDevice, it migh not been initialized correctly.


  • Rich Tebb

    You most likely have an invalid Device.  If you're using the DXUT library, then you should set a callback for the DXUTSetCallbackDeviceLost.

    Look at how it is solved in the "Simple Sample" (C++) in the DirectX Sample Browser.



  • setting position of sphere