m_Renderer NULL pointer

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • m_Renderer NULL pointer

      Hey, this is my first post, woo!

      I got the GCC4 code last night, and followed the instructions to build and launch the Teapot Wars game. Overall it worked great except for one issue.

      When debugging, the game window attempts to launch on my second monitor which is set up in portrait mode at 1050x1680 (16:10) resolution. But for some reason it ends up calling OnD3D11DestroyDevice() almost immediately. And it throws the following exception at line 1131 of GameCode.cpp, which is obviously a null pointer issue. m_Renderer has not been initialized yet.

      Unhandled exception at 0x002bd877 in TeapotWars_2010Win32Debug.exe: 0xC0000005: Access violation reading location 0x00000000.


      After walking through the code, and delving into DXUT.cpp, I found that in the DXUTChangeDevice() function on line 2432 the function decides that the size and position of the window would not work, so it recursively calls itself again, and in doing so attempts to cleanup anything it has already done by destroying the window. And so it calls our custom OnD3D11DestroyDevice() before m_Renderer has been initialized.

      As a temporary work around, I added the following to OnD3D11DestroyDevice(), which fixes my issue and lets me launch the game. I'm just not sure if that is the best solution.

      if(g_pApp->m_Renderer != NULL){
      g_pApp->m_Renderer->VShutdown();
      }
    • RE: m_Renderer NULL pointer

      That sounds like a good idea to me - especially if it doesn't cause any unusual side effects in a single monitor setup. Thanks for posting the workaround!
      Mr.Mike
      Author, Programmer, Brewer, Patriot
    • That seems like a totally valid fix. I've tested it on a couple different monitor configurations here and it works just fine. I'm checking it into google code.

      -Rez