• R/O
  • HTTP
  • SSH
  • HTTPS

sdl2referencejp: Commit

SDL2.0の日本語リファレンスマニュアル


Commit MetaInfo

Revision3d66837232f78bb0f55a1bb2c4f2fc1e7922196e (tree)
Time2019-06-22 21:22:30
Authormaruhiro <maruhiro@brid...>
Commitermaruhiro

Log Message

SDL_Vulkan_GetDrawableSize サンプルコードを追加 https://wiki.libsdl.org/SDL_Vulkan_GetDrawableSize?action=diff&rev1=2&rev2=4

Change Summary

Incremental Difference

--- a/SDL_Vulkan_GetDrawableSize.html
+++ b/SDL_Vulkan_GetDrawableSize.html
@@ -25,9 +25,28 @@
2525 <p>
2626 <code>
2727 <pre>
28+// C++17ならばstd::clamp()を使う
29+#define CLAMP(x, lo, hi) ((x) < (lo) ? (lo) : (x) > (hi) ? (hi) : (x))
30+
31+SDL_Window *window;
32+VkSurfaceKHR surface;
33+VkPhysicalDevice physicalDevice;
34+
35+// window = SDL_CreateWindow(...);
36+if (!SDL_Vulkan_CreateSurface(window, instance, &surface)) {
37+ // handle error
38+}
39+// physicalDevice = ...;
40+
41+// ...
42+
43+VkSurfaceCapabilitiesKHR capabilities;
44+vkGetPhysicalDeviceSurfaceCapabilitiesKHR(physicalDevice, surface, &capabilities);
2845 int width;
2946 int height;
3047 SDL_Vulkan_GetDrawableSize(window, &width, &height);
48+width = CLAMP(width, capabilities.minImageExtent.width, capabilities.maxImageExtent.width);
49+height = CLAMP(height, capabilities.minImageExtent.height, capabilities.maxImageExtent.height);
3150 </pre>
3251 </code>
3352 <h2>詳細</h2>
Show on old repository browser