XNA Creators Club Online
Page 1 of 1 (7 items)
Sort Posts: Previous Next

GetAdadpterDisplayMode not work why !!!§§§

Last post 08-25-2008 7:16 PM by Belkace Dj. 6 replies.
  • 08-25-2008 7:55 AM

    GetAdadpterDisplayMode not work why !!!§§§

    welcome

     I Have a Classs Called MyDevice I Want To Create Direct3D9 Device but wher i Debug The Project The Pc Show A Message

    Say :

     

    Unhandled exception at 0x004114b7 in Direct3d Device.exe: 0xC0000005: Access violation reading location 0x00000000.

     

    I  Use Viusal C++ 2005 Pro

     

    The Code Is

     

    void MyDevice::BuildDeviceParameters()
    {
        
        ZeroMemory ( &Parameters , sizeof (D3DPRESENT_PARAMETERS));

        Direct3D->GetAdapterDisplayMode ( D3DADAPTER_DEFAULT , &DisplayMode );
        

        Parameters.AutoDepthStencilFormat = DisplayMode.Format ;
        Parameters.BackBufferCount = 3 ;
        Parameters.BackBufferFormat = DisplayMode.Format ;
        Parameters.BackBufferHeight = DisplayMode.Height ;
        Parameters.BackBufferWidth = DisplayMode.Width ;
        Parameters.EnableAutoDepthStencil = TRUE ;
        Parameters.hDeviceWindow = hwnd ;
        Parameters.SwapEffect = D3DSWAPEFFECT_DISCARD ;
        Parameters.Windowed = TRUE ;


        
    }

     

    remark

    There Is No Error Whene I Build The Project 

     


  • 08-25-2008 9:25 AM In reply to

    Re: GetAdadpterDisplayMode not work why !!!§§§

    That type of error message usually means you're using an uninitialised pointer, its pointing to location 0x0, a null pointer. Make sure Direct3D is created before you use it.

  • 08-25-2008 11:40 AM In reply to

    Re: GetAdadpterDisplayMode not work why !!!§§§

    Thanks

    your idea  works

     But

    The error Go To The Reder Function please help §§§!!!!

    Code:

     void MyDevice::Render()
    {
        
        Device->Clear ( 0 , NULL , D3DCLEAR_TARGET , D3DCOLOR_XRGB(0,0,255) , 1.0f , 0);

        if ( SUCCEEDED ( Device->BeginScene ()))
        {
            Device->EndScene ();
        }
        Device->Present ( NULL , NULL , NULL , NULL );
        
    }


  • 08-25-2008 2:13 PM In reply to

    Re: GetAdadpterDisplayMode not work why !!!§§§

    Theres nothing wrong with the function call. It could be something else.

    One thing it could be, looking at your D3DPRESENT_PARAMETERS you're requesting a depth-stencil surface but you haven't specified its format, try setting its AutoDepthStencilFormat to something like D3DFMT_D16 or D3DFMT_D24X8. Or since you're just clearing the target you can set EnableAutoDepthStencil to FALSE.

  • 08-25-2008 2:43 PM In reply to

    Re: GetAdadpterDisplayMode not work why !!!§§§

    i try setting its AutoDepthStencilFormat to something like D3DFMT_D16 or D3DFMT_D24X8.set EnableAutoDepthStencil to FALSE.

     

    but i Find The Folowing error

     

    First-chance exception at 0x00412122 in Direct3d Device.exe: 0xC0000005: Access violation reading location 0x00000000.

  • 08-25-2008 3:23 PM In reply to

    Re: GetAdadpterDisplayMode not work why !!!§§§

    Those access violations are to do with uninitialised pointers. Basically something like:

    struct C { int i; }

    C* ptr = 0;
    ptr->i = 3;           // Access violation, ptr points to 0x0

    you first need to set the pointer like:

    C* ptr = new C;
    ptr->i = 3;           // OK, we're pointing to something

    Make sure that IDirect3D9 and IDirect3DDevice9 are created before you call any of their methods. Also make sure that you've created the window and called ShowWindow() and UpdateWindow() before you create the IDirect3DDevice9.

  • 08-25-2008 7:16 PM In reply to

    Re: GetAdadpterDisplayMode not work why !!!§§§

    Thanks

     

    Now It Work

     

    Very Thanks


Page 1 of 1 (7 items) Previous Next
var gDomain='m.webtrends.com'; var gDcsId='dcschd84w10000w4lw9hcqmsz_8n3x'; var gTrackEvents=1; var gFpc='WT_FPC'; /*<\/scr"+"ipt>");} /*]]>*/
DCSIMG