예제 #1
0
// this is the entry point for any Windows program
// Note: It is a form of main(...), but made for Windows applications (that is, non-console applications).
// Note: I had to change the project properties->linker->system->subsystem from "Console" to "Windows" to get it to compile correctly.
int WINAPI WinMain(
   HINSTANCE h_instance,
   HINSTANCE h_prev_instance,
   LPSTR lp_cmd_line,
   int n_show_cmd)
{
   // this will be the handle for the window (hence the acronym)
   HWND handle_window;

   // this struct will hold information for the window class
   // Note: WNDCLASS is depreciated.  It was superseded by WNDCLASSEX, so use that instead.
   WNDCLASSEX wc;
   ZeroMemory(&wc, sizeof(WNDCLASSEX));

   // fill the struct with the needed information
   wc.cbSize = sizeof(WNDCLASSEX);           // tell the struct how big it is (??why doesn't it know how big itself is??)
   wc.style = CS_HREDRAW | CS_VREDRAW;       // redraw on vertical and horizontal resizing
   wc.lpfnWndProc = my_window_proc;          // this is the function that the window class calls when it gets a message from windows (keystroke, mouse movement, etc.)
   wc.hInstance = h_instance;                // the handle to our application instance
   wc.hCursor = LoadCursor(NULL, IDC_ARROW); // don't give it an application handle that stores a pointer graphic (we don't have one anyway), and give it the default mouse pointer
   //wc.hbrBackground = (HBRUSH)COLOR_WINDOW;  // give the window class's background the default window color
   wc.lpszClassName = L"WindowClass1";       // give the window class a name (when creating a window with this window class, you must specify this string exactly)

   // register the window class so that Windows can use it to create windows
   RegisterClassEx(&wc);

   // calculate the size of the window based on how big we want the client (the space within the window borders) to be
   // Note: This "adjust window rectangle" function conveniently calculates window dimensions given information about
   // the dimensions of the size and origin of the client area, the window style, and whether the window has menus or 
   // not (FALSE in this case).  The last item is some information about extended window styles for "Extended Window".
   // We are not using any such styles, so we provide NULL.
   RECT window_rectangle = { 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT };
   AdjustWindowRectEx(&window_rectangle, WS_OVERLAPPEDWINDOW, FALSE, NULL);

   // create the window on the screen
   handle_window = CreateWindowEx(
      NULL,                               // do not use any extra style options provided by "Extended Window"
      L"WindowClass1",                    // name of the window class that this window will be an instance of (must match an existing window class name)
      L"Our First Direct3D Program",      // displayed on the window's title bar
      WS_OVERLAPPEDWINDOW,                // this option specifies several standard features and make a basic window style (check out the #define for more details)
      300,                                // x-position of the window relative to the desktop
      300,                                // y-position of the window relative to the desktop
      window_rectangle.right - window_rectangle.left,    // width of the window (origin at left, increases left to right)
      window_rectangle.bottom - window_rectangle.top,    // height of the window (origin at top, increases top to bottom)
      NULL,                               // we have no parent window, so do not provide a handle to a window
      NULL,                               // we are not using menus, so do not provide a handle to a menu
      h_instance,                         // application handle determined by Windows when the program starts; identifies this window with our application
      NULL);                              // used with multiple windows, which we are not using

   // display the window on the screen
   ShowWindow(handle_window, n_show_cmd);

   // set up and initialize Direct3D
   init_d3d(handle_window);


   // enter the main loop

   // this struct holds Windows event messages
   MSG event_message = { 0 };

   // enter the loop and stay here forever
   while (true)
   {
      // check to see if any messages are waiting in the queue, and remove them from the queue if you find them
      if (PeekMessage(&event_message, NULL, 0, 0, PM_REMOVE))
      {
         // translate keystroke messages into the right format, then send them to the "window processing" function for handling
         TranslateMessage(&event_message);
         DispatchMessage(&event_message);

         // check to see if it is time to quite, and if it is, break out of the loop and return from main
         // Note: The window will not send a WM_QUIT message.  It is called when the application (in this
         // case, our code) calls the PostQuitMessage(...) function, which in turn will only be called if
         // the message was WM_DESTROY.
         // Previously, we used the return value of GetMessage(...) as the condition in the while(...) 
         // loop, and that function would return false if it got a WM_QUIT message.  Now the loop 
         // condition is always true, so we need to manually check for WM_QUIT and stop the application
         // if we see it.
         if (WM_QUIT == event_message.message)
         {
            break;
         }
      }

      // render a frame, regardless of whether a message was handled or not
      render_frame();
   }

   clean_d3d();

   // return this part (??which part??) of the WM_QUIT message to Windows
   return event_message.wParam;
}
예제 #2
0
void  D3D12Render::v_init()
{
	init_d3d();
	init_size();
}