• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2020 The Dawn Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef UTILS_GLFWUTILS_H_
16 #define UTILS_GLFWUTILS_H_
17 
18 #include "dawn/webgpu_cpp.h"
19 
20 #include <memory>
21 
22 struct GLFWwindow;
23 
24 namespace utils {
25 
26     // Adds all the necessary glfwWindowHint calls for the next GLFWwindow created to be used with
27     // the specified backend.
28     void SetupGLFWWindowHintsForBackend(wgpu::BackendType type);
29 
30     // Does the necessary setup on the GLFWwindow to allow creating a wgpu::Surface with it and
31     // calls `instance.CreateSurface` with the correct descriptor for this window.
32     // Returns a null wgpu::Surface on failure.
33     wgpu::Surface CreateSurfaceForWindow(wgpu::Instance instance, GLFWwindow* window);
34 
35     // Use for testing only. Does everything that CreateSurfaceForWindow does except the call to
36     // CreateSurface so the descriptor can be modified for testing.
37     std::unique_ptr<wgpu::ChainedStruct> SetupWindowAndGetSurfaceDescriptorForTesting(
38         GLFWwindow* window);
39 
40 }  // namespace utils
41 
42 #endif  // UTILS_GLFWUTILS_H_
43