Home | History | Annotate | Download | only in smoke
      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     PFN_vkGetInstanceProcAddr load_vk();
     33     bool can_present(VkPhysicalDevice phy, uint32_t queue_family);
     34 
     35     void create_window();
     36     VkSurfaceKHR create_surface(VkInstance instance);
     37 
     38     static LRESULT CALLBACK window_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
     39         ShellWin32 *shell = reinterpret_cast<ShellWin32 *>(GetWindowLongPtr(hwnd, GWLP_USERDATA));
     40 
     41         // called from constructor, CreateWindowEx specifically.  But why?
     42         if (!shell) return DefWindowProc(hwnd, uMsg, wParam, lParam);
     43 
     44         return shell->handle_message(uMsg, wParam, lParam);
     45     }
     46     LRESULT handle_message(UINT msg, WPARAM wparam, LPARAM lparam);
     47 
     48     HINSTANCE hinstance_;
     49     HWND hwnd_;
     50 
     51     HMODULE hmodule_;
     52 };
     53 
     54 #endif  // SHELL_WIN32_H
     55