• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 Google, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef SHELL_WIN32_H
18 #define SHELL_WIN32_H
19 
20 #include <windows.h>
21 #include "Shell.h"
22 
23 class ShellWin32 : public Shell {
24 public:
25     ShellWin32(Game &game);
26     ~ShellWin32();
27 
28     void run();
29     void quit();
30 
31 private:
32 
33     PFN_vkGetInstanceProcAddr load_vk();
34     bool can_present(VkPhysicalDevice phy, uint32_t queue_family);
35 
36     void create_window();
37     VkSurfaceKHR create_surface(VkInstance instance);
38 
window_proc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)39     static LRESULT CALLBACK window_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
40     {
41         ShellWin32 *shell = reinterpret_cast<ShellWin32 *>(GetWindowLongPtr(hwnd, GWLP_USERDATA));
42 
43         // called from constructor, CreateWindowEx specifically.  But why?
44         if (!shell)
45             return DefWindowProc(hwnd, uMsg, wParam, lParam);
46 
47         return shell->handle_message(uMsg, wParam, lParam);
48     }
49     LRESULT handle_message(UINT msg, WPARAM wparam, LPARAM lparam);
50 
51     HINSTANCE hinstance_;
52     HWND hwnd_;
53 
54     HMODULE hmodule_;
55 };
56 
57 #endif // SHELL_WIN32_H
58