DXUT and the MainLoop

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

    • DXUT and the MainLoop

      Fantastic book Mike, I've skimmed the book in its entirity once, and I'm reading it again now in hopes of trying to implement the DXUT architecture for the first time. Due to the lack of reference and tutorials on the subject out there outside of the examples of GCC and MSDN (which currently focuses on dx10 function calls).

      My current goal is displaying a blank window with the traditional blue background rendering in directx.

      C Source Code

      1. #include "DXUT.h"
      2. #include "DXUTmisc.h"
      3. //int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
      4. INT WINAPI _WinMain( HINSTANCE hInstance, HINSTANCE hPrevIstance, LPSTR lpCmdLine, INT nCmdShow)
      5. {
      6. //DXUTInit( true, true );
      7. //DXUTCreateWindow( L"Example" );
      8. //DXUTCreateDevice( true, 640, 480 );
      9. // Custom main loop
      10. HWND hWnd = 0;//DXUTGetHWND();
      11. BOOL bGotMsg;
      12. MSG msg;
      13. msg.message = WM_NULL;
      14. PeekMessage( &msg, NULL, 0U, 0U, PM_NOREMOVE );
      15. while( WM_QUIT != msg.message )
      16. {
      17. // Use PeekMessage() so we can use idle time to render the scene
      18. bGotMsg = ( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) != 0 );
      19. if( bGotMsg )
      20. {
      21. // Translate and dispatch the message
      22. if( 0 == TranslateAccelerator( hWnd, NULL, &msg ) )
      23. {
      24. TranslateMessage( &msg );
      25. DispatchMessage( &msg );
      26. }
      27. }
      28. else
      29. {
      30. // Render a frame during idle time (no messages are waiting)
      31. //DXUTMainLoop();
      32. //DXUTRender3DEnvironment();
      33. }
      34. }
      35. return 0;//DXUTGetExitCode();
      36. }
      Display All


      I've been stripping away example code in order to simply get it to work but with no luck. I'm getting an odd linker error "Error 1 error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup MSVCRTD.lib"

      I did some research and some of the suggestions where to turn on Multi-byte instead of Unicode which is preffered by the dxut.h header. I'm a little stuck right now.

      Thank you.
      http://www.michaelkofman.com/
    • How did you set up your project? Is it a console application, or a Win32 application? My guess is that you set it up as a console application, which looks for main() instead of WinMain(). If this is the case, try setting up a new project as a Win32 application with this code and see if it works. Also, Draco is right, you'll need WinMain() as opposed to _WinMain().

      Let me know whether or not this works.

      -Rez
    • It's an empty win32 application. It isn't console a console I'm afraid. I've even made another proect just to be certain.

      PS: Thank you for your help, I'm constantly watching this thread for updates and I appreciete it.
      http://www.michaelkofman.com/
    • I created yet another new project, this time on a different machine the code compiled just fine. The tmainCRTStartup error is still a mystery to me. But moving past it, I'm begin by including

      C Source Code

      1. #include "DXUT.h"
      2. #include "DXUTmisc.h"

      Still compiled just fine.
      I proceed with a DXUTInit( true, true ) call and I recieve another linker error. Does DXUTInit require a callback function? I can not seem to find the definition for DXUTInit anywhere inside dxut.h
      http://www.michaelkofman.com/
    • Are you remembering to include the DXUT source files (cpp files) in your project? It sounds like it's not finding the code for DXUTInit().

      -Rez