2010-09-07 15:34:51 +00:00
|
|
|
//========================================================================
|
2015-01-26 02:16:43 +00:00
|
|
|
// Context creation and information tool
|
2016-11-21 15:23:59 +00:00
|
|
|
// Copyright (c) Camilla Löwy <elmindreda@glfw.org>
|
2010-09-07 15:34:51 +00:00
|
|
|
//
|
|
|
|
// This software is provided 'as-is', without any express or implied
|
|
|
|
// warranty. In no event will the authors be held liable for any damages
|
|
|
|
// arising from the use of this software.
|
|
|
|
//
|
|
|
|
// Permission is granted to anyone to use this software for any purpose,
|
|
|
|
// including commercial applications, and to alter it and redistribute it
|
|
|
|
// freely, subject to the following restrictions:
|
|
|
|
//
|
|
|
|
// 1. The origin of this software must not be misrepresented; you must not
|
|
|
|
// claim that you wrote the original software. If you use this software
|
|
|
|
// in a product, an acknowledgment in the product documentation would
|
|
|
|
// be appreciated but is not required.
|
|
|
|
//
|
|
|
|
// 2. Altered source versions must be plainly marked as such, and must not
|
|
|
|
// be misrepresented as being the original software.
|
|
|
|
//
|
|
|
|
// 3. This notice may not be removed or altered from any source
|
|
|
|
// distribution.
|
|
|
|
//
|
|
|
|
//========================================================================
|
|
|
|
|
2021-08-24 23:18:03 +00:00
|
|
|
#define GLAD_GL_IMPLEMENTATION
|
2019-04-14 15:34:38 +00:00
|
|
|
#include <glad/gl.h>
|
2021-08-24 23:18:03 +00:00
|
|
|
#define GLAD_VULKAN_IMPLEMENTATION
|
2019-04-14 15:34:38 +00:00
|
|
|
#include <glad/vulkan.h>
|
2019-05-24 15:17:15 +00:00
|
|
|
#define GLFW_INCLUDE_NONE
|
2013-05-22 20:46:34 +00:00
|
|
|
#include <GLFW/glfw3.h>
|
2010-09-07 15:34:51 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2019-05-19 17:10:35 +00:00
|
|
|
#include <stdbool.h>
|
2010-09-07 15:34:51 +00:00
|
|
|
|
|
|
|
#include "getopt.h"
|
|
|
|
|
2011-10-08 22:55:39 +00:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
#define strcasecmp(x, y) _stricmp(x, y)
|
|
|
|
#endif
|
|
|
|
|
2015-01-26 02:16:43 +00:00
|
|
|
#define API_NAME_OPENGL "gl"
|
|
|
|
#define API_NAME_OPENGL_ES "es"
|
2012-09-30 13:32:50 +00:00
|
|
|
|
2016-03-28 11:19:31 +00:00
|
|
|
#define API_NAME_NATIVE "native"
|
|
|
|
#define API_NAME_EGL "egl"
|
2017-02-28 18:23:25 +00:00
|
|
|
#define API_NAME_OSMESA "osmesa"
|
2016-03-28 11:19:31 +00:00
|
|
|
|
2011-10-08 22:55:39 +00:00
|
|
|
#define PROFILE_NAME_CORE "core"
|
|
|
|
#define PROFILE_NAME_COMPAT "compat"
|
|
|
|
|
2014-08-21 17:21:45 +00:00
|
|
|
#define STRATEGY_NAME_NONE "none"
|
|
|
|
#define STRATEGY_NAME_LOSE "lose"
|
|
|
|
|
|
|
|
#define BEHAVIOR_NAME_NONE "none"
|
|
|
|
#define BEHAVIOR_NAME_FLUSH "flush"
|
2011-10-08 22:55:39 +00:00
|
|
|
|
2020-06-25 16:22:08 +00:00
|
|
|
#define ANGLE_TYPE_OPENGL "gl"
|
|
|
|
#define ANGLE_TYPE_OPENGLES "es"
|
|
|
|
#define ANGLE_TYPE_D3D9 "d3d9"
|
|
|
|
#define ANGLE_TYPE_D3D11 "d3d11"
|
|
|
|
#define ANGLE_TYPE_VULKAN "vk"
|
|
|
|
#define ANGLE_TYPE_METAL "mtl"
|
|
|
|
|
2021-07-13 19:50:09 +00:00
|
|
|
#define PLATFORM_NAME_ANY "any"
|
|
|
|
#define PLATFORM_NAME_WIN32 "win32"
|
|
|
|
#define PLATFORM_NAME_COCOA "cooca"
|
|
|
|
#define PLATFORM_NAME_WL "wayland"
|
|
|
|
#define PLATFORM_NAME_X11 "x11"
|
|
|
|
#define PLATFORM_NAME_NULL "null"
|
|
|
|
|
2010-09-07 15:34:51 +00:00
|
|
|
static void usage(void)
|
|
|
|
{
|
2015-01-26 02:16:43 +00:00
|
|
|
printf("Usage: glfwinfo [OPTION]...\n");
|
2013-11-03 12:38:45 +00:00
|
|
|
printf("Options:\n");
|
2021-07-13 19:50:09 +00:00
|
|
|
printf(" --platform=PLATFORM the platform to use ("
|
|
|
|
PLATFORM_NAME_ANY " or "
|
|
|
|
PLATFORM_NAME_WIN32 " or "
|
|
|
|
PLATFORM_NAME_COCOA " or "
|
|
|
|
PLATFORM_NAME_X11 " or "
|
|
|
|
PLATFORM_NAME_WL " or "
|
|
|
|
PLATFORM_NAME_NULL ")\n");
|
2015-01-26 02:16:43 +00:00
|
|
|
printf(" -a, --client-api=API the client API to use ("
|
|
|
|
API_NAME_OPENGL " or "
|
|
|
|
API_NAME_OPENGL_ES ")\n");
|
|
|
|
printf(" -b, --behavior=BEHAVIOR the release behavior to use ("
|
|
|
|
BEHAVIOR_NAME_NONE " or "
|
|
|
|
BEHAVIOR_NAME_FLUSH ")\n");
|
2016-03-28 11:19:31 +00:00
|
|
|
printf(" -c, --context-api=API the context creation API to use ("
|
|
|
|
API_NAME_NATIVE " or "
|
2017-02-28 18:23:25 +00:00
|
|
|
API_NAME_EGL " or "
|
|
|
|
API_NAME_OSMESA ")\n");
|
2015-01-26 02:16:43 +00:00
|
|
|
printf(" -d, --debug request a debug context\n");
|
|
|
|
printf(" -f, --forward require a forward-compatible context\n");
|
|
|
|
printf(" -h, --help show this help\n");
|
2015-08-10 18:19:04 +00:00
|
|
|
printf(" -l, --list-extensions list all Vulkan and client API extensions\n");
|
|
|
|
printf(" --list-layers list all Vulkan layers\n");
|
2015-01-26 02:16:43 +00:00
|
|
|
printf(" -m, --major=MAJOR the major number of the required "
|
|
|
|
"client API version\n");
|
|
|
|
printf(" -n, --minor=MINOR the minor number of the required "
|
|
|
|
"client API version\n");
|
|
|
|
printf(" -p, --profile=PROFILE the OpenGL profile to use ("
|
|
|
|
PROFILE_NAME_CORE " or "
|
|
|
|
PROFILE_NAME_COMPAT ")\n");
|
|
|
|
printf(" -s, --robustness=STRATEGY the robustness strategy to use ("
|
|
|
|
STRATEGY_NAME_NONE " or "
|
|
|
|
STRATEGY_NAME_LOSE ")\n");
|
2015-07-01 12:48:20 +00:00
|
|
|
printf(" -v, --version print version information\n");
|
2015-06-30 16:41:19 +00:00
|
|
|
printf(" --red-bits=N the number of red bits to request\n");
|
|
|
|
printf(" --green-bits=N the number of green bits to request\n");
|
|
|
|
printf(" --blue-bits=N the number of blue bits to request\n");
|
|
|
|
printf(" --alpha-bits=N the number of alpha bits to request\n");
|
|
|
|
printf(" --depth-bits=N the number of depth bits to request\n");
|
|
|
|
printf(" --stencil-bits=N the number of stencil bits to request\n");
|
|
|
|
printf(" --accum-red-bits=N the number of red bits to request\n");
|
|
|
|
printf(" --accum-green-bits=N the number of green bits to request\n");
|
|
|
|
printf(" --accum-blue-bits=N the number of blue bits to request\n");
|
|
|
|
printf(" --accum-alpha-bits=N the number of alpha bits to request\n");
|
|
|
|
printf(" --aux-buffers=N the number of aux buffers to request\n");
|
|
|
|
printf(" --samples=N the number of MSAA samples to request\n");
|
|
|
|
printf(" --stereo request stereo rendering\n");
|
|
|
|
printf(" --srgb request an sRGB capable framebuffer\n");
|
|
|
|
printf(" --singlebuffer request single-buffering\n");
|
2015-08-10 10:46:14 +00:00
|
|
|
printf(" --no-error request a context that does not emit errors\n");
|
2020-06-25 16:22:08 +00:00
|
|
|
printf(" --angle-type=TYPE the ANGLE platform type to use ("
|
|
|
|
ANGLE_TYPE_OPENGL ", "
|
|
|
|
ANGLE_TYPE_OPENGLES ", "
|
|
|
|
ANGLE_TYPE_D3D9 ", "
|
|
|
|
ANGLE_TYPE_D3D11 ", "
|
|
|
|
ANGLE_TYPE_VULKAN " or "
|
|
|
|
ANGLE_TYPE_METAL ")\n");
|
2019-03-27 14:59:36 +00:00
|
|
|
printf(" --graphics-switching request macOS graphics switching\n");
|
2021-04-11 19:44:02 +00:00
|
|
|
printf(" --disable-xcb-surface disable VK_KHR_xcb_surface extension\n");
|
2010-09-07 15:34:51 +00:00
|
|
|
}
|
|
|
|
|
2010-11-23 16:45:23 +00:00
|
|
|
static void error_callback(int error, const char* description)
|
|
|
|
{
|
2012-09-30 13:51:46 +00:00
|
|
|
fprintf(stderr, "Error: %s\n", description);
|
2010-11-23 16:45:23 +00:00
|
|
|
}
|
|
|
|
|
2021-07-13 19:50:09 +00:00
|
|
|
static const char* get_platform_name(int platform)
|
|
|
|
{
|
|
|
|
if (platform == GLFW_PLATFORM_WIN32)
|
|
|
|
return "Win32";
|
|
|
|
else if (platform == GLFW_PLATFORM_COCOA)
|
|
|
|
return "Cocoa";
|
|
|
|
else if (platform == GLFW_PLATFORM_WAYLAND)
|
|
|
|
return "Wayland";
|
|
|
|
else if (platform == GLFW_PLATFORM_X11)
|
|
|
|
return "X11";
|
|
|
|
else if (platform == GLFW_PLATFORM_NULL)
|
|
|
|
return "Null";
|
|
|
|
|
|
|
|
return "unknown";
|
|
|
|
}
|
|
|
|
|
2015-08-10 18:19:04 +00:00
|
|
|
static const char* get_device_type_name(VkPhysicalDeviceType type)
|
|
|
|
{
|
|
|
|
if (type == VK_PHYSICAL_DEVICE_TYPE_OTHER)
|
|
|
|
return "other";
|
|
|
|
else if (type == VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU)
|
|
|
|
return "integrated GPU";
|
|
|
|
else if (type == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU)
|
|
|
|
return "discrete GPU";
|
|
|
|
else if (type == VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU)
|
|
|
|
return "virtual GPU";
|
|
|
|
else if (type == VK_PHYSICAL_DEVICE_TYPE_CPU)
|
|
|
|
return "CPU";
|
|
|
|
|
|
|
|
return "unknown";
|
|
|
|
}
|
|
|
|
|
2015-01-26 02:16:43 +00:00
|
|
|
static const char* get_api_name(int api)
|
2010-10-03 16:55:13 +00:00
|
|
|
{
|
2012-09-30 13:32:50 +00:00
|
|
|
if (api == GLFW_OPENGL_API)
|
|
|
|
return "OpenGL";
|
|
|
|
else if (api == GLFW_OPENGL_ES_API)
|
|
|
|
return "OpenGL ES";
|
2010-10-03 16:55:13 +00:00
|
|
|
|
2012-09-30 13:32:50 +00:00
|
|
|
return "Unknown API";
|
2010-10-03 16:55:13 +00:00
|
|
|
}
|
|
|
|
|
2012-10-21 20:13:14 +00:00
|
|
|
static const char* get_profile_name_gl(GLint mask)
|
2010-09-07 15:34:51 +00:00
|
|
|
{
|
2010-09-11 12:33:24 +00:00
|
|
|
if (mask & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT)
|
2012-12-13 19:04:17 +00:00
|
|
|
return PROFILE_NAME_COMPAT;
|
2010-09-11 12:33:24 +00:00
|
|
|
if (mask & GL_CONTEXT_CORE_PROFILE_BIT)
|
2012-12-13 19:04:17 +00:00
|
|
|
return PROFILE_NAME_CORE;
|
2010-09-07 15:34:51 +00:00
|
|
|
|
2010-10-03 16:55:13 +00:00
|
|
|
return "unknown";
|
2010-09-07 15:34:51 +00:00
|
|
|
}
|
|
|
|
|
2012-10-21 20:13:14 +00:00
|
|
|
static const char* get_profile_name_glfw(int profile)
|
|
|
|
{
|
|
|
|
if (profile == GLFW_OPENGL_COMPAT_PROFILE)
|
2012-12-13 19:04:17 +00:00
|
|
|
return PROFILE_NAME_COMPAT;
|
2012-10-21 20:13:14 +00:00
|
|
|
if (profile == GLFW_OPENGL_CORE_PROFILE)
|
2012-12-13 19:04:17 +00:00
|
|
|
return PROFILE_NAME_CORE;
|
2012-10-21 20:13:14 +00:00
|
|
|
|
|
|
|
return "unknown";
|
|
|
|
}
|
|
|
|
|
2012-12-13 18:29:18 +00:00
|
|
|
static const char* get_strategy_name_gl(GLint strategy)
|
|
|
|
{
|
|
|
|
if (strategy == GL_LOSE_CONTEXT_ON_RESET_ARB)
|
|
|
|
return STRATEGY_NAME_LOSE;
|
|
|
|
if (strategy == GL_NO_RESET_NOTIFICATION_ARB)
|
|
|
|
return STRATEGY_NAME_NONE;
|
|
|
|
|
|
|
|
return "unknown";
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char* get_strategy_name_glfw(int strategy)
|
|
|
|
{
|
|
|
|
if (strategy == GLFW_LOSE_CONTEXT_ON_RESET)
|
|
|
|
return STRATEGY_NAME_LOSE;
|
|
|
|
if (strategy == GLFW_NO_RESET_NOTIFICATION)
|
|
|
|
return STRATEGY_NAME_NONE;
|
2012-10-21 20:13:14 +00:00
|
|
|
|
|
|
|
return "unknown";
|
|
|
|
}
|
|
|
|
|
2016-03-28 11:19:31 +00:00
|
|
|
static void list_context_extensions(int client, int major, int minor)
|
2010-09-07 15:34:51 +00:00
|
|
|
{
|
2016-03-28 11:19:31 +00:00
|
|
|
printf("%s context extensions:\n", get_api_name(client));
|
2010-09-07 15:34:51 +00:00
|
|
|
|
2016-03-28 11:19:31 +00:00
|
|
|
if (client == GLFW_OPENGL_API && major > 2)
|
2010-09-07 15:34:51 +00:00
|
|
|
{
|
2019-05-19 17:10:35 +00:00
|
|
|
GLint count;
|
2010-09-07 15:34:51 +00:00
|
|
|
glGetIntegerv(GL_NUM_EXTENSIONS, &count);
|
|
|
|
|
2019-05-19 17:10:35 +00:00
|
|
|
for (int i = 0; i < count; i++)
|
2016-02-15 07:34:44 +00:00
|
|
|
printf(" %s\n", (const char*) glGetStringi(GL_EXTENSIONS, i));
|
2010-09-07 15:34:51 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-05-19 17:10:35 +00:00
|
|
|
const GLubyte* extensions = glGetString(GL_EXTENSIONS);
|
2010-09-07 15:34:51 +00:00
|
|
|
while (*extensions != '\0')
|
|
|
|
{
|
2016-02-15 07:34:44 +00:00
|
|
|
putchar(' ');
|
|
|
|
|
|
|
|
while (*extensions != '\0' && *extensions != ' ')
|
|
|
|
{
|
2010-09-07 15:34:51 +00:00
|
|
|
putchar(*extensions);
|
2016-02-15 07:34:44 +00:00
|
|
|
extensions++;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (*extensions == ' ')
|
|
|
|
extensions++;
|
2010-09-07 15:34:51 +00:00
|
|
|
|
2016-02-15 07:34:44 +00:00
|
|
|
putchar('\n');
|
2010-09-07 15:34:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-10 18:19:04 +00:00
|
|
|
static void list_vulkan_instance_extensions(void)
|
|
|
|
{
|
|
|
|
printf("Vulkan instance extensions:\n");
|
|
|
|
|
2019-05-19 17:10:35 +00:00
|
|
|
uint32_t ep_count;
|
2019-05-19 17:26:16 +00:00
|
|
|
vkEnumerateInstanceExtensionProperties(NULL, &ep_count, NULL);
|
2019-05-19 17:10:35 +00:00
|
|
|
VkExtensionProperties* ep = calloc(ep_count, sizeof(VkExtensionProperties));
|
2019-05-19 17:26:16 +00:00
|
|
|
vkEnumerateInstanceExtensionProperties(NULL, &ep_count, ep);
|
2015-08-10 18:19:04 +00:00
|
|
|
|
2019-05-19 17:10:35 +00:00
|
|
|
for (uint32_t i = 0; i < ep_count; i++)
|
2019-05-19 17:27:48 +00:00
|
|
|
printf(" %s (spec version %u)\n", ep[i].extensionName, ep[i].specVersion);
|
2015-08-10 18:19:04 +00:00
|
|
|
|
|
|
|
free(ep);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void list_vulkan_instance_layers(void)
|
|
|
|
{
|
|
|
|
printf("Vulkan instance layers:\n");
|
|
|
|
|
2019-05-19 17:10:35 +00:00
|
|
|
uint32_t lp_count;
|
2019-05-19 17:26:16 +00:00
|
|
|
vkEnumerateInstanceLayerProperties(&lp_count, NULL);
|
2019-05-19 17:10:35 +00:00
|
|
|
VkLayerProperties* lp = calloc(lp_count, sizeof(VkLayerProperties));
|
2019-05-19 17:26:16 +00:00
|
|
|
vkEnumerateInstanceLayerProperties(&lp_count, lp);
|
2015-08-10 18:19:04 +00:00
|
|
|
|
2019-05-19 17:10:35 +00:00
|
|
|
for (uint32_t i = 0; i < lp_count; i++)
|
2015-08-10 18:19:04 +00:00
|
|
|
{
|
2019-05-19 17:27:48 +00:00
|
|
|
printf(" %s (spec version %u) \"%s\"\n",
|
2015-08-10 18:19:04 +00:00
|
|
|
lp[i].layerName,
|
|
|
|
lp[i].specVersion >> 22,
|
|
|
|
lp[i].description);
|
|
|
|
}
|
|
|
|
|
|
|
|
free(lp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void list_vulkan_device_extensions(VkInstance instance, VkPhysicalDevice device)
|
|
|
|
{
|
|
|
|
printf("Vulkan device extensions:\n");
|
|
|
|
|
2019-05-19 17:10:35 +00:00
|
|
|
uint32_t ep_count;
|
2019-05-19 17:26:16 +00:00
|
|
|
vkEnumerateDeviceExtensionProperties(device, NULL, &ep_count, NULL);
|
2019-05-19 17:10:35 +00:00
|
|
|
VkExtensionProperties* ep = calloc(ep_count, sizeof(VkExtensionProperties));
|
2019-05-19 17:26:16 +00:00
|
|
|
vkEnumerateDeviceExtensionProperties(device, NULL, &ep_count, ep);
|
2015-08-10 18:19:04 +00:00
|
|
|
|
2019-05-19 17:10:35 +00:00
|
|
|
for (uint32_t i = 0; i < ep_count; i++)
|
2019-05-19 17:27:48 +00:00
|
|
|
printf(" %s (spec version %u)\n", ep[i].extensionName, ep[i].specVersion);
|
2015-08-10 18:19:04 +00:00
|
|
|
|
|
|
|
free(ep);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void list_vulkan_device_layers(VkInstance instance, VkPhysicalDevice device)
|
|
|
|
{
|
|
|
|
printf("Vulkan device layers:\n");
|
|
|
|
|
2019-05-19 17:10:35 +00:00
|
|
|
uint32_t lp_count;
|
2019-05-19 17:26:16 +00:00
|
|
|
vkEnumerateDeviceLayerProperties(device, &lp_count, NULL);
|
2019-05-19 17:10:35 +00:00
|
|
|
VkLayerProperties* lp = calloc(lp_count, sizeof(VkLayerProperties));
|
2019-05-19 17:26:16 +00:00
|
|
|
vkEnumerateDeviceLayerProperties(device, &lp_count, lp);
|
2015-08-10 18:19:04 +00:00
|
|
|
|
2019-05-19 17:10:35 +00:00
|
|
|
for (uint32_t i = 0; i < lp_count; i++)
|
2015-08-10 18:19:04 +00:00
|
|
|
{
|
2019-05-19 17:27:48 +00:00
|
|
|
printf(" %s (spec version %u) \"%s\"\n",
|
2015-08-10 18:19:04 +00:00
|
|
|
lp[i].layerName,
|
|
|
|
lp[i].specVersion >> 22,
|
|
|
|
lp[i].description);
|
|
|
|
}
|
|
|
|
|
|
|
|
free(lp);
|
|
|
|
}
|
|
|
|
|
2020-06-28 19:23:17 +00:00
|
|
|
static bool valid_version(void)
|
2012-08-30 00:17:08 +00:00
|
|
|
{
|
|
|
|
int major, minor, revision;
|
|
|
|
glfwGetVersion(&major, &minor, &revision);
|
|
|
|
|
|
|
|
if (major != GLFW_VERSION_MAJOR)
|
|
|
|
{
|
|
|
|
printf("*** ERROR: GLFW major version mismatch! ***\n");
|
2020-06-28 19:23:17 +00:00
|
|
|
return false;
|
2012-08-30 00:17:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (minor != GLFW_VERSION_MINOR || revision != GLFW_VERSION_REVISION)
|
|
|
|
printf("*** WARNING: GLFW version mismatch! ***\n");
|
|
|
|
|
2020-06-28 19:23:17 +00:00
|
|
|
return true;
|
2012-08-30 00:17:08 +00:00
|
|
|
}
|
|
|
|
|
2015-06-30 16:36:33 +00:00
|
|
|
static void print_version(void)
|
|
|
|
{
|
|
|
|
int major, minor, revision;
|
|
|
|
glfwGetVersion(&major, &minor, &revision);
|
|
|
|
|
|
|
|
printf("GLFW header version: %u.%u.%u\n",
|
|
|
|
GLFW_VERSION_MAJOR,
|
|
|
|
GLFW_VERSION_MINOR,
|
|
|
|
GLFW_VERSION_REVISION);
|
|
|
|
printf("GLFW library version: %u.%u.%u\n", major, minor, revision);
|
|
|
|
printf("GLFW library version string: \"%s\"\n", glfwGetVersionString());
|
|
|
|
}
|
|
|
|
|
2021-07-13 19:50:09 +00:00
|
|
|
static void print_platform(void)
|
|
|
|
{
|
|
|
|
const int platforms[] =
|
|
|
|
{
|
|
|
|
GLFW_PLATFORM_WIN32,
|
|
|
|
GLFW_PLATFORM_COCOA,
|
|
|
|
GLFW_PLATFORM_WAYLAND,
|
|
|
|
GLFW_PLATFORM_X11,
|
|
|
|
GLFW_PLATFORM_NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
printf("GLFW platform: %s\n", get_platform_name(glfwGetPlatform()));
|
|
|
|
printf("GLFW supported platforms:\n");
|
|
|
|
|
|
|
|
for (size_t i = 0; i < sizeof(platforms) / sizeof(platforms[0]); i++)
|
|
|
|
{
|
|
|
|
if (glfwPlatformSupported(platforms[i]))
|
|
|
|
printf(" %s\n", get_platform_name(platforms[i]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-07 15:34:51 +00:00
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
2019-05-19 17:10:35 +00:00
|
|
|
int ch;
|
|
|
|
bool list_extensions = false, list_layers = false;
|
2010-09-07 15:34:51 +00:00
|
|
|
|
2020-06-28 19:18:21 +00:00
|
|
|
// These duplicate the defaults for each hint
|
2021-07-13 19:50:09 +00:00
|
|
|
int platform = GLFW_ANY_PLATFORM;
|
2020-06-28 19:18:21 +00:00
|
|
|
int client_api = GLFW_OPENGL_API;
|
|
|
|
int context_major = 1;
|
|
|
|
int context_minor = 0;
|
|
|
|
int context_release = GLFW_ANY_RELEASE_BEHAVIOR;
|
|
|
|
int context_creation_api = GLFW_NATIVE_CONTEXT_API;
|
|
|
|
int context_robustness = GLFW_NO_ROBUSTNESS;
|
|
|
|
bool context_debug = false;
|
|
|
|
bool context_no_error = false;
|
|
|
|
bool opengl_forward = false;
|
|
|
|
int opengl_profile = GLFW_OPENGL_ANY_PROFILE;
|
|
|
|
int fb_red_bits = 8;
|
|
|
|
int fb_green_bits = 8;
|
|
|
|
int fb_blue_bits = 8;
|
|
|
|
int fb_alpha_bits = 8;
|
|
|
|
int fb_depth_bits = 24;
|
|
|
|
int fb_stencil_bits = 8;
|
|
|
|
int fb_accum_red_bits = 0;
|
|
|
|
int fb_accum_green_bits = 0;
|
|
|
|
int fb_accum_blue_bits = 0;
|
|
|
|
int fb_accum_alpha_bits = 0;
|
|
|
|
int fb_aux_buffers = 0;
|
|
|
|
int fb_samples = 0;
|
|
|
|
bool fb_stereo = false;
|
|
|
|
bool fb_srgb = false;
|
|
|
|
bool fb_doublebuffer = true;
|
2020-06-25 16:22:08 +00:00
|
|
|
int angle_type = GLFW_ANGLE_PLATFORM_TYPE_NONE;
|
2020-06-28 19:18:21 +00:00
|
|
|
bool cocoa_graphics_switching = false;
|
2021-04-11 19:44:02 +00:00
|
|
|
bool disable_xcb_surface = false;
|
2020-06-28 19:18:21 +00:00
|
|
|
|
2021-07-13 19:50:09 +00:00
|
|
|
enum { PLATFORM, CLIENT, CONTEXT, BEHAVIOR, DEBUG_CONTEXT, FORWARD, HELP,
|
2019-07-22 15:42:00 +00:00
|
|
|
EXTENSIONS, LAYERS,
|
2015-07-01 12:48:20 +00:00
|
|
|
MAJOR, MINOR, PROFILE, ROBUSTNESS, VERSION,
|
2015-06-30 16:41:19 +00:00
|
|
|
REDBITS, GREENBITS, BLUEBITS, ALPHABITS, DEPTHBITS, STENCILBITS,
|
|
|
|
ACCUMREDBITS, ACCUMGREENBITS, ACCUMBLUEBITS, ACCUMALPHABITS,
|
2019-03-27 14:59:36 +00:00
|
|
|
AUXBUFFERS, SAMPLES, STEREO, SRGB, SINGLEBUFFER, NOERROR_SRSLY,
|
2021-04-11 19:44:02 +00:00
|
|
|
ANGLE_TYPE, GRAPHICS_SWITCHING, XCB_SURFACE };
|
2015-01-26 02:16:43 +00:00
|
|
|
const struct option options[] =
|
|
|
|
{
|
2021-07-13 19:50:09 +00:00
|
|
|
{ "platform", 1, NULL, PLATFORM },
|
2019-03-27 14:59:36 +00:00
|
|
|
{ "behavior", 1, NULL, BEHAVIOR },
|
|
|
|
{ "client-api", 1, NULL, CLIENT },
|
|
|
|
{ "context-api", 1, NULL, CONTEXT },
|
2019-07-22 15:42:00 +00:00
|
|
|
{ "debug", 0, NULL, DEBUG_CONTEXT },
|
2019-03-27 14:59:36 +00:00
|
|
|
{ "forward", 0, NULL, FORWARD },
|
|
|
|
{ "help", 0, NULL, HELP },
|
|
|
|
{ "list-extensions", 0, NULL, EXTENSIONS },
|
|
|
|
{ "list-layers", 0, NULL, LAYERS },
|
|
|
|
{ "major", 1, NULL, MAJOR },
|
|
|
|
{ "minor", 1, NULL, MINOR },
|
|
|
|
{ "profile", 1, NULL, PROFILE },
|
|
|
|
{ "robustness", 1, NULL, ROBUSTNESS },
|
|
|
|
{ "version", 0, NULL, VERSION },
|
|
|
|
{ "red-bits", 1, NULL, REDBITS },
|
|
|
|
{ "green-bits", 1, NULL, GREENBITS },
|
|
|
|
{ "blue-bits", 1, NULL, BLUEBITS },
|
|
|
|
{ "alpha-bits", 1, NULL, ALPHABITS },
|
|
|
|
{ "depth-bits", 1, NULL, DEPTHBITS },
|
|
|
|
{ "stencil-bits", 1, NULL, STENCILBITS },
|
|
|
|
{ "accum-red-bits", 1, NULL, ACCUMREDBITS },
|
|
|
|
{ "accum-green-bits", 1, NULL, ACCUMGREENBITS },
|
|
|
|
{ "accum-blue-bits", 1, NULL, ACCUMBLUEBITS },
|
|
|
|
{ "accum-alpha-bits", 1, NULL, ACCUMALPHABITS },
|
|
|
|
{ "aux-buffers", 1, NULL, AUXBUFFERS },
|
|
|
|
{ "samples", 1, NULL, SAMPLES },
|
|
|
|
{ "stereo", 0, NULL, STEREO },
|
|
|
|
{ "srgb", 0, NULL, SRGB },
|
|
|
|
{ "singlebuffer", 0, NULL, SINGLEBUFFER },
|
|
|
|
{ "no-error", 0, NULL, NOERROR_SRSLY },
|
2020-06-25 16:22:08 +00:00
|
|
|
{ "angle-type", 1, NULL, ANGLE_TYPE },
|
2019-03-27 14:59:36 +00:00
|
|
|
{ "graphics-switching", 0, NULL, GRAPHICS_SWITCHING },
|
2021-04-11 19:44:02 +00:00
|
|
|
{ "vk-xcb-surface", 0, NULL, XCB_SURFACE },
|
2015-01-26 02:16:43 +00:00
|
|
|
{ NULL, 0, NULL, 0 }
|
|
|
|
};
|
|
|
|
|
2016-07-22 16:13:28 +00:00
|
|
|
while ((ch = getopt_long(argc, argv, "a:b:c:dfhlm:n:p:s:v", options, NULL)) != -1)
|
2010-09-07 15:34:51 +00:00
|
|
|
{
|
|
|
|
switch (ch)
|
|
|
|
{
|
2021-07-13 19:50:09 +00:00
|
|
|
case PLATFORM:
|
2021-10-25 19:24:07 +00:00
|
|
|
if (strcasecmp(optarg, PLATFORM_NAME_ANY) == 0)
|
|
|
|
platform = GLFW_ANY_PLATFORM;
|
|
|
|
else if (strcasecmp(optarg, PLATFORM_NAME_WIN32) == 0)
|
2021-07-13 19:50:09 +00:00
|
|
|
platform = GLFW_PLATFORM_WIN32;
|
|
|
|
else if (strcasecmp(optarg, PLATFORM_NAME_COCOA) == 0)
|
|
|
|
platform = GLFW_PLATFORM_COCOA;
|
|
|
|
else if (strcasecmp(optarg, PLATFORM_NAME_WL) == 0)
|
|
|
|
platform = GLFW_PLATFORM_WAYLAND;
|
|
|
|
else if (strcasecmp(optarg, PLATFORM_NAME_X11) == 0)
|
|
|
|
platform = GLFW_PLATFORM_X11;
|
|
|
|
else if (strcasecmp(optarg, PLATFORM_NAME_NULL) == 0)
|
|
|
|
platform = GLFW_PLATFORM_NULL;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
usage();
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
break;
|
2012-09-30 13:32:50 +00:00
|
|
|
case 'a':
|
2016-03-28 11:19:31 +00:00
|
|
|
case CLIENT:
|
2015-01-26 02:16:43 +00:00
|
|
|
if (strcasecmp(optarg, API_NAME_OPENGL) == 0)
|
2020-06-28 19:18:21 +00:00
|
|
|
client_api = GLFW_OPENGL_API;
|
2015-01-26 02:16:43 +00:00
|
|
|
else if (strcasecmp(optarg, API_NAME_OPENGL_ES) == 0)
|
2020-06-28 19:18:21 +00:00
|
|
|
client_api = GLFW_OPENGL_ES_API;
|
2012-09-30 13:32:50 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
usage();
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
2014-08-20 15:59:58 +00:00
|
|
|
break;
|
2014-08-21 17:21:45 +00:00
|
|
|
case 'b':
|
2015-01-26 02:16:43 +00:00
|
|
|
case BEHAVIOR:
|
2014-08-21 17:21:45 +00:00
|
|
|
if (strcasecmp(optarg, BEHAVIOR_NAME_NONE) == 0)
|
2020-06-28 19:18:21 +00:00
|
|
|
context_release = GLFW_RELEASE_BEHAVIOR_NONE;
|
2014-08-21 17:21:45 +00:00
|
|
|
else if (strcasecmp(optarg, BEHAVIOR_NAME_FLUSH) == 0)
|
2020-06-28 19:18:21 +00:00
|
|
|
context_release = GLFW_RELEASE_BEHAVIOR_FLUSH;
|
2014-08-21 17:21:45 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
usage();
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
break;
|
2016-03-28 11:19:31 +00:00
|
|
|
case 'c':
|
|
|
|
case CONTEXT:
|
|
|
|
if (strcasecmp(optarg, API_NAME_NATIVE) == 0)
|
2020-06-28 19:18:21 +00:00
|
|
|
context_creation_api = GLFW_NATIVE_CONTEXT_API;
|
2016-03-28 11:19:31 +00:00
|
|
|
else if (strcasecmp(optarg, API_NAME_EGL) == 0)
|
2020-06-28 19:18:21 +00:00
|
|
|
context_creation_api = GLFW_EGL_CONTEXT_API;
|
2017-02-28 18:23:25 +00:00
|
|
|
else if (strcasecmp(optarg, API_NAME_OSMESA) == 0)
|
2020-06-28 19:18:21 +00:00
|
|
|
context_creation_api = GLFW_OSMESA_CONTEXT_API;
|
2016-03-28 11:19:31 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
usage();
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
break;
|
2010-09-07 15:34:51 +00:00
|
|
|
case 'd':
|
2019-07-22 15:42:00 +00:00
|
|
|
case DEBUG_CONTEXT:
|
2020-06-28 19:18:21 +00:00
|
|
|
context_debug = true;
|
2010-09-07 15:34:51 +00:00
|
|
|
break;
|
|
|
|
case 'f':
|
2015-01-26 02:16:43 +00:00
|
|
|
case FORWARD:
|
2020-06-28 19:18:21 +00:00
|
|
|
opengl_forward = true;
|
2010-09-07 15:34:51 +00:00
|
|
|
break;
|
|
|
|
case 'h':
|
2015-01-26 02:16:43 +00:00
|
|
|
case HELP:
|
2010-09-07 15:34:51 +00:00
|
|
|
usage();
|
2010-09-20 18:22:26 +00:00
|
|
|
exit(EXIT_SUCCESS);
|
2010-09-07 15:34:51 +00:00
|
|
|
case 'l':
|
2015-01-26 02:16:43 +00:00
|
|
|
case EXTENSIONS:
|
2020-06-28 19:23:17 +00:00
|
|
|
list_extensions = true;
|
2015-08-10 18:19:04 +00:00
|
|
|
break;
|
|
|
|
case LAYERS:
|
2020-06-28 19:23:17 +00:00
|
|
|
list_layers = true;
|
2010-09-07 15:34:51 +00:00
|
|
|
break;
|
|
|
|
case 'm':
|
2015-01-26 02:16:43 +00:00
|
|
|
case MAJOR:
|
2020-06-28 19:18:21 +00:00
|
|
|
context_major = atoi(optarg);
|
2010-09-07 15:34:51 +00:00
|
|
|
break;
|
|
|
|
case 'n':
|
2015-01-26 02:16:43 +00:00
|
|
|
case MINOR:
|
2020-06-28 19:18:21 +00:00
|
|
|
context_minor = atoi(optarg);
|
2010-09-07 15:34:51 +00:00
|
|
|
break;
|
|
|
|
case 'p':
|
2015-01-26 02:16:43 +00:00
|
|
|
case PROFILE:
|
2011-10-08 22:55:39 +00:00
|
|
|
if (strcasecmp(optarg, PROFILE_NAME_CORE) == 0)
|
2020-06-28 19:18:21 +00:00
|
|
|
opengl_profile = GLFW_OPENGL_CORE_PROFILE;
|
2011-10-08 22:55:39 +00:00
|
|
|
else if (strcasecmp(optarg, PROFILE_NAME_COMPAT) == 0)
|
2020-06-28 19:18:21 +00:00
|
|
|
opengl_profile = GLFW_OPENGL_COMPAT_PROFILE;
|
2010-09-07 15:34:51 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
usage();
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
break;
|
2014-08-21 17:21:45 +00:00
|
|
|
case 's':
|
2015-01-26 02:16:43 +00:00
|
|
|
case ROBUSTNESS:
|
2011-10-08 22:55:39 +00:00
|
|
|
if (strcasecmp(optarg, STRATEGY_NAME_NONE) == 0)
|
2020-06-28 19:18:21 +00:00
|
|
|
context_robustness = GLFW_NO_RESET_NOTIFICATION;
|
2011-10-08 22:55:39 +00:00
|
|
|
else if (strcasecmp(optarg, STRATEGY_NAME_LOSE) == 0)
|
2020-06-28 19:18:21 +00:00
|
|
|
context_robustness = GLFW_LOSE_CONTEXT_ON_RESET;
|
2011-03-07 19:51:34 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
usage();
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
break;
|
2015-07-01 12:48:20 +00:00
|
|
|
case 'v':
|
|
|
|
case VERSION:
|
|
|
|
print_version();
|
|
|
|
exit(EXIT_SUCCESS);
|
2015-06-30 16:41:19 +00:00
|
|
|
case REDBITS:
|
|
|
|
if (strcmp(optarg, "-") == 0)
|
2020-06-28 19:18:21 +00:00
|
|
|
fb_red_bits = GLFW_DONT_CARE;
|
2015-06-30 16:41:19 +00:00
|
|
|
else
|
2020-06-28 19:18:21 +00:00
|
|
|
fb_red_bits = atoi(optarg);
|
2015-06-30 16:41:19 +00:00
|
|
|
break;
|
|
|
|
case GREENBITS:
|
|
|
|
if (strcmp(optarg, "-") == 0)
|
2020-06-28 19:18:21 +00:00
|
|
|
fb_green_bits = GLFW_DONT_CARE;
|
2015-06-30 16:41:19 +00:00
|
|
|
else
|
2020-06-28 19:18:21 +00:00
|
|
|
fb_green_bits = atoi(optarg);
|
2015-06-30 16:41:19 +00:00
|
|
|
break;
|
|
|
|
case BLUEBITS:
|
|
|
|
if (strcmp(optarg, "-") == 0)
|
2020-06-28 19:18:21 +00:00
|
|
|
fb_blue_bits = GLFW_DONT_CARE;
|
2015-06-30 16:41:19 +00:00
|
|
|
else
|
2020-06-28 19:18:21 +00:00
|
|
|
fb_blue_bits = atoi(optarg);
|
2015-06-30 16:41:19 +00:00
|
|
|
break;
|
|
|
|
case ALPHABITS:
|
|
|
|
if (strcmp(optarg, "-") == 0)
|
2020-06-28 19:18:21 +00:00
|
|
|
fb_alpha_bits = GLFW_DONT_CARE;
|
2015-06-30 16:41:19 +00:00
|
|
|
else
|
2020-06-28 19:18:21 +00:00
|
|
|
fb_alpha_bits = atoi(optarg);
|
2015-06-30 16:41:19 +00:00
|
|
|
break;
|
|
|
|
case DEPTHBITS:
|
|
|
|
if (strcmp(optarg, "-") == 0)
|
2020-06-28 19:18:21 +00:00
|
|
|
fb_depth_bits = GLFW_DONT_CARE;
|
2015-06-30 16:41:19 +00:00
|
|
|
else
|
2020-06-28 19:18:21 +00:00
|
|
|
fb_depth_bits = atoi(optarg);
|
2015-06-30 16:41:19 +00:00
|
|
|
break;
|
|
|
|
case STENCILBITS:
|
|
|
|
if (strcmp(optarg, "-") == 0)
|
2020-06-28 19:18:21 +00:00
|
|
|
fb_stencil_bits = GLFW_DONT_CARE;
|
2015-06-30 16:41:19 +00:00
|
|
|
else
|
2020-06-28 19:18:21 +00:00
|
|
|
fb_stencil_bits = atoi(optarg);
|
2015-06-30 16:41:19 +00:00
|
|
|
break;
|
|
|
|
case ACCUMREDBITS:
|
|
|
|
if (strcmp(optarg, "-") == 0)
|
2020-06-28 19:18:21 +00:00
|
|
|
fb_accum_red_bits = GLFW_DONT_CARE;
|
2015-06-30 16:41:19 +00:00
|
|
|
else
|
2020-06-28 19:18:21 +00:00
|
|
|
fb_accum_red_bits = atoi(optarg);
|
2015-06-30 16:41:19 +00:00
|
|
|
break;
|
|
|
|
case ACCUMGREENBITS:
|
|
|
|
if (strcmp(optarg, "-") == 0)
|
2020-06-28 19:18:21 +00:00
|
|
|
fb_accum_green_bits = GLFW_DONT_CARE;
|
2015-06-30 16:41:19 +00:00
|
|
|
else
|
2020-06-28 19:18:21 +00:00
|
|
|
fb_accum_green_bits = atoi(optarg);
|
2015-06-30 16:41:19 +00:00
|
|
|
break;
|
|
|
|
case ACCUMBLUEBITS:
|
|
|
|
if (strcmp(optarg, "-") == 0)
|
2020-06-28 19:18:21 +00:00
|
|
|
fb_accum_blue_bits = GLFW_DONT_CARE;
|
2015-06-30 16:41:19 +00:00
|
|
|
else
|
2020-06-28 19:18:21 +00:00
|
|
|
fb_accum_blue_bits = atoi(optarg);
|
2015-06-30 16:41:19 +00:00
|
|
|
break;
|
|
|
|
case ACCUMALPHABITS:
|
|
|
|
if (strcmp(optarg, "-") == 0)
|
2020-06-28 19:18:21 +00:00
|
|
|
fb_accum_alpha_bits = GLFW_DONT_CARE;
|
2015-06-30 16:41:19 +00:00
|
|
|
else
|
2020-06-28 19:18:21 +00:00
|
|
|
fb_accum_alpha_bits = atoi(optarg);
|
2015-06-30 16:41:19 +00:00
|
|
|
break;
|
|
|
|
case AUXBUFFERS:
|
|
|
|
if (strcmp(optarg, "-") == 0)
|
2020-06-28 19:18:21 +00:00
|
|
|
fb_aux_buffers = GLFW_DONT_CARE;
|
2015-06-30 16:41:19 +00:00
|
|
|
else
|
2020-06-28 19:18:21 +00:00
|
|
|
fb_aux_buffers = atoi(optarg);
|
2015-06-30 16:41:19 +00:00
|
|
|
break;
|
|
|
|
case SAMPLES:
|
|
|
|
if (strcmp(optarg, "-") == 0)
|
2020-06-28 19:18:21 +00:00
|
|
|
fb_samples = GLFW_DONT_CARE;
|
2015-06-30 16:41:19 +00:00
|
|
|
else
|
2020-06-28 19:18:21 +00:00
|
|
|
fb_samples = atoi(optarg);
|
2015-06-30 16:41:19 +00:00
|
|
|
break;
|
|
|
|
case STEREO:
|
2020-06-28 19:18:21 +00:00
|
|
|
fb_stereo = true;
|
2015-06-30 16:41:19 +00:00
|
|
|
break;
|
|
|
|
case SRGB:
|
2020-06-28 19:18:21 +00:00
|
|
|
fb_srgb = true;
|
2015-06-30 16:41:19 +00:00
|
|
|
break;
|
|
|
|
case SINGLEBUFFER:
|
2020-06-28 19:18:21 +00:00
|
|
|
fb_doublebuffer = false;
|
2015-06-30 16:41:19 +00:00
|
|
|
break;
|
2015-10-28 01:14:42 +00:00
|
|
|
case NOERROR_SRSLY:
|
2020-06-28 19:18:21 +00:00
|
|
|
context_no_error = true;
|
2015-08-10 10:46:14 +00:00
|
|
|
break;
|
2020-06-25 16:22:08 +00:00
|
|
|
case ANGLE_TYPE:
|
|
|
|
if (strcmp(optarg, ANGLE_TYPE_OPENGL) == 0)
|
|
|
|
angle_type = GLFW_ANGLE_PLATFORM_TYPE_OPENGL;
|
|
|
|
else if (strcmp(optarg, ANGLE_TYPE_OPENGLES) == 0)
|
|
|
|
angle_type = GLFW_ANGLE_PLATFORM_TYPE_OPENGLES;
|
|
|
|
else if (strcmp(optarg, ANGLE_TYPE_D3D9) == 0)
|
|
|
|
angle_type = GLFW_ANGLE_PLATFORM_TYPE_D3D9;
|
|
|
|
else if (strcmp(optarg, ANGLE_TYPE_D3D11) == 0)
|
|
|
|
angle_type = GLFW_ANGLE_PLATFORM_TYPE_D3D11;
|
|
|
|
else if (strcmp(optarg, ANGLE_TYPE_VULKAN) == 0)
|
|
|
|
angle_type = GLFW_ANGLE_PLATFORM_TYPE_VULKAN;
|
|
|
|
else if (strcmp(optarg, ANGLE_TYPE_METAL) == 0)
|
|
|
|
angle_type = GLFW_ANGLE_PLATFORM_TYPE_METAL;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
usage();
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
break;
|
2019-03-27 14:59:36 +00:00
|
|
|
case GRAPHICS_SWITCHING:
|
2020-06-28 19:18:21 +00:00
|
|
|
cocoa_graphics_switching = true;
|
2019-03-27 14:59:36 +00:00
|
|
|
break;
|
2021-04-11 19:44:02 +00:00
|
|
|
case XCB_SURFACE:
|
|
|
|
disable_xcb_surface = true;
|
|
|
|
break;
|
2010-09-07 15:34:51 +00:00
|
|
|
default:
|
|
|
|
usage();
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-28 19:18:21 +00:00
|
|
|
// Initialize GLFW and create window
|
|
|
|
|
|
|
|
if (!valid_version())
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
|
|
|
|
glfwSetErrorCallback(error_callback);
|
|
|
|
|
2021-07-13 19:50:09 +00:00
|
|
|
glfwInitHint(GLFW_PLATFORM, platform);
|
|
|
|
|
2020-06-28 19:23:17 +00:00
|
|
|
glfwInitHint(GLFW_COCOA_MENUBAR, false);
|
2020-06-28 19:18:21 +00:00
|
|
|
|
2020-06-25 16:22:08 +00:00
|
|
|
glfwInitHint(GLFW_ANGLE_PLATFORM_TYPE, angle_type);
|
2021-04-11 19:44:02 +00:00
|
|
|
glfwInitHint(GLFW_X11_XCB_VULKAN_SURFACE, !disable_xcb_surface);
|
2020-06-25 16:22:08 +00:00
|
|
|
|
2020-06-28 19:18:21 +00:00
|
|
|
if (!glfwInit())
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
|
2015-06-30 16:36:33 +00:00
|
|
|
print_version();
|
2021-07-13 19:50:09 +00:00
|
|
|
print_platform();
|
2015-06-30 16:36:33 +00:00
|
|
|
|
2020-06-28 19:23:17 +00:00
|
|
|
glfwWindowHint(GLFW_VISIBLE, false);
|
2012-08-28 15:52:22 +00:00
|
|
|
|
2020-06-28 19:18:21 +00:00
|
|
|
glfwWindowHint(GLFW_CLIENT_API, client_api);
|
|
|
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, context_major);
|
|
|
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, context_minor);
|
|
|
|
glfwWindowHint(GLFW_CONTEXT_RELEASE_BEHAVIOR, context_release);
|
|
|
|
glfwWindowHint(GLFW_CONTEXT_CREATION_API, context_creation_api);
|
|
|
|
glfwWindowHint(GLFW_CONTEXT_ROBUSTNESS, context_robustness);
|
|
|
|
glfwWindowHint(GLFW_CONTEXT_DEBUG, context_debug);
|
|
|
|
glfwWindowHint(GLFW_CONTEXT_NO_ERROR, context_no_error);
|
|
|
|
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, opengl_forward);
|
|
|
|
glfwWindowHint(GLFW_OPENGL_PROFILE, opengl_profile);
|
|
|
|
|
|
|
|
glfwWindowHint(GLFW_RED_BITS, fb_red_bits);
|
|
|
|
glfwWindowHint(GLFW_BLUE_BITS, fb_blue_bits);
|
|
|
|
glfwWindowHint(GLFW_GREEN_BITS, fb_green_bits);
|
|
|
|
glfwWindowHint(GLFW_ALPHA_BITS, fb_alpha_bits);
|
|
|
|
glfwWindowHint(GLFW_DEPTH_BITS, fb_depth_bits);
|
|
|
|
glfwWindowHint(GLFW_STENCIL_BITS, fb_stencil_bits);
|
|
|
|
glfwWindowHint(GLFW_ACCUM_RED_BITS, fb_accum_red_bits);
|
|
|
|
glfwWindowHint(GLFW_ACCUM_GREEN_BITS, fb_accum_green_bits);
|
|
|
|
glfwWindowHint(GLFW_ACCUM_BLUE_BITS, fb_accum_blue_bits);
|
|
|
|
glfwWindowHint(GLFW_ACCUM_ALPHA_BITS, fb_accum_alpha_bits);
|
|
|
|
glfwWindowHint(GLFW_AUX_BUFFERS, fb_aux_buffers);
|
|
|
|
glfwWindowHint(GLFW_SAMPLES, fb_samples);
|
|
|
|
glfwWindowHint(GLFW_STEREO, fb_stereo);
|
|
|
|
glfwWindowHint(GLFW_SRGB_CAPABLE, fb_srgb);
|
|
|
|
glfwWindowHint(GLFW_DOUBLEBUFFER, fb_doublebuffer);
|
|
|
|
|
|
|
|
glfwWindowHint(GLFW_COCOA_GRAPHICS_SWITCHING, cocoa_graphics_switching);
|
|
|
|
|
2019-05-19 17:10:35 +00:00
|
|
|
GLFWwindow* window = glfwCreateWindow(200, 200, "Version", NULL, NULL);
|
2010-10-03 16:55:13 +00:00
|
|
|
if (!window)
|
2012-10-22 01:20:16 +00:00
|
|
|
{
|
|
|
|
glfwTerminate();
|
2010-09-07 15:34:51 +00:00
|
|
|
exit(EXIT_FAILURE);
|
2012-10-22 01:20:16 +00:00
|
|
|
}
|
2010-09-07 15:34:51 +00:00
|
|
|
|
2012-08-10 13:29:45 +00:00
|
|
|
glfwMakeContextCurrent(window);
|
2019-04-14 15:34:38 +00:00
|
|
|
gladLoadGL(glfwGetProcAddress);
|
2012-08-10 13:29:45 +00:00
|
|
|
|
2019-05-19 17:10:35 +00:00
|
|
|
const GLenum error = glGetError();
|
2016-02-19 13:27:51 +00:00
|
|
|
if (error != GL_NO_ERROR)
|
|
|
|
printf("*** OpenGL error after make current: 0x%08x ***\n", error);
|
|
|
|
|
2012-09-30 13:32:50 +00:00
|
|
|
// Report client API version
|
2010-09-07 15:34:51 +00:00
|
|
|
|
2019-05-19 17:10:35 +00:00
|
|
|
const int client = glfwGetWindowAttrib(window, GLFW_CLIENT_API);
|
|
|
|
const int major = glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MAJOR);
|
|
|
|
const int minor = glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MINOR);
|
|
|
|
const int revision = glfwGetWindowAttrib(window, GLFW_CONTEXT_REVISION);
|
|
|
|
const int profile = glfwGetWindowAttrib(window, GLFW_OPENGL_PROFILE);
|
2010-09-07 15:34:51 +00:00
|
|
|
|
2012-09-30 13:32:50 +00:00
|
|
|
printf("%s context version string: \"%s\"\n",
|
2016-03-28 11:19:31 +00:00
|
|
|
get_api_name(client),
|
2012-09-30 13:32:50 +00:00
|
|
|
glGetString(GL_VERSION));
|
2010-09-07 15:34:51 +00:00
|
|
|
|
2012-09-30 13:32:50 +00:00
|
|
|
printf("%s context version parsed by GLFW: %u.%u.%u\n",
|
2016-03-28 11:19:31 +00:00
|
|
|
get_api_name(client),
|
2012-09-30 13:32:50 +00:00
|
|
|
major, minor, revision);
|
2010-09-07 15:34:51 +00:00
|
|
|
|
2012-09-30 13:32:50 +00:00
|
|
|
// Report client API context properties
|
2010-09-07 15:34:51 +00:00
|
|
|
|
2016-03-28 11:19:31 +00:00
|
|
|
if (client == GLFW_OPENGL_API)
|
2010-09-07 15:34:51 +00:00
|
|
|
{
|
2012-09-30 13:32:50 +00:00
|
|
|
if (major >= 3)
|
|
|
|
{
|
2015-06-30 16:29:14 +00:00
|
|
|
GLint flags;
|
|
|
|
|
2012-09-30 13:32:50 +00:00
|
|
|
glGetIntegerv(GL_CONTEXT_FLAGS, &flags);
|
2016-03-28 11:19:31 +00:00
|
|
|
printf("%s context flags (0x%08x):", get_api_name(client), flags);
|
2012-09-30 13:32:50 +00:00
|
|
|
|
|
|
|
if (flags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT)
|
|
|
|
printf(" forward-compatible");
|
2015-10-14 01:11:20 +00:00
|
|
|
if (flags & 2/*GL_CONTEXT_FLAG_DEBUG_BIT*/)
|
2012-09-30 13:32:50 +00:00
|
|
|
printf(" debug");
|
2012-12-13 18:29:18 +00:00
|
|
|
if (flags & GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB)
|
|
|
|
printf(" robustness");
|
2015-08-10 10:46:14 +00:00
|
|
|
if (flags & 8/*GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR*/)
|
|
|
|
printf(" no-error");
|
2012-09-30 13:32:50 +00:00
|
|
|
putchar('\n');
|
|
|
|
|
2016-03-28 11:19:31 +00:00
|
|
|
printf("%s context flags parsed by GLFW:", get_api_name(client));
|
2012-09-30 13:32:50 +00:00
|
|
|
|
2013-05-27 13:30:32 +00:00
|
|
|
if (glfwGetWindowAttrib(window, GLFW_OPENGL_FORWARD_COMPAT))
|
2012-09-30 13:32:50 +00:00
|
|
|
printf(" forward-compatible");
|
2020-06-26 16:35:48 +00:00
|
|
|
if (glfwGetWindowAttrib(window, GLFW_CONTEXT_DEBUG))
|
2012-09-30 13:32:50 +00:00
|
|
|
printf(" debug");
|
2015-01-26 02:16:43 +00:00
|
|
|
if (glfwGetWindowAttrib(window, GLFW_CONTEXT_ROBUSTNESS) == GLFW_LOSE_CONTEXT_ON_RESET)
|
2012-12-13 18:29:18 +00:00
|
|
|
printf(" robustness");
|
2015-08-10 10:46:14 +00:00
|
|
|
if (glfwGetWindowAttrib(window, GLFW_CONTEXT_NO_ERROR))
|
|
|
|
printf(" no-error");
|
2012-09-30 13:32:50 +00:00
|
|
|
putchar('\n');
|
|
|
|
}
|
2010-10-03 16:55:13 +00:00
|
|
|
|
2015-01-26 02:16:43 +00:00
|
|
|
if (major >= 4 || (major == 3 && minor >= 2))
|
2012-09-30 13:32:50 +00:00
|
|
|
{
|
2015-06-30 16:29:14 +00:00
|
|
|
GLint mask;
|
2012-09-30 13:32:50 +00:00
|
|
|
glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &mask);
|
2015-06-30 16:41:19 +00:00
|
|
|
|
2012-09-30 13:32:50 +00:00
|
|
|
printf("%s profile mask (0x%08x): %s\n",
|
2016-03-28 11:19:31 +00:00
|
|
|
get_api_name(client),
|
2012-09-30 13:32:50 +00:00
|
|
|
mask,
|
2012-10-21 20:13:14 +00:00
|
|
|
get_profile_name_gl(mask));
|
2012-09-30 13:32:50 +00:00
|
|
|
|
2012-10-21 20:13:14 +00:00
|
|
|
printf("%s profile mask parsed by GLFW: %s\n",
|
2016-03-28 11:19:31 +00:00
|
|
|
get_api_name(client),
|
2012-10-21 20:13:14 +00:00
|
|
|
get_profile_name_glfw(profile));
|
2012-09-30 13:32:50 +00:00
|
|
|
}
|
2012-12-13 18:29:18 +00:00
|
|
|
|
2016-09-26 12:55:55 +00:00
|
|
|
if (GLAD_GL_ARB_robustness)
|
2012-12-13 18:29:18 +00:00
|
|
|
{
|
2015-06-30 16:41:19 +00:00
|
|
|
const int robustness = glfwGetWindowAttrib(window, GLFW_CONTEXT_ROBUSTNESS);
|
2012-12-13 18:29:18 +00:00
|
|
|
GLint strategy;
|
|
|
|
glGetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_ARB, &strategy);
|
|
|
|
|
|
|
|
printf("%s robustness strategy (0x%08x): %s\n",
|
2016-03-28 11:19:31 +00:00
|
|
|
get_api_name(client),
|
2012-12-13 18:29:18 +00:00
|
|
|
strategy,
|
|
|
|
get_strategy_name_gl(strategy));
|
|
|
|
|
|
|
|
printf("%s robustness strategy parsed by GLFW: %s\n",
|
2016-03-28 11:19:31 +00:00
|
|
|
get_api_name(client),
|
2012-12-13 18:29:18 +00:00
|
|
|
get_strategy_name_glfw(robustness));
|
|
|
|
}
|
2010-09-07 15:34:51 +00:00
|
|
|
}
|
|
|
|
|
2012-09-30 13:32:50 +00:00
|
|
|
printf("%s context renderer string: \"%s\"\n",
|
2016-03-28 11:19:31 +00:00
|
|
|
get_api_name(client),
|
2012-09-30 13:32:50 +00:00
|
|
|
glGetString(GL_RENDERER));
|
|
|
|
printf("%s context vendor string: \"%s\"\n",
|
2016-03-28 11:19:31 +00:00
|
|
|
get_api_name(client),
|
2012-09-30 13:32:50 +00:00
|
|
|
glGetString(GL_VENDOR));
|
|
|
|
|
2015-01-26 02:16:43 +00:00
|
|
|
if (major >= 2)
|
2010-09-07 15:34:51 +00:00
|
|
|
{
|
2012-09-30 13:32:50 +00:00
|
|
|
printf("%s context shading language version: \"%s\"\n",
|
2016-03-28 11:19:31 +00:00
|
|
|
get_api_name(client),
|
2011-10-08 22:55:39 +00:00
|
|
|
glGetString(GL_SHADING_LANGUAGE_VERSION));
|
2010-09-07 15:34:51 +00:00
|
|
|
}
|
|
|
|
|
2016-03-28 11:19:31 +00:00
|
|
|
printf("%s framebuffer:\n", get_api_name(client));
|
2015-06-30 16:41:19 +00:00
|
|
|
|
2019-05-19 17:10:35 +00:00
|
|
|
GLint redbits, greenbits, bluebits, alphabits, depthbits, stencilbits;
|
|
|
|
|
2016-03-28 11:19:31 +00:00
|
|
|
if (client == GLFW_OPENGL_API && profile == GLFW_OPENGL_CORE_PROFILE)
|
2015-07-01 12:58:43 +00:00
|
|
|
{
|
|
|
|
glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER,
|
|
|
|
GL_BACK_LEFT,
|
|
|
|
GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE,
|
|
|
|
&redbits);
|
|
|
|
glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER,
|
|
|
|
GL_BACK_LEFT,
|
|
|
|
GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE,
|
|
|
|
&greenbits);
|
|
|
|
glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER,
|
|
|
|
GL_BACK_LEFT,
|
|
|
|
GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE,
|
|
|
|
&bluebits);
|
|
|
|
glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER,
|
|
|
|
GL_BACK_LEFT,
|
|
|
|
GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE,
|
|
|
|
&alphabits);
|
|
|
|
glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER,
|
|
|
|
GL_DEPTH,
|
|
|
|
GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE,
|
|
|
|
&depthbits);
|
|
|
|
glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER,
|
|
|
|
GL_STENCIL,
|
|
|
|
GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE,
|
|
|
|
&stencilbits);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
glGetIntegerv(GL_RED_BITS, &redbits);
|
|
|
|
glGetIntegerv(GL_GREEN_BITS, &greenbits);
|
|
|
|
glGetIntegerv(GL_BLUE_BITS, &bluebits);
|
|
|
|
glGetIntegerv(GL_ALPHA_BITS, &alphabits);
|
|
|
|
glGetIntegerv(GL_DEPTH_BITS, &depthbits);
|
|
|
|
glGetIntegerv(GL_STENCIL_BITS, &stencilbits);
|
|
|
|
}
|
|
|
|
|
|
|
|
printf(" red: %u green: %u blue: %u alpha: %u depth: %u stencil: %u\n",
|
|
|
|
redbits, greenbits, bluebits, alphabits, depthbits, stencilbits);
|
2015-06-30 16:41:19 +00:00
|
|
|
|
2016-03-28 11:19:31 +00:00
|
|
|
if (client == GLFW_OPENGL_ES_API ||
|
2016-09-26 12:55:55 +00:00
|
|
|
GLAD_GL_ARB_multisample ||
|
2015-07-01 12:58:43 +00:00
|
|
|
major > 1 || minor >= 3)
|
|
|
|
{
|
|
|
|
GLint samples, samplebuffers;
|
|
|
|
glGetIntegerv(GL_SAMPLES, &samples);
|
|
|
|
glGetIntegerv(GL_SAMPLE_BUFFERS, &samplebuffers);
|
2015-06-30 16:41:19 +00:00
|
|
|
|
2015-07-01 12:58:43 +00:00
|
|
|
printf(" samples: %u sample buffers: %u\n", samples, samplebuffers);
|
|
|
|
}
|
2015-06-30 16:41:19 +00:00
|
|
|
|
2016-03-28 11:19:31 +00:00
|
|
|
if (client == GLFW_OPENGL_API && profile != GLFW_OPENGL_CORE_PROFILE)
|
2015-07-01 12:58:43 +00:00
|
|
|
{
|
|
|
|
GLint accumredbits, accumgreenbits, accumbluebits, accumalphabits;
|
|
|
|
GLint auxbuffers;
|
2015-06-30 16:41:19 +00:00
|
|
|
|
2015-07-01 12:58:43 +00:00
|
|
|
glGetIntegerv(GL_ACCUM_RED_BITS, &accumredbits);
|
|
|
|
glGetIntegerv(GL_ACCUM_GREEN_BITS, &accumgreenbits);
|
|
|
|
glGetIntegerv(GL_ACCUM_BLUE_BITS, &accumbluebits);
|
|
|
|
glGetIntegerv(GL_ACCUM_ALPHA_BITS, &accumalphabits);
|
|
|
|
glGetIntegerv(GL_AUX_BUFFERS, &auxbuffers);
|
2015-06-30 16:41:19 +00:00
|
|
|
|
2015-07-01 12:58:43 +00:00
|
|
|
printf(" accum red: %u accum green: %u accum blue: %u accum alpha: %u aux buffers: %u\n",
|
|
|
|
accumredbits, accumgreenbits, accumbluebits, accumalphabits, auxbuffers);
|
2015-06-30 16:41:19 +00:00
|
|
|
}
|
|
|
|
|
2015-08-10 18:19:04 +00:00
|
|
|
if (list_extensions)
|
2016-03-28 11:19:31 +00:00
|
|
|
list_context_extensions(client, major, minor);
|
2015-08-10 18:19:04 +00:00
|
|
|
|
2021-04-11 19:26:27 +00:00
|
|
|
glfwDestroyWindow(window);
|
|
|
|
|
|
|
|
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
|
|
|
|
|
|
|
window = glfwCreateWindow(200, 200, "Version", NULL, NULL);
|
|
|
|
if (!window)
|
|
|
|
{
|
|
|
|
glfwTerminate();
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
2017-08-20 12:42:39 +00:00
|
|
|
printf("Vulkan loader: %s\n",
|
2015-08-10 18:19:04 +00:00
|
|
|
glfwVulkanSupported() ? "available" : "missing");
|
|
|
|
|
|
|
|
if (glfwVulkanSupported())
|
|
|
|
{
|
2021-08-24 23:18:03 +00:00
|
|
|
gladLoadVulkanUserPtr(NULL, (GLADuserptrloadfunc) glfwGetInstanceProcAddress, NULL);
|
2015-08-10 18:19:04 +00:00
|
|
|
|
2019-05-19 17:10:35 +00:00
|
|
|
uint32_t loader_version = VK_API_VERSION_1_0;
|
|
|
|
|
2019-05-19 16:55:50 +00:00
|
|
|
if (vkEnumerateInstanceVersion)
|
|
|
|
{
|
|
|
|
uint32_t version;
|
|
|
|
if (vkEnumerateInstanceVersion(&version) == VK_SUCCESS)
|
|
|
|
loader_version = version;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("Vulkan loader API version: %i.%i\n",
|
|
|
|
VK_VERSION_MAJOR(loader_version),
|
|
|
|
VK_VERSION_MINOR(loader_version));
|
|
|
|
|
2019-05-19 17:10:35 +00:00
|
|
|
uint32_t re_count;
|
|
|
|
const char** re = glfwGetRequiredInstanceExtensions(&re_count);
|
2015-08-10 18:19:04 +00:00
|
|
|
|
2016-11-07 18:44:56 +00:00
|
|
|
if (re)
|
|
|
|
{
|
2021-04-11 19:26:27 +00:00
|
|
|
printf("Vulkan window surface required instance extensions:\n");
|
2019-05-19 17:10:35 +00:00
|
|
|
for (uint32_t i = 0; i < re_count; i++)
|
2021-04-11 19:26:27 +00:00
|
|
|
printf(" %s\n", re[i]);
|
2016-11-07 18:44:56 +00:00
|
|
|
}
|
|
|
|
else
|
2021-04-11 19:26:27 +00:00
|
|
|
printf("Vulkan window surface extensions missing\n");
|
2015-08-10 18:19:04 +00:00
|
|
|
|
|
|
|
if (list_extensions)
|
|
|
|
list_vulkan_instance_extensions();
|
|
|
|
|
|
|
|
if (list_layers)
|
|
|
|
list_vulkan_instance_layers();
|
|
|
|
|
2019-05-19 17:10:35 +00:00
|
|
|
VkApplicationInfo ai = { VK_STRUCTURE_TYPE_APPLICATION_INFO };
|
2015-08-10 18:19:04 +00:00
|
|
|
ai.pApplicationName = "glfwinfo";
|
2019-05-19 16:55:50 +00:00
|
|
|
ai.applicationVersion = VK_MAKE_VERSION(GLFW_VERSION_MAJOR,
|
|
|
|
GLFW_VERSION_MINOR,
|
|
|
|
GLFW_VERSION_REVISION);
|
|
|
|
|
|
|
|
if (loader_version >= VK_API_VERSION_1_1)
|
|
|
|
ai.apiVersion = VK_API_VERSION_1_1;
|
|
|
|
else
|
|
|
|
ai.apiVersion = VK_API_VERSION_1_0;
|
2015-08-10 18:19:04 +00:00
|
|
|
|
2019-05-19 17:10:35 +00:00
|
|
|
VkInstanceCreateInfo ici = { VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO };
|
2015-08-10 18:19:04 +00:00
|
|
|
ici.pApplicationInfo = &ai;
|
|
|
|
ici.enabledExtensionCount = re_count;
|
|
|
|
ici.ppEnabledExtensionNames = re;
|
|
|
|
|
2019-05-19 17:10:35 +00:00
|
|
|
VkInstance instance = VK_NULL_HANDLE;
|
|
|
|
|
2015-08-10 18:19:04 +00:00
|
|
|
if (vkCreateInstance(&ici, NULL, &instance) != VK_SUCCESS)
|
|
|
|
{
|
|
|
|
glfwTerminate();
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
2021-08-24 23:18:03 +00:00
|
|
|
gladLoadVulkanUserPtr(NULL, (GLADuserptrloadfunc) glfwGetInstanceProcAddress, instance);
|
2015-08-10 18:19:04 +00:00
|
|
|
|
2021-04-11 19:26:27 +00:00
|
|
|
if (re)
|
|
|
|
{
|
|
|
|
VkSurfaceKHR surface = VK_NULL_HANDLE;
|
|
|
|
|
|
|
|
if (glfwCreateWindowSurface(instance, window, NULL, &surface) == VK_SUCCESS)
|
|
|
|
{
|
|
|
|
printf("Vulkan window surface created successfully\n");
|
|
|
|
vkDestroySurfaceKHR(instance, surface, NULL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
printf("Failed to create Vulkan window surface\n");
|
|
|
|
}
|
|
|
|
|
2019-05-19 17:10:35 +00:00
|
|
|
uint32_t pd_count;
|
2019-05-19 17:26:16 +00:00
|
|
|
vkEnumeratePhysicalDevices(instance, &pd_count, NULL);
|
2019-05-19 17:10:35 +00:00
|
|
|
VkPhysicalDevice* pd = calloc(pd_count, sizeof(VkPhysicalDevice));
|
2019-05-19 17:26:16 +00:00
|
|
|
vkEnumeratePhysicalDevices(instance, &pd_count, pd);
|
2015-08-10 18:19:04 +00:00
|
|
|
|
2019-05-19 17:10:35 +00:00
|
|
|
for (uint32_t i = 0; i < pd_count; i++)
|
2015-08-10 18:19:04 +00:00
|
|
|
{
|
|
|
|
VkPhysicalDeviceProperties pdp;
|
|
|
|
vkGetPhysicalDeviceProperties(pd[i], &pdp);
|
|
|
|
|
2019-05-19 17:27:48 +00:00
|
|
|
printf("Vulkan %s device: \"%s\" (API version %i.%i)\n",
|
2015-08-10 18:19:04 +00:00
|
|
|
get_device_type_name(pdp.deviceType),
|
2019-05-19 16:55:50 +00:00
|
|
|
pdp.deviceName,
|
|
|
|
VK_VERSION_MAJOR(pdp.apiVersion),
|
|
|
|
VK_VERSION_MINOR(pdp.apiVersion));
|
2015-08-10 18:19:04 +00:00
|
|
|
|
2021-04-11 20:12:15 +00:00
|
|
|
uint32_t qfp_count;
|
|
|
|
vkGetPhysicalDeviceQueueFamilyProperties(pd[i], &qfp_count, NULL);
|
|
|
|
|
2021-10-06 17:49:34 +00:00
|
|
|
if (re)
|
2021-04-11 20:12:15 +00:00
|
|
|
{
|
2021-10-06 17:49:34 +00:00
|
|
|
printf("Vulkan device queue family presentation support:\n");
|
|
|
|
for (uint32_t j = 0; j < qfp_count; j++)
|
|
|
|
{
|
|
|
|
printf(" %u: ", j);
|
|
|
|
if (glfwGetPhysicalDevicePresentationSupport(instance, pd[i], j))
|
|
|
|
printf("supported\n");
|
|
|
|
else
|
|
|
|
printf("no\n");
|
|
|
|
}
|
2021-04-11 20:12:15 +00:00
|
|
|
}
|
|
|
|
|
2015-08-10 18:19:04 +00:00
|
|
|
if (list_extensions)
|
|
|
|
list_vulkan_device_extensions(instance, pd[i]);
|
|
|
|
|
|
|
|
if (list_layers)
|
|
|
|
list_vulkan_device_layers(instance, pd[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
free(pd);
|
|
|
|
vkDestroyInstance(instance, NULL);
|
|
|
|
}
|
2010-09-07 15:34:51 +00:00
|
|
|
|
2021-04-11 19:26:27 +00:00
|
|
|
glfwDestroyWindow(window);
|
|
|
|
|
2010-09-07 15:34:51 +00:00
|
|
|
glfwTerminate();
|
|
|
|
exit(EXIT_SUCCESS);
|
|
|
|
}
|
|
|
|
|