Merge branch 'glfw:master' into master

This commit is contained in:
Richard Knight 2021-05-16 09:43:34 +01:00
commit 21de8862e5
35 changed files with 448 additions and 340 deletions

2
.gitignore vendored
View File

@ -77,6 +77,7 @@ examples/splitview
examples/sharing
examples/triangle-opengl
examples/wave
examples/windows
tests/*.app
tests/*.exe
tests/clipboard
@ -87,6 +88,7 @@ tests/gamma
tests/glfwinfo
tests/icon
tests/iconify
tests/inputlag
tests/joysticks
tests/monitors
tests/msaa

View File

@ -69,8 +69,8 @@ endif()
#--------------------------------------------------------------------
# Set compiler specific flags
#--------------------------------------------------------------------
if (MSVC)
if (NOT USE_MSVC_RUNTIME_LIBRARY_DLL)
if (MSVC AND NOT USE_MSVC_RUNTIME_LIBRARY_DLL)
if (${CMAKE_VERSION} VERSION_LESS 3.15)
foreach (flag CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_RELEASE
@ -85,6 +85,8 @@ if (MSVC)
endif()
endforeach()
else()
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
endif()

View File

@ -99,7 +99,7 @@ located in the `deps/` directory.
functions
- [linmath.h](https://github.com/datenwolf/linmath.h) for linear algebra in
examples
- [Nuklear](https://github.com/vurtun/nuklear) for test and example UI
- [Nuklear](https://github.com/Immediate-Mode-UI/Nuklear) for test and example UI
- [stb\_image\_write](https://github.com/nothings/stb) for writing images to disk
The documentation is generated with [Doxygen](http://doxygen.org/) if CMake can
@ -127,7 +127,10 @@ information on what to include when reporting a bug.
- Added `GLFW_FEATURE_UNIMPLEMENTED` error for incomplete backends (#1692)
- Added `GLFW_ANGLE_PLATFORM_TYPE` init hint and `GLFW_ANGLE_PLATFORM_TYPE_*`
values to select ANGLE backend (#1380)
- Added `GLFW_X11_XCB_VULKAN_SURFACE` init hint for selecting X11 Vulkan
surface extension (#1793)
- Made joystick subsystem initialize at first use (#1284,#1646)
- Made `GLFW_DOUBLEBUFFER` a read-only window attribute
- Updated the minimum required CMake version to 3.1
- Disabled tests and examples by default when built as a CMake subdirectory
- Bugfix: The CMake config-file package used an absolute path and was not
@ -137,6 +140,7 @@ information on what to include when reporting a bug.
- Bugfix: Built-in mappings failed because some OEMs re-used VID/PID (#1583)
- Bugfix: Some extension loader headers did not prevent default OpenGL header
inclusion (#1695)
- Bugfix: Buffers were swapped at creation on single-buffered windows (#1873)
- [Win32] Added the `GLFW_WIN32_KEYBOARD_MENU` window hint for enabling access
to the window menu
- [Win32] Added a version info resource to the GLFW DLL
@ -159,6 +163,13 @@ information on what to include when reporting a bug.
configuration change (#1761)
- [Win32] Bugfix: Initialization would segfault on Windows 8 (not 8.1) (#1775)
- [Win32] Bugfix: Duplicate size events were not filtered (#1610)
- [Win32] Bugfix: Full screen windows were incorrectly resized by DPI changes
(#1582)
- [Win32] Bugfix: `GLFW_SCALE_TO_MONITOR` had no effect on systems older than
Windows 10 version 1703 (#1511)
- [Win32] Bugfix: `USE_MSVC_RUNTIME_LIBRARY_DLL` had no effect on CMake 3.15 or
later (#1783,#1796)
- [Win32] Bugfix: Compilation with LLVM for Windows failed (#1807,#1824,#1874)
- [Cocoa] Added support for `VK_EXT_metal_surface` (#1619)
- [Cocoa] Added locating the Vulkan loader at runtime in an application bundle
- [Cocoa] Moved main menu creation to GLFW initialization time (#1649)
@ -178,6 +189,11 @@ information on what to include when reporting a bug.
- [Cocoa] Bugfix: Failing to retrieve the refresh rate of built-in displays
could leak memory
- [Cocoa] Bugfix: Objective-C files were compiled as C with CMake 3.19 (#1787)
- [Cocoa] Bugfix: Duplicate video modes were not filtered out (#1830)
- [Cocoa] Bugfix: Menubar was not clickable on macOS 10.15+ until it lost and
regained focus (#1648,#1802)
- [Cocoa] Bugfix: Monitor name query could segfault on macOS 11 (#1809,#1833)
- [Cocoa] Bugfix: The install name of the installed dylib was relative (#1504)
- [X11] Bugfix: The CMake files did not check for the XInput headers (#1480)
- [X11] Bugfix: Key names were not updated when the keyboard layout changed
(#1462,#1528)
@ -203,6 +219,8 @@ information on what to include when reporting a bug.
combinaitons (#1598)
- [X11] Bugfix: Keys pressed simultaneously with others were not always
reported (#1112,#1415,#1472,#1616)
- [X11] Bugfix: Some window attributes were not applied on leaving fullscreen
(#1863)
- [Wayland] Removed support for `wl_shell` (#1443)
- [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432)
- [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled
@ -212,6 +230,7 @@ information on what to include when reporting a bug.
(#1463)
- [Wayland] Bugfix: Client-Side Decorations were destroyed in the wrong worder
(#1798)
- [Wayland] Bugfix: Monitors physical size could report zero (#1784,#1792)
- [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled
- [NSGL] Removed enforcement of forward-compatible flag for core contexts
- [NSGL] Bugfix: `GLFW_COCOA_RETINA_FRAMEBUFFER` had no effect on newer
@ -246,13 +265,16 @@ GLFW exists because people around the world donated their time and lent their
skills.
- Bobyshev Alexander
- Laurent Aphecetche
- Matt Arsenault
- ashishgamedev
- David Avedissian
- Keith Bauer
- John Bartholomew
- Coşku Baş
- Niklas Behrens
- Andrew Belt
- Nevyn Bengtsson
- Niklas Bergström
- Denis Bernard
- Doug Binks
@ -274,6 +296,7 @@ skills.
- Andrew Corrigan
- Bailey Cosier
- Noel Cower
- CuriouserThing
- Jason Daly
- Jarrod Davis
- Olivier Delannoy
@ -439,6 +462,7 @@ skills.
- Frank Wille
- Andy Williams
- Joel Winarske
- Richard A. Wilkes
- Tatsuya Yatagawa
- Ryogo Yoshimura
- Lukas Zanner

145
deps/linmath.h vendored
View File

@ -1,14 +1,13 @@
#ifndef LINMATH_H
#define LINMATH_H
#include <string.h>
#include <math.h>
#include <string.h>
/* 2020-03-02 Camilla Löwy <elmindreda@elmindreda.org>
* - Added inclusion of string.h for memcpy
* - Replaced tan and acos with tanf and acosf
/* 2021-03-21 Camilla Löwy <elmindreda@elmindreda.org>
* - Replaced double constants with float equivalents
*/
#include <string.h>
#ifdef LINMATH_NO_INLINE
#define LINMATH_H_FUNC static
@ -38,7 +37,7 @@ LINMATH_H_FUNC void vec##n##_scale(vec##n r, vec##n const v, float const s) \
} \
LINMATH_H_FUNC float vec##n##_mul_inner(vec##n const a, vec##n const b) \
{ \
float p = 0.; \
float p = 0.f; \
int i; \
for(i=0; i<n; ++i) \
p += b[i]*a[i]; \
@ -64,6 +63,12 @@ LINMATH_H_FUNC void vec##n##_max(vec##n r, vec##n const a, vec##n const b) \
int i; \
for(i=0; i<n; ++i) \
r[i] = a[i]>b[i] ? a[i] : b[i]; \
} \
LINMATH_H_FUNC void vec##n##_dup(vec##n r, vec##n const src) \
{ \
int i; \
for(i=0; i<n; ++i) \
r[i] = src[i]; \
}
LINMATH_H_DEFINE_VEC(2)
@ -85,7 +90,7 @@ LINMATH_H_FUNC void vec3_reflect(vec3 r, vec3 const v, vec3 const n)
r[i] = v[i] - p*n[i];
}
LINMATH_H_FUNC void vec4_mul_cross(vec4 r, vec4 a, vec4 b)
LINMATH_H_FUNC void vec4_mul_cross(vec4 r, vec4 const a, vec4 const b)
{
r[0] = a[1]*b[2] - a[2]*b[1];
r[1] = a[2]*b[0] - a[0]*b[2];
@ -93,7 +98,7 @@ LINMATH_H_FUNC void vec4_mul_cross(vec4 r, vec4 a, vec4 b)
r[3] = 1.f;
}
LINMATH_H_FUNC void vec4_reflect(vec4 r, vec4 v, vec4 n)
LINMATH_H_FUNC void vec4_reflect(vec4 r, vec4 const v, vec4 const n)
{
float p = 2.f*vec4_mul_inner(v, n);
int i;
@ -109,61 +114,59 @@ LINMATH_H_FUNC void mat4x4_identity(mat4x4 M)
for(j=0; j<4; ++j)
M[i][j] = i==j ? 1.f : 0.f;
}
LINMATH_H_FUNC void mat4x4_dup(mat4x4 M, mat4x4 N)
LINMATH_H_FUNC void mat4x4_dup(mat4x4 M, mat4x4 const N)
{
int i, j;
int i;
for(i=0; i<4; ++i)
for(j=0; j<4; ++j)
M[i][j] = N[i][j];
vec4_dup(M[i], N[i]);
}
LINMATH_H_FUNC void mat4x4_row(vec4 r, mat4x4 M, int i)
LINMATH_H_FUNC void mat4x4_row(vec4 r, mat4x4 const M, int i)
{
int k;
for(k=0; k<4; ++k)
r[k] = M[k][i];
}
LINMATH_H_FUNC void mat4x4_col(vec4 r, mat4x4 M, int i)
LINMATH_H_FUNC void mat4x4_col(vec4 r, mat4x4 const M, int i)
{
int k;
for(k=0; k<4; ++k)
r[k] = M[i][k];
}
LINMATH_H_FUNC void mat4x4_transpose(mat4x4 M, mat4x4 N)
LINMATH_H_FUNC void mat4x4_transpose(mat4x4 M, mat4x4 const N)
{
// Note: if M and N are the same, the user has to
// explicitly make a copy of M and set it to N.
int i, j;
for(j=0; j<4; ++j)
for(i=0; i<4; ++i)
M[i][j] = N[j][i];
}
LINMATH_H_FUNC void mat4x4_add(mat4x4 M, mat4x4 a, mat4x4 b)
LINMATH_H_FUNC void mat4x4_add(mat4x4 M, mat4x4 const a, mat4x4 const b)
{
int i;
for(i=0; i<4; ++i)
vec4_add(M[i], a[i], b[i]);
}
LINMATH_H_FUNC void mat4x4_sub(mat4x4 M, mat4x4 a, mat4x4 b)
LINMATH_H_FUNC void mat4x4_sub(mat4x4 M, mat4x4 const a, mat4x4 const b)
{
int i;
for(i=0; i<4; ++i)
vec4_sub(M[i], a[i], b[i]);
}
LINMATH_H_FUNC void mat4x4_scale(mat4x4 M, mat4x4 a, float k)
LINMATH_H_FUNC void mat4x4_scale(mat4x4 M, mat4x4 const a, float k)
{
int i;
for(i=0; i<4; ++i)
vec4_scale(M[i], a[i], k);
}
LINMATH_H_FUNC void mat4x4_scale_aniso(mat4x4 M, mat4x4 a, float x, float y, float z)
LINMATH_H_FUNC void mat4x4_scale_aniso(mat4x4 M, mat4x4 const a, float x, float y, float z)
{
int i;
vec4_scale(M[0], a[0], x);
vec4_scale(M[1], a[1], y);
vec4_scale(M[2], a[2], z);
for(i = 0; i < 4; ++i) {
M[3][i] = a[3][i];
vec4_dup(M[3], a[3]);
}
}
LINMATH_H_FUNC void mat4x4_mul(mat4x4 M, mat4x4 a, mat4x4 b)
LINMATH_H_FUNC void mat4x4_mul(mat4x4 M, mat4x4 const a, mat4x4 const b)
{
mat4x4 temp;
int k, r, c;
@ -174,7 +177,7 @@ LINMATH_H_FUNC void mat4x4_mul(mat4x4 M, mat4x4 a, mat4x4 b)
}
mat4x4_dup(M, temp);
}
LINMATH_H_FUNC void mat4x4_mul_vec4(vec4 r, mat4x4 M, vec4 v)
LINMATH_H_FUNC void mat4x4_mul_vec4(vec4 r, mat4x4 const M, vec4 const v)
{
int i, j;
for(j=0; j<4; ++j) {
@ -200,13 +203,13 @@ LINMATH_H_FUNC void mat4x4_translate_in_place(mat4x4 M, float x, float y, float
M[3][i] += vec4_mul_inner(r, t);
}
}
LINMATH_H_FUNC void mat4x4_from_vec3_mul_outer(mat4x4 M, vec3 a, vec3 b)
LINMATH_H_FUNC void mat4x4_from_vec3_mul_outer(mat4x4 M, vec3 const a, vec3 const b)
{
int i, j;
for(i=0; i<4; ++i) for(j=0; j<4; ++j)
M[i][j] = i<3 && j<3 ? a[i] * b[j] : 0.f;
}
LINMATH_H_FUNC void mat4x4_rotate(mat4x4 R, mat4x4 M, float x, float y, float z, float angle)
LINMATH_H_FUNC void mat4x4_rotate(mat4x4 R, mat4x4 const M, float x, float y, float z, float angle)
{
float s = sinf(angle);
float c = cosf(angle);
@ -234,13 +237,13 @@ LINMATH_H_FUNC void mat4x4_rotate(mat4x4 R, mat4x4 M, float x, float y, float z,
mat4x4_add(T, T, C);
mat4x4_add(T, T, S);
T[3][3] = 1.;
T[3][3] = 1.f;
mat4x4_mul(R, M, T);
} else {
mat4x4_dup(R, M);
}
}
LINMATH_H_FUNC void mat4x4_rotate_X(mat4x4 Q, mat4x4 M, float angle)
LINMATH_H_FUNC void mat4x4_rotate_X(mat4x4 Q, mat4x4 const M, float angle)
{
float s = sinf(angle);
float c = cosf(angle);
@ -252,7 +255,7 @@ LINMATH_H_FUNC void mat4x4_rotate_X(mat4x4 Q, mat4x4 M, float angle)
};
mat4x4_mul(Q, M, R);
}
LINMATH_H_FUNC void mat4x4_rotate_Y(mat4x4 Q, mat4x4 M, float angle)
LINMATH_H_FUNC void mat4x4_rotate_Y(mat4x4 Q, mat4x4 const M, float angle)
{
float s = sinf(angle);
float c = cosf(angle);
@ -264,7 +267,7 @@ LINMATH_H_FUNC void mat4x4_rotate_Y(mat4x4 Q, mat4x4 M, float angle)
};
mat4x4_mul(Q, M, R);
}
LINMATH_H_FUNC void mat4x4_rotate_Z(mat4x4 Q, mat4x4 M, float angle)
LINMATH_H_FUNC void mat4x4_rotate_Z(mat4x4 Q, mat4x4 const M, float angle)
{
float s = sinf(angle);
float c = cosf(angle);
@ -276,7 +279,7 @@ LINMATH_H_FUNC void mat4x4_rotate_Z(mat4x4 Q, mat4x4 M, float angle)
};
mat4x4_mul(Q, M, R);
}
LINMATH_H_FUNC void mat4x4_invert(mat4x4 T, mat4x4 M)
LINMATH_H_FUNC void mat4x4_invert(mat4x4 T, mat4x4 const M)
{
float s[6];
float c[6];
@ -317,10 +320,10 @@ LINMATH_H_FUNC void mat4x4_invert(mat4x4 T, mat4x4 M)
T[3][2] = (-M[3][0] * s[3] + M[3][1] * s[1] - M[3][2] * s[0]) * idet;
T[3][3] = ( M[2][0] * s[3] - M[2][1] * s[1] + M[2][2] * s[0]) * idet;
}
LINMATH_H_FUNC void mat4x4_orthonormalize(mat4x4 R, mat4x4 M)
LINMATH_H_FUNC void mat4x4_orthonormalize(mat4x4 R, mat4x4 const M)
{
mat4x4_dup(R, M);
float s = 1.;
float s = 1.f;
vec3 h;
vec3_norm(R[2], R[2]);
@ -398,7 +401,7 @@ LINMATH_H_FUNC void mat4x4_perspective(mat4x4 m, float y_fov, float aspect, floa
m[3][2] = -((2.f * f * n) / (f - n));
m[3][3] = 0.f;
}
LINMATH_H_FUNC void mat4x4_look_at(mat4x4 m, vec3 eye, vec3 center, vec3 up)
LINMATH_H_FUNC void mat4x4_look_at(mat4x4 m, vec3 const eye, vec3 const center, vec3 const up)
{
/* Adapted from Android's OpenGL Matrix.java. */
/* See the OpenGL GLUT documentation for gluLookAt for a description */
@ -441,24 +444,18 @@ LINMATH_H_FUNC void mat4x4_look_at(mat4x4 m, vec3 eye, vec3 center, vec3 up)
}
typedef float quat[4];
#define quat_add vec4_add
#define quat_sub vec4_sub
#define quat_norm vec4_norm
#define quat_scale vec4_scale
#define quat_mul_inner vec4_mul_inner
LINMATH_H_FUNC void quat_identity(quat q)
{
q[0] = q[1] = q[2] = 0.f;
q[3] = 1.f;
}
LINMATH_H_FUNC void quat_add(quat r, quat a, quat b)
{
int i;
for(i=0; i<4; ++i)
r[i] = a[i] + b[i];
}
LINMATH_H_FUNC void quat_sub(quat r, quat a, quat b)
{
int i;
for(i=0; i<4; ++i)
r[i] = a[i] - b[i];
}
LINMATH_H_FUNC void quat_mul(quat r, quat p, quat q)
LINMATH_H_FUNC void quat_mul(quat r, quat const p, quat const q)
{
vec3 w;
vec3_mul_cross(r, p, q);
@ -468,37 +465,22 @@ LINMATH_H_FUNC void quat_mul(quat r, quat p, quat q)
vec3_add(r, r, w);
r[3] = p[3]*q[3] - vec3_mul_inner(p, q);
}
LINMATH_H_FUNC void quat_scale(quat r, quat v, float s)
{
int i;
for(i=0; i<4; ++i)
r[i] = v[i] * s;
}
LINMATH_H_FUNC float quat_inner_product(quat a, quat b)
{
float p = 0.f;
int i;
for(i=0; i<4; ++i)
p += b[i]*a[i];
return p;
}
LINMATH_H_FUNC void quat_conj(quat r, quat q)
LINMATH_H_FUNC void quat_conj(quat r, quat const q)
{
int i;
for(i=0; i<3; ++i)
r[i] = -q[i];
r[3] = q[3];
}
LINMATH_H_FUNC void quat_rotate(quat r, float angle, vec3 axis) {
vec3 v;
vec3_scale(v, axis, sinf(angle / 2));
int i;
for(i=0; i<3; ++i)
r[i] = v[i];
r[3] = cosf(angle / 2);
LINMATH_H_FUNC void quat_rotate(quat r, float angle, vec3 const axis) {
vec3 axis_norm;
vec3_norm(axis_norm, axis);
float s = sinf(angle / 2);
float c = cosf(angle / 2);
vec3_scale(r, axis_norm, s);
r[3] = c;
}
#define quat_norm vec4_norm
LINMATH_H_FUNC void quat_mul_vec3(vec3 r, quat q, vec3 v)
LINMATH_H_FUNC void quat_mul_vec3(vec3 r, quat const q, vec3 const v)
{
/*
* Method by Fabian 'ryg' Giessen (of Farbrausch)
@ -518,7 +500,7 @@ v' = v + q.w * t + cross(q.xyz, t)
vec3_add(r, v, t);
vec3_add(r, r, u);
}
LINMATH_H_FUNC void mat4x4_from_quat(mat4x4 M, quat q)
LINMATH_H_FUNC void mat4x4_from_quat(mat4x4 M, quat const q)
{
float a = q[3];
float b = q[0];
@ -548,18 +530,21 @@ LINMATH_H_FUNC void mat4x4_from_quat(mat4x4 M, quat q)
M[3][3] = 1.f;
}
LINMATH_H_FUNC void mat4x4o_mul_quat(mat4x4 R, mat4x4 M, quat q)
LINMATH_H_FUNC void mat4x4o_mul_quat(mat4x4 R, mat4x4 const M, quat const q)
{
/* XXX: The way this is written only works for othogonal matrices. */
/* XXX: The way this is written only works for orthogonal matrices. */
/* TODO: Take care of non-orthogonal case. */
quat_mul_vec3(R[0], q, M[0]);
quat_mul_vec3(R[1], q, M[1]);
quat_mul_vec3(R[2], q, M[2]);
R[3][0] = R[3][1] = R[3][2] = 0.f;
R[3][3] = 1.f;
R[0][3] = M[0][3];
R[1][3] = M[1][3];
R[2][3] = M[2][3];
R[3][3] = M[3][3]; // typically 1.0, but here we make it general
}
LINMATH_H_FUNC void quat_from_mat4x4(quat q, mat4x4 M)
LINMATH_H_FUNC void quat_from_mat4x4(quat q, mat4x4 const M)
{
float r=0.f;
int i;
@ -589,13 +574,13 @@ LINMATH_H_FUNC void quat_from_mat4x4(quat q, mat4x4 M)
q[3] = (M[p[2]][p[1]] - M[p[1]][p[2]])/(2.f*r);
}
LINMATH_H_FUNC void mat4x4_arcball(mat4x4 R, mat4x4 M, vec2 _a, vec2 _b, float s)
LINMATH_H_FUNC void mat4x4_arcball(mat4x4 R, mat4x4 const M, vec2 const _a, vec2 const _b, float s)
{
vec2 a; memcpy(a, _a, sizeof(a));
vec2 b; memcpy(b, _b, sizeof(b));
float z_a = 0.;
float z_b = 0.;
float z_a = 0.f;
float z_b = 0.f;
if(vec2_len(a) < 1.f) {
z_a = sqrtf(1.f - vec2_mul_inner(a, a));
@ -615,7 +600,7 @@ LINMATH_H_FUNC void mat4x4_arcball(mat4x4 R, mat4x4 M, vec2 _a, vec2 _b, float s
vec3 c_;
vec3_mul_cross(c_, a_, b_);
float const angle = acosf(vec3_mul_inner(a_, b_)) * s;
float const angle = acos(vec3_mul_inner(a_, b_)) * s;
mat4x4_rotate(R, M, c_[0], c_[1], c_[2], angle);
}
#endif

View File

@ -1074,13 +1074,6 @@ VERBATIM_HEADERS = YES
ALPHABETICAL_INDEX = YES
# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in
# which the alphabetical index list will be split.
# Minimum value: 1, maximum value: 20, default value: 5.
# This tag requires that the tag ALPHABETICAL_INDEX is set to YES.
COLS_IN_ALPHA_INDEX = 5
# In case all classes in a project start with a common prefix, all classes will
# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag
# can be used to specify a prefix (or a list of prefixes) that should be ignored

View File

@ -235,6 +235,10 @@ __USE_MSVC_RUNTIME_LIBRARY_DLL__ determines whether to use the DLL version or th
static library version of the Visual C++ runtime library. If set to `ON`, the
DLL version of the Visual C++ library is used.
@note On CMake 3.15 and later you can set the
[CMAKE_MSVC_RUNTIME_LIBRARY](https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html)
variable instead of this option.
@anchor GLFW_USE_HYBRID_HPG
__GLFW_USE_HYBRID_HPG__ determines whether to export the `NvOptimusEnablement` and
`AmdPowerXpressRequestHighPerformance` symbols, which force the use of the

View File

@ -138,9 +138,9 @@ as extensions until they become obsolete.
An extension is defined by:
- An extension name (e.g. `GL_ARB_debug_output`)
- New OpenGL tokens (e.g. `GL_DEBUG_SEVERITY_HIGH_ARB`)
- New OpenGL functions (e.g. `glGetDebugMessageLogARB`)
- An extension name (e.g. `GL_ARB_gl_spirv`)
- New OpenGL tokens (e.g. `GL_SPIR_V_BINARY_ARB`)
- New OpenGL functions (e.g. `glSpecializeShaderARB`)
Note the `ARB` affix, which stands for Architecture Review Board and is used
for official extensions. The extension above was created by the ARB, but there
@ -225,9 +225,9 @@ To check whether a specific extension is supported, use the `GLAD_GL_xxx`
booleans.
@code
if (GLAD_GL_ARB_debug_output)
if (GLAD_GL_ARB_gl_spirv)
{
// Use GL_ARB_debug_output
// Use GL_ARB_gl_spirv
}
@endcode
@ -259,8 +259,8 @@ included in your development environment may be several years out of date and
may not include the extensions you wish to use.
The header defines function pointer types for all functions of all extensions it
supports. These have names like `PFNGLGETDEBUGMESSAGELOGARBPROC` (for
`glGetDebugMessageLogARB`), i.e. the name is made uppercase and `PFN` (pointer
supports. These have names like `PFNGLSPECIALIZESHADERARBPROC` (for
`glSpecializeShaderARB`), i.e. the name is made uppercase and `PFN` (pointer
to function) and `PROC` (procedure) are added to the ends.
To include the extension header, define @ref GLFW_INCLUDE_GLEXT before including
@ -280,7 +280,7 @@ is necessary to check at run-time whether the context supports the extension.
This is done with @ref glfwExtensionSupported.
@code
if (glfwExtensionSupported("GL_ARB_debug_output"))
if (glfwExtensionSupported("GL_ARB_gl_spirv"))
{
// The extension is supported by the current context
}
@ -299,7 +299,7 @@ your operating system, making it necessary to fetch them at run time. You can
retrieve pointers to these functions with @ref glfwGetProcAddress.
@code
PFNGLGETDEBUGMESSAGELOGARBPROC pfnGetDebugMessageLog = glfwGetProcAddress("glGetDebugMessageLogARB");
PFNGLSPECIALIZESHADERARBPROC pfnSpecializeShaderARB = glfwGetProcAddress("glSpecializeShaderARB");
@endcode
In general, you should avoid giving the function pointer variables the (exact)
@ -313,28 +313,28 @@ when used together.
#define GLFW_INCLUDE_GLEXT
#include <GLFW/glfw3.h>
#define glGetDebugMessageLogARB pfnGetDebugMessageLog
PFNGLGETDEBUGMESSAGELOGARBPROC pfnGetDebugMessageLog;
#define glSpecializeShaderARB pfnSpecializeShaderARB
PFNGLSPECIALIZESHADERARBPROC pfnSpecializeShaderARB;
// Flag indicating whether the extension is supported
int has_ARB_debug_output = 0;
int has_ARB_gl_spirv = 0;
void load_extensions(void)
{
if (glfwExtensionSupported("GL_ARB_debug_output"))
if (glfwExtensionSupported("GL_ARB_gl_spirv"))
{
pfnGetDebugMessageLog = (PFNGLGETDEBUGMESSAGELOGARBPROC)
glfwGetProcAddress("glGetDebugMessageLogARB");
has_ARB_debug_output = 1;
pfnSpecializeShaderARB = (PFNGLSPECIALIZESHADERARBPROC)
glfwGetProcAddress("glSpecializeShaderARB");
has_ARB_gl_spirv = 1;
}
}
void some_function(void)
{
if (has_ARB_debug_output)
if (has_ARB_gl_spirv)
{
// Now the extension function can be called as usual
glGetDebugMessageLogARB(...);
glSpecializeShaderARB(...);
}
}
@endcode

View File

@ -103,7 +103,6 @@ one of `GLFW_ANGLE_PLATFORM_TYPE_NONE`, `GLFW_ANGLE_PLATFORM_TYPE_OPENGL`,
`GLFW_ANGLE_PLATFORM_TYPE_D3D11`, `GLFW_ANGLE_PLATFORM_TYPE_VULKAN` and
`GLFW_ANGLE_PLATFORM_TYPE_METAL`.
@par
The ANGLE platform type is specified via the `EGL_ANGLE_platform_angle`
extension. This extension is not used if this hint is
`GLFW_ANGLE_PLATFORM_TYPE_NONE`, which is the default value.
@ -124,14 +123,24 @@ a nib or manually by GLFW. Possible values are `GLFW_TRUE` and `GLFW_FALSE`.
This is ignored on other platforms.
@subsubsection init_hints_x11 X11 specific init hints
@anchor GLFW_X11_XCB_VULKAN_SURFACE_hint
__GLFW_X11_XCB_VULKAN_SURFACE__ specifies whether to prefer the
`VK_KHR_xcb_surface` extension for creating Vulkan surfaces, or whether to use
the `VK_KHR_xlib_surface` extension. Possible values are `GLFW_TRUE` and
`GLFW_FALSE`. This is ignored on other platforms.
@subsubsection init_hints_values Supported and default values
Initialization hint | Default value | Supported values
------------------------------- | ------------------------------- | ----------------
-------------------------------- | ------------------------------- | ----------------
@ref GLFW_JOYSTICK_HAT_BUTTONS | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
@ref GLFW_ANGLE_PLATFORM_TYPE | `GLFW_ANGLE_PLATFORM_TYPE_NONE` | `GLFW_ANGLE_PLATFORM_TYPE_NONE`, `GLFW_ANGLE_PLATFORM_TYPE_OPENGL`, `GLFW_ANGLE_PLATFORM_TYPE_OPENGLES`, `GLFW_ANGLE_PLATFORM_TYPE_D3D9`, `GLFW_ANGLE_PLATFORM_TYPE_D3D11`, `GLFW_ANGLE_PLATFORM_TYPE_VULKAN` or `GLFW_ANGLE_PLATFORM_TYPE_METAL`
@ref GLFW_COCOA_CHDIR_RESOURCES | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
@ref GLFW_COCOA_MENUBAR | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
@ref GLFW_X11_XCB_VULKAN_SURFACE | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
@subsection intro_init_terminate Terminating GLFW

View File

@ -142,6 +142,7 @@ then GLFW will fail to initialize.
- @ref GLFW_ANGLE_PLATFORM_TYPE_D3D11
- @ref GLFW_ANGLE_PLATFORM_TYPE_VULKAN
- @ref GLFW_ANGLE_PLATFORM_TYPE_METAL
- @ref GLFW_X11_XCB_VULKAN_SURFACE
@section news_archive Release notes for earlier versions

View File

@ -93,7 +93,7 @@ if (glfwVulkanSupported())
This function returns `GLFW_TRUE` if the Vulkan loader and any minimally
functional ICD was found.
If if one or both were not found, calling any other Vulkan related GLFW function
If one or both were not found, calling any other Vulkan related GLFW function
will generate a @ref GLFW_API_UNAVAILABLE error.

View File

@ -236,7 +236,8 @@ does not affect window decorations. Possible values are `GLFW_TRUE` and
@anchor GLFW_FOCUS_ON_SHOW_hint
__GLFW_FOCUS_ON_SHOW__ specifies whether the window will be given input
focus when @ref glfwShowWindow is called. Possible values are `GLFW_TRUE` and `GLFW_FALSE`.
focus when @ref glfwShowWindow is called. Possible values are `GLFW_TRUE` and
`GLFW_FALSE`.
@anchor GLFW_SCALE_TO_MONITOR
__GLFW_SCALE_TO_MONITOR__ specified whether the window content area should be
@ -278,7 +279,6 @@ __GLFW_ACCUM_ALPHA_BITS__ specify the desired bit depths of the various
components of the accumulation buffer. A value of `GLFW_DONT_CARE` means the
application has no preference.
@par
Accumulation buffers are a legacy OpenGL feature and should not be used in new
code.
@ -286,7 +286,6 @@ code.
__GLFW_AUX_BUFFERS__ specifies the desired number of auxiliary buffers. A value
of `GLFW_DONT_CARE` means the application has no preference.
@par
Auxiliary buffers are a legacy OpenGL feature and should not be used in new
code.
@ -303,16 +302,15 @@ the application has no preference.
__GLFW_SRGB_CAPABLE__ specifies whether the framebuffer should be sRGB capable.
Possible values are `GLFW_TRUE` and `GLFW_FALSE`.
@par
__OpenGL:__ If enabled and supported by the system, the `GL_FRAMEBUFFER_SRGB`
enable will control sRGB rendering. By default, sRGB rendering will be
disabled.
@note __OpenGL:__ If enabled and supported by the system, the
`GL_FRAMEBUFFER_SRGB` enable will control sRGB rendering. By default, sRGB
rendering will be disabled.
@par
__OpenGL ES:__ If enabled and supported by the system, the context will always
have sRGB rendering enabled.
@note __OpenGL ES:__ If enabled and supported by the system, the context will
always have sRGB rendering enabled.
@anchor GLFW_DOUBLEBUFFER
@anchor GLFW_DOUBLEBUFFER_hint
__GLFW_DOUBLEBUFFER__ specifies whether the framebuffer should be double
buffered. You nearly always want to use double buffering. This is a hard
constraint. Possible values are `GLFW_TRUE` and `GLFW_FALSE`.
@ -339,28 +337,22 @@ create the context. Possible values are `GLFW_NATIVE_CONTEXT_API`,
`GLFW_EGL_CONTEXT_API` and `GLFW_OSMESA_CONTEXT_API`. This is a hard
constraint. If no client API is requested, this hint is ignored.
@par
@macos The EGL API is not available on this platform and requests to use it
will fail.
An [extension loader library](@ref context_glext_auto) that assumes it knows
which API was used to create the current context may fail if you change this
hint. This can be resolved by having it load functions via @ref
glfwGetProcAddress.
@par
__Wayland:__ The EGL API _is_ the native context creation API, so this hint
@note @wayland The EGL API _is_ the native context creation API, so this hint
will have no effect.
@par
__OSMesa:__ As its name implies, an OpenGL context created with OSMesa does not
update the window contents when its buffers are swapped. Use OpenGL functions
or the OSMesa native access functions @ref glfwGetOSMesaColorBuffer and @ref
glfwGetOSMesaDepthBuffer to retrieve the framebuffer contents.
@note @x11 On some Linux systems, creating contexts via both the native and EGL
APIs in a single process will cause the application to segfault. Stick to one
API or the other on Linux for now.
@note An OpenGL extension loader library that assumes it knows which context
creation API is used on a given platform may fail if you change this hint. This
can be resolved by having it load via @ref glfwGetProcAddress, which always uses
the selected API.
@bug On some Linux systems, creating contexts via both the native and EGL APIs
in a single process will cause the application to segfault. Stick to one API or
the other on Linux for now.
@note __OSMesa:__ As its name implies, an OpenGL context created with OSMesa
does not update the window contents when its buffers are swapped. Use OpenGL
functions or the OSMesa native access functions @ref glfwGetOSMesaColorBuffer
and @ref glfwGetOSMesaDepthBuffer to retrieve the framebuffer contents.
@anchor GLFW_CONTEXT_VERSION_MAJOR_hint
@anchor GLFW_CONTEXT_VERSION_MINOR_hint
@ -368,27 +360,24 @@ __GLFW_CONTEXT_VERSION_MAJOR__ and __GLFW_CONTEXT_VERSION_MINOR__ specify the
client API version that the created context must be compatible with. The exact
behavior of these hints depend on the requested client API.
@note Do not confuse these hints with `GLFW_VERSION_MAJOR` and
`GLFW_VERSION_MINOR`, which provide the API version of the GLFW header.
@par
__OpenGL:__ These hints are not hard constraints, but creation will fail if the
OpenGL version of the created context is less than the one requested. It is
therefore perfectly safe to use the default of version 1.0 for legacy code and
you will still get backwards-compatible contexts of version 3.0 and above when
available.
@par
While there is no way to ask the driver for a context of the highest supported
version, GLFW will attempt to provide this when you ask for a version 1.0
context, which is the default for these hints.
@par
__OpenGL ES:__ These hints are not hard constraints, but creation will fail if
the OpenGL ES version of the created context is less than the one requested.
Additionally, OpenGL ES 1.x cannot be returned if 2.0 or later was requested,
and vice versa. This is because OpenGL ES 3.x is backward compatible with 2.0,
but OpenGL ES 2.0 is not backward compatible with 1.x.
Do not confuse these hints with @ref GLFW_VERSION_MAJOR and @ref
GLFW_VERSION_MINOR, which provide the API version of the GLFW header.
@note __OpenGL:__ These hints are not hard constraints, but creation will fail
if the OpenGL version of the created context is less than the one requested. It
is therefore perfectly safe to use the default of version 1.0 for legacy code
and you will still get backwards-compatible contexts of version 3.0 and above
when available.
@note __OpenGL ES:__ These hints are not hard constraints, but creation will
fail if the OpenGL ES version of the created context is less than the one
requested. Additionally, OpenGL ES 1.x cannot be returned if 2.0 or later was
requested, and vice versa. This is because OpenGL ES 3.x is backward compatible
with 2.0, but OpenGL ES 2.0 is not backward compatible with 1.x.
@note @macos The OS only supports core profile contexts for OpenGL versions 3.2
and later. Before creating an OpenGL context of version 3.2 or later you must
@ -401,7 +390,6 @@ forward-compatible, i.e. one where all functionality deprecated in the requested
version of OpenGL is removed. This must only be used if the requested OpenGL
version is 3.0 or above. If OpenGL ES is requested, this hint is ignored.
@par
Forward-compatibility is described in detail in the
[OpenGL Reference Manual](https://www.opengl.org/registry/).
@ -411,13 +399,11 @@ __GLFW_CONTEXT_DEBUG__ specifies whether the context should be created in debug
mode, which may provide additional error and diagnostic reporting functionality.
Possible values are `GLFW_TRUE` and `GLFW_FALSE`.
@par
Debug contexts for OpenGL and OpenGL ES are described in detail by the
[GL_KHR_debug](https://www.khronos.org/registry/OpenGL/extensions/KHR/KHR_debug.txt)
extension.
@par
This is the new name, introduced in GLFW 3.4. The older
@note `GLFW_CONTEXT_DEBUG` is the new name introduced in GLFW 3.4. The older
`GLFW_OPENGL_DEBUG_CONTEXT` name is also available for compatibility.
@anchor GLFW_OPENGL_PROFILE_hint
@ -428,7 +414,6 @@ a specific profile. If requesting an OpenGL version below 3.2,
`GLFW_OPENGL_ANY_PROFILE` must be used. If OpenGL ES is requested, this hint
is ignored.
@par
OpenGL profiles are described in detail in the
[OpenGL Reference Manual](https://www.opengl.org/registry/).
@ -448,7 +433,6 @@ the pipeline will be flushed whenever the context is released from being the
current one. If the behavior is `GLFW_RELEASE_BEHAVIOR_NONE`, the pipeline will
not be flushed on release.
@par
Context release behaviors are described in detail by the
[GL_KHR_context_flush_control](https://www.opengl.org/registry/specs/KHR/context_flush_control.txt)
extension.
@ -458,7 +442,6 @@ __GLFW_CONTEXT_NO_ERROR__ specifies whether errors should be generated by the
context. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. If enabled,
situations that would have generated errors instead cause undefined behavior.
@par
The no error mode for OpenGL and OpenGL ES is described in detail by the
[GL_KHR_no_error](https://www.opengl.org/registry/specs/KHR/no_error.txt)
extension.
@ -492,12 +475,10 @@ run on the discrete GPU. This only affects systems with both integrated and
discrete GPUs. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. This is
ignored on other platforms.
@par
Simpler programs and tools may want to enable this to save power, while games
and other applications performing advanced rendering will want to leave it
disabled.
@par
A bundled application that wishes to participate in Automatic Graphics Switching
should also declare this in its `Info.plist` by setting the
`NSSupportsAutomaticGraphicsSwitching` key to `true`.
@ -1397,9 +1378,11 @@ if the window's context supports robustness, or `GLFW_NO_ROBUSTNESS` otherwise.
@subsubsection window_attribs_fb Framebuffer related attributes
GLFW does not expose attributes of the default framebuffer (i.e. the framebuffer
attached to the window) as these can be queried directly with either OpenGL,
OpenGL ES or Vulkan.
GLFW does not expose most attributes of the default framebuffer (i.e. the
framebuffer attached to the window) as these can be queried directly with either
OpenGL, OpenGL ES or Vulkan. The one exception is
[GLFW_DOUBLEBUFFER](@ref GLFW_DOUBLEBUFFER_attrib), as this is not provided by
OpenGL ES.
If you are using version 3.0 or later of OpenGL or OpenGL ES, the
`glGetFramebufferAttachmentParameteriv` function can be used to retrieve the
@ -1425,6 +1408,11 @@ alpha sizes are queried from the `GL_BACK_LEFT`, while the depth and stencil
sizes are queried from the `GL_DEPTH` and `GL_STENCIL` attachments,
respectively.
@anchor GLFW_DOUBLEBUFFER_attrib
__GLFW_DOUBLEBUFFER__ indicates whether the specified window is double-buffered
when rendering with OpenGL or OpenGL ES. This can be set before creation with
the [GLFW_DOUBLEBUFFER](@ref GLFW_DOUBLEBUFFER_hint) window hint.
@section buffer_swap Buffer swapping

View File

@ -7,7 +7,8 @@ if (MATH_LIBRARY)
link_libraries("${MATH_LIBRARY}")
endif()
if (MSVC)
# Workaround for the MS CRT deprecating parts of the standard library
if (MSVC OR CMAKE_C_SIMULATE_ID STREQUAL "MSVC")
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif()
@ -54,9 +55,13 @@ if (GLFW_USE_OSMESA)
endif()
if (MSVC)
# Tell MSVC to use main instead of WinMain for Windows subsystem executables
# Tell MSVC to use main instead of WinMain
set_target_properties(${GUI_ONLY_BINARIES} PROPERTIES
LINK_FLAGS "/ENTRY:mainCRTStartup")
elseif (CMAKE_C_SIMULATE_ID STREQUAL "MSVC")
# Tell Clang using MS CRT to use main instead of WinMain
set_target_properties(${GUI_ONLY_BINARIES} PROPERTIES
LINK_FLAGS "-Wl,/entry:mainCRTStartup")
endif()
if (APPLE)

View File

@ -276,23 +276,24 @@ extern "C" {
/*! @name GLFW version macros
* @{ */
/*! @brief The major version number of the GLFW library.
/*! @brief The major version number of the GLFW header.
*
* This is incremented when the API is changed in non-compatible ways.
* The major version number of the GLFW header. This is incremented when the
* API is changed in non-compatible ways.
* @ingroup init
*/
#define GLFW_VERSION_MAJOR 3
/*! @brief The minor version number of the GLFW library.
/*! @brief The minor version number of the GLFW header.
*
* This is incremented when features are added to the API but it remains
* backward-compatible.
* The minor version number of the GLFW header. This is incremented when
* features are added to the API but it remains backward-compatible.
* @ingroup init
*/
#define GLFW_VERSION_MINOR 4
/*! @brief The revision number of the GLFW library.
/*! @brief The revision number of the GLFW header.
*
* This is incremented when a bug fix release is made that does not contain any
* API changes.
* The revision number of the GLFW header. This is incremented when a bug fix
* release is made that does not contain any API changes.
* @ingroup init
*/
#define GLFW_VERSION_REVISION 0
@ -977,9 +978,10 @@ extern "C" {
* Monitor refresh rate [hint](@ref GLFW_REFRESH_RATE).
*/
#define GLFW_REFRESH_RATE 0x0002100F
/*! @brief Framebuffer double buffering hint.
/*! @brief Framebuffer double buffering hint and attribute.
*
* Framebuffer double buffering [hint](@ref GLFW_DOUBLEBUFFER).
* Framebuffer double buffering [hint](@ref GLFW_DOUBLEBUFFER_hint) and
* [attribute](@ref GLFW_DOUBLEBUFFER_attrib).
*/
#define GLFW_DOUBLEBUFFER 0x00021010
@ -1250,6 +1252,11 @@ extern "C" {
* macOS specific [init hint](@ref GLFW_COCOA_MENUBAR_hint).
*/
#define GLFW_COCOA_MENUBAR 0x00051002
/*! @brief X11 specific init hint.
*
* X11 specific [init hint](@ref GLFW_X11_XCB_VULKAN_SURFACE_hint).
*/
#define GLFW_X11_XCB_VULKAN_SURFACE 0x00052001
/*! @} */
#define GLFW_DONT_CARE -1
@ -2417,8 +2424,9 @@ GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun callback);
*
* This function returns an array of all video modes supported by the specified
* monitor. The returned array is sorted in ascending order, first by color
* bit depth (the sum of all channel depths) and then by resolution area (the
* product of width and height).
* bit depth (the sum of all channel depths), then by resolution area (the
* product of width and height), then resolution width and finally by refresh
* rate.
*
* @param[in] monitor The monitor to query.
* @param[out] count Where to store the number of video modes in the returned
@ -5865,9 +5873,8 @@ GLFWAPI int glfwVulkanSupported(void);
* returned array, as it is an error to specify an extension more than once in
* the `VkInstanceCreateInfo` struct.
*
* @remark @macos This function currently supports either the
* `VK_MVK_macos_surface` extension from MoltenVK or `VK_EXT_metal_surface`
* extension.
* @remark @macos GLFW currently supports both the `VK_MVK_macos_surface` and
* the newer `VK_EXT_metal_surface` extensions.
*
* @pointer_lifetime The returned array is allocated and freed by GLFW. You
* should not free it yourself. It is guaranteed to be valid only until the
@ -5950,7 +5957,7 @@ GLFWAPI GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance, const char* p
* GLFW_API_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR.
*
* @remark @macos This function currently always returns `GLFW_TRUE`, as the
* `VK_MVK_macos_surface` extension does not provide
* `VK_MVK_macos_surface` and `VK_EXT_metal_surface` extensions do not provide
* a `vkGetPhysicalDevice*PresentationSupport` type function.
*
* @thread_safety This function may be called from any thread. For
@ -6013,6 +6020,12 @@ GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhys
* @remark @macos This function creates and sets a `CAMetalLayer` instance for
* the window content view, which is required for MoltenVK to function.
*
* @remark @x11 GLFW by default attempts to use the `VK_KHR_xcb_surface`
* extension, if available. You can make it prefer the `VK_KHR_xlib_surface`
* extension by setting the
* [GLFW_X11_XCB_VULKAN_SURFACE](@ref GLFW_X11_XCB_VULKAN_SURFACE_hint) init
* hint.
*
* @thread_safety This function may be called from any thread. For
* synchronization details of Vulkan objects, see the Vulkan specification.
*

View File

@ -83,8 +83,8 @@ extern "C" {
#if defined(GLFW_EXPOSE_NATIVE_WIN32) || defined(GLFW_EXPOSE_NATIVE_WGL)
// This is a workaround for the fact that glfw3.h needs to export APIENTRY (for
// example to allow applications to correctly declare a GL_ARB_debug_output
// callback) but windows.h assumes no one will define APIENTRY before it does
// example to allow applications to correctly declare a GL_KHR_debug callback)
// but windows.h assumes no one will define APIENTRY before it does
#if defined(GLFW_APIENTRY_DEFINED)
#undef APIENTRY
#undef GLFW_APIENTRY_DEFINED

View File

@ -37,7 +37,7 @@ elseif (_GLFW_OSMESA)
endif()
if (_GLFW_X11 OR _GLFW_WAYLAND)
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_sources(glfw PRIVATE linux_joystick.h linux_joystick.c)
else()
target_sources(glfw PRIVATE null_joystick.h null_joystick.c)
@ -120,7 +120,7 @@ endif()
# Make GCC warn about declarations that VS 2010 and 2012 won't accept for all
# source files that VS will build (Clang ignores this because we set -std=c99)
if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
set_source_files_properties(context.c init.c input.c monitor.c vulkan.c
window.c win32_init.c win32_joystick.c
win32_monitor.c win32_time.c win32_thread.c
@ -130,22 +130,18 @@ if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
endif()
# Enable a reasonable set of warnings
if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR
"${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR
"${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang")
# NOTE: The order matters here, Clang-CL matches both MSVC and Clang
if (MSVC)
target_compile_options(glfw PRIVATE "/W3")
elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR
CMAKE_C_COMPILER_ID STREQUAL "Clang" OR
CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
if ("${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC")
# Tell Clang-CL that this is a Clang flag
target_compile_options(glfw PRIVATE "/clang:-Wall")
else()
target_compile_options(glfw PRIVATE "-Wall")
endif()
elseif (MSVC)
target_compile_options(glfw PRIVATE "/W3")
endif()
if (WIN32)
target_compile_definitions(glfw PRIVATE _UNICODE)
if (_GLFW_WIN32)
target_compile_definitions(glfw PRIVATE UNICODE _UNICODE)
endif()
# HACK: When building on MinGW, WINVER and UNICODE need to be defined before
@ -153,7 +149,7 @@ endif()
# win32_platform.h. We define them here until a saner solution can be found
# NOTE: MinGW-w64 and Visual C++ do /not/ need this hack.
if (MINGW)
target_compile_definitions(glfw PRIVATE UNICODE WINVER=0x0501)
target_compile_definitions(glfw PRIVATE WINVER=0x0501)
endif()
# Workaround for legacy MinGW not providing XInput and DirectInput
@ -166,8 +162,8 @@ if (MINGW)
endif()
endif()
# Workaround for VS deprecating parts of the standard library
if (MSVC)
# Workaround for the MS CRT deprecating parts of the standard library
if (MSVC OR CMAKE_C_SIMULATE_ID STREQUAL "MSVC")
target_compile_definitions(glfw PRIVATE _CRT_SECURE_NO_WARNINGS)
endif()
@ -203,9 +199,6 @@ if (BUILD_SHARED_LIBS)
endif()
target_compile_definitions(glfw INTERFACE GLFW_DLL)
elseif (APPLE)
set_target_properties(glfw PROPERTIES
INSTALL_NAME_DIR "${CMAKE_INSTALL_LIBDIR}")
endif()
if (MINGW)
@ -246,7 +239,7 @@ endif()
if (GLFW_INSTALL)
install(TARGETS glfw
EXPORT glfwTargets
RUNTIME DESTINATION "bin"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
endif()

View File

@ -428,9 +428,6 @@ static GLFWbool initializeTIS(void)
{
if (_glfw.hints.init.ns.menubar)
{
// In case we are unbundled, make us a proper UI application
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
// Menu bar setup must go between sharedApplication and finishLaunching
// in order to properly emulate the behavior of NSApplicationMain
@ -557,6 +554,10 @@ int _glfwPlatformInit(void)
if (![[NSRunningApplication currentApplication] isFinishedLaunching])
[NSApp run];
// In case we are unbundled, make us a proper UI application
if (_glfw.hints.init.ns.menubar)
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
return GLFW_TRUE;
} // autoreleasepool

View File

@ -39,8 +39,21 @@
// Get the name of the specified display, or NULL
//
static char* getDisplayName(CGDirectDisplayID displayID)
static char* getMonitorName(CGDirectDisplayID displayID, NSScreen* screen)
{
// IOKit doesn't work on Apple Silicon anymore
// Luckily, 10.15 introduced -[NSScreen localizedName].
// Use it if available, and fall back to IOKit otherwise.
if (screen)
{
if ([screen respondsToSelector:@selector(localizedName)])
{
NSString* name = [screen valueForKey:@"localizedName"];
if (name)
return _glfw_strdup([name UTF8String]);
}
}
io_iterator_t it;
io_service_t service;
CFDictionaryRef info;
@ -50,7 +63,7 @@ static char* getDisplayName(CGDirectDisplayID displayID)
&it) != 0)
{
// This may happen if a desktop Mac is running headless
return NULL;
return _glfw_strdup("Display");
}
while ((service = IOIteratorNext(it)) != 0)
@ -88,7 +101,7 @@ static char* getDisplayName(CGDirectDisplayID displayID)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Cocoa: Failed to find service port for display");
return NULL;
return _glfw_strdup("Display");
}
CFDictionaryRef names =
@ -101,7 +114,7 @@ static char* getDisplayName(CGDirectDisplayID displayID)
{
// This may happen if a desktop Mac is running headless
CFRelease(info);
return NULL;
return _glfw_strdup("Display");
}
const CFIndex size =
@ -209,31 +222,6 @@ static void endFadeReservation(CGDisplayFadeReservationToken token)
}
}
// Finds and caches the NSScreen corresponding to the specified monitor
//
static GLFWbool refreshMonitorScreen(_GLFWmonitor* monitor)
{
if (monitor->ns.screen)
return GLFW_TRUE;
for (NSScreen* screen in [NSScreen screens])
{
NSNumber* displayID = [screen deviceDescription][@"NSScreenNumber"];
// HACK: Compare unit numbers instead of display IDs to work around
// display replacement on machines with automatic graphics
// switching
if (monitor->ns.unitNumber == CGDisplayUnitNumber([displayID unsignedIntValue]))
{
monitor->ns.screen = screen;
return GLFW_TRUE;
}
}
_glfwInputError(GLFW_PLATFORM_ERROR, "Cocoa: Failed to find a screen for monitor");
return GLFW_FALSE;
}
// Returns the display refresh rate queried from the I/O registry
//
static double getFallbackRefreshRate(CGDirectDisplayID displayID)
@ -334,27 +322,46 @@ void _glfwPollMonitorsNS(void)
if (CGDisplayIsAsleep(displays[i]))
continue;
const uint32_t unitNumber = CGDisplayUnitNumber(displays[i]);
NSScreen* screen = nil;
for (screen in [NSScreen screens])
{
NSNumber* screenNumber = [screen deviceDescription][@"NSScreenNumber"];
// HACK: Compare unit numbers instead of display IDs to work around
// display replacement on machines with automatic graphics
// switching
const uint32_t unitNumber = CGDisplayUnitNumber(displays[i]);
for (uint32_t j = 0; j < disconnectedCount; j++)
if (CGDisplayUnitNumber([screenNumber unsignedIntValue]) == unitNumber)
break;
}
// HACK: Compare unit numbers instead of display IDs to work around
// display replacement on machines with automatic graphics
// switching
uint32_t j;
for (j = 0; j < disconnectedCount; j++)
{
if (disconnected[j] && disconnected[j]->ns.unitNumber == unitNumber)
{
disconnected[j]->ns.screen = screen;
disconnected[j] = NULL;
break;
}
}
if (j < disconnectedCount)
continue;
const CGSize size = CGDisplayScreenSize(displays[i]);
char* name = getDisplayName(displays[i]);
char* name = getMonitorName(displays[i], screen);
if (!name)
name = _glfw_strdup("Unknown");
continue;
_GLFWmonitor* monitor = _glfwAllocMonitor(name, size.width, size.height);
monitor->ns.displayID = displays[i];
monitor->ns.unitNumber = unitNumber;
monitor->ns.screen = screen;
free(name);
@ -463,8 +470,11 @@ void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
{
@autoreleasepool {
if (!refreshMonitorScreen(monitor))
return;
if (!monitor->ns.screen)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Cocoa: Cannot query content scale without screen");
}
const NSRect points = [monitor->ns.screen frame];
const NSRect pixels = [monitor->ns.screen convertRectToBacking:points];
@ -483,8 +493,11 @@ void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor,
{
@autoreleasepool {
if (!refreshMonitorScreen(monitor))
return;
if (!monitor->ns.screen)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Cocoa: Cannot query workarea without screen");
}
const NSRect frameRect = [monitor->ns.screen visibleFrame];
@ -527,7 +540,7 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count)
}
// Skip duplicate modes
if (i < *count)
if (j < *count)
continue;
(*count)++;

View File

@ -196,12 +196,6 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
continue;
}
if (desired->doublebuffer != current->doublebuffer)
{
// Double buffering is a hard constraint
continue;
}
// Count number of missing buffers
{
missing = 0;
@ -570,6 +564,8 @@ GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window,
PFNGLCLEARPROC glClear = (PFNGLCLEARPROC)
window->context.getProcAddress("glClear");
glClear(GL_COLOR_BUFFER_BIT);
if (window->doublebuffer)
window->context.swapBuffers(window);
}

View File

@ -173,7 +173,7 @@ static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig,
u->stencilBits = getEGLConfigAttrib(n, EGL_STENCIL_SIZE);
u->samples = getEGLConfigAttrib(n, EGL_SAMPLES);
u->doublebuffer = GLFW_TRUE;
u->doublebuffer = desired->doublebuffer;
u->handle = (uintptr_t) n;
usableCount++;
@ -643,6 +643,9 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
setAttrib(EGL_GL_COLORSPACE_KHR, EGL_GL_COLORSPACE_SRGB_KHR);
}
if (!fbconfig->doublebuffer)
setAttrib(EGL_RENDER_BUFFER, EGL_SINGLE_BUFFER);
setAttrib(EGL_NONE, EGL_NONE);
native = _glfwPlatformGetEGLNativeWindow(window);

View File

@ -64,6 +64,8 @@
#define EGL_OPENGL_ES_API 0x30a0
#define EGL_OPENGL_API 0x30a2
#define EGL_NONE 0x3038
#define EGL_RENDER_BUFFER 0x3086
#define EGL_SINGLE_BUFFER 0x3085
#define EGL_EXTENSIONS 0x3055
#define EGL_CONTEXT_CLIENT_VERSION 0x3098
#define EGL_NATIVE_VISUAL_ID 0x302e

View File

@ -92,6 +92,9 @@ static GLFWbool chooseGLXFBConfig(const _GLFWfbconfig* desired,
continue;
}
if (getGLXFBConfigAttrib(n, GLX_DOUBLEBUFFER) != desired->doublebuffer)
continue;
if (desired->transparent)
{
XVisualInfo* vi = glXGetVisualFromFBConfig(_glfw.x11.display, n);
@ -119,8 +122,6 @@ static GLFWbool chooseGLXFBConfig(const _GLFWfbconfig* desired,
if (getGLXFBConfigAttrib(n, GLX_STEREO))
u->stereo = GLFW_TRUE;
if (getGLXFBConfigAttrib(n, GLX_DOUBLEBUFFER))
u->doublebuffer = GLFW_TRUE;
if (_glfw.glx.ARB_multisample)
u->samples = getGLXFBConfigAttrib(n, GLX_SAMPLES);

View File

@ -57,7 +57,10 @@ static _GLFWinitconfig _glfwInitHints =
{
GLFW_TRUE, // macOS menu bar
GLFW_TRUE // macOS bundle chdir
}
},
{
GLFW_TRUE, // X11 XCB Vulkan surface
},
};
// Terminate the library
@ -298,6 +301,9 @@ GLFWAPI void glfwInitHint(int hint, int value)
case GLFW_COCOA_MENUBAR:
_glfwInitHints.ns.menubar = value;
return;
case GLFW_X11_XCB_VULKAN_SURFACE:
_glfwInitHints.x11.xcbVulkanSurface = value;
return;
}
_glfwInputError(GLFW_INVALID_ENUM,

View File

@ -446,7 +446,6 @@ _GLFWjoystick* _glfwAllocJoystick(const char* name,
js = _glfw.joysticks + jid;
js->present = GLFW_TRUE;
js->name = _glfw_strdup(name);
js->axes = calloc(axisCount, sizeof(float));
js->buttons = calloc(buttonCount + (size_t) hatCount * 4, 1);
js->hats = calloc(hatCount, 1);
@ -454,6 +453,7 @@ _GLFWjoystick* _glfwAllocJoystick(const char* name,
js->buttonCount = buttonCount;
js->hatCount = hatCount;
strncpy(js->name, name, sizeof(js->name) - 1);
strncpy(js->guid, guid, sizeof(js->guid) - 1);
js->mapping = findValidMapping(js);
@ -464,7 +464,6 @@ _GLFWjoystick* _glfwAllocJoystick(const char* name,
//
void _glfwFreeJoystick(_GLFWjoystick* js)
{
free(js->name);
free(js->axes);
free(js->buttons);
free(js->hats);

View File

@ -248,6 +248,9 @@ struct _GLFWinitconfig
GLFWbool menubar;
GLFWbool chdir;
} ns;
struct {
GLFWbool xcbVulkanSurface;
} x11;
};
// Window configuration
@ -384,6 +387,7 @@ struct _GLFWwindow
GLFWbool mousePassthrough;
GLFWbool shouldClose;
void* userPointer;
GLFWbool doublebuffer;
GLFWvidmode videoMode;
_GLFWmonitor* monitor;
_GLFWcursor* cursor;
@ -432,7 +436,7 @@ struct _GLFWwindow
//
struct _GLFWmonitor
{
char* name;
char name[128];
void* userPointer;
// Physical dimensions in millimeters.
@ -493,7 +497,7 @@ struct _GLFWjoystick
int buttonCount;
unsigned char* hats;
int hatCount;
char* name;
char name[128];
void* userPointer;
char guid[33];
_GLFWmapping* mapping;

View File

@ -170,8 +170,7 @@ _GLFWmonitor* _glfwAllocMonitor(const char* name, int widthMM, int heightMM)
monitor->widthMM = widthMM;
monitor->heightMM = heightMM;
if (name)
monitor->name = _glfw_strdup(name);
strncpy(monitor->name, name, sizeof(monitor->name) - 1);
return monitor;
}
@ -189,7 +188,6 @@ void _glfwFreeMonitor(_GLFWmonitor* monitor)
_glfwFreeGammaArrays(&monitor->currentRamp);
free(monitor->modes);
free(monitor->name);
free(monitor);
}

View File

@ -165,6 +165,9 @@ static int choosePixelFormat(_GLFWwindow* window,
if (findAttribValue(WGL_ACCELERATION_ARB) == WGL_NO_ACCELERATION_ARB)
continue;
if (findAttribValue(WGL_DOUBLE_BUFFER_ARB) != fbconfig->doublebuffer)
continue;
u->redBits = findAttribValue(WGL_RED_BITS_ARB);
u->greenBits = findAttribValue(WGL_GREEN_BITS_ARB);
u->blueBits = findAttribValue(WGL_BLUE_BITS_ARB);
@ -182,8 +185,6 @@ static int choosePixelFormat(_GLFWwindow* window,
if (findAttribValue(WGL_STEREO_ARB))
u->stereo = GLFW_TRUE;
if (findAttribValue(WGL_DOUBLE_BUFFER_ARB))
u->doublebuffer = GLFW_TRUE;
if (_glfw.wgl.ARB_multisample)
u->samples = findAttribValue(WGL_SAMPLES_ARB);
@ -239,6 +240,9 @@ static int choosePixelFormat(_GLFWwindow* window,
if (pfd.iPixelType != PFD_TYPE_RGBA)
continue;
if (!!(pfd.dwFlags & PFD_DOUBLEBUFFER) != fbconfig->doublebuffer)
continue;
u->redBits = pfd.cRedBits;
u->greenBits = pfd.cGreenBits;
u->blueBits = pfd.cBlueBits;
@ -256,8 +260,6 @@ static int choosePixelFormat(_GLFWwindow* window,
if (pfd.dwFlags & PFD_STEREO)
u->stereo = GLFW_TRUE;
if (pfd.dwFlags & PFD_DOUBLEBUFFER)
u->doublebuffer = GLFW_TRUE;
}
u->handle = pixelFormat;

View File

@ -39,6 +39,10 @@ static const GUID _glfw_GUID_DEVINTERFACE_HID =
#if defined(_GLFW_USE_HYBRID_HPG) || defined(_GLFW_USE_OPTIMUS_HPG)
#if defined(_GLFW_BUILD_DLL)
#warning "These symbols must be exported by the executable and have no effect in a DLL"
#endif
// Executables (but not DLLs) exporting this symbol with this value will be
// automatically directed to the high-performance GPU on Nvidia Optimus systems
// with up-to-date drivers
@ -614,7 +618,9 @@ void _glfwPlatformTerminate(void)
const char* _glfwPlatformGetVersionString(void)
{
return _GLFW_VERSION_NUMBER " Win32 WGL EGL OSMesa"
#if defined(__MINGW32__)
#if defined(__MINGW64_VERSION_MAJOR)
" MinGW-w64"
#elif defined(__MINGW32__)
" MinGW"
#elif defined(_MSC_VER)
" VisualC"

View File

@ -39,8 +39,8 @@
#endif
// This is a workaround for the fact that glfw3.h needs to export APIENTRY (for
// example to allow applications to correctly declare a GL_ARB_debug_output
// callback) but windows.h assumes no one will define APIENTRY before it does
// example to allow applications to correctly declare a GL_KHR_debug callback)
// but windows.h assumes no one will define APIENTRY before it does
#undef APIENTRY
// GLFW on Windows is Unicode only and does not work in MBCS mode

View File

@ -501,7 +501,17 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
case WM_NCCREATE:
{
if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
{
const CREATESTRUCTW* cs = (const CREATESTRUCTW*) lParam;
const _GLFWwndconfig* wndconfig = cs->lpCreateParams;
// On per-monitor DPI aware V1 systems, only enable
// non-client scaling for windows that scale the client area
// We need WM_GETDPISCALEDSIZE from V2 to keep the client
// area static when the non-client area is scaled
if (wndconfig && wndconfig->scaleToMonitor)
EnableNonClientDpiScaling(hWnd);
}
break;
}
@ -1138,9 +1148,11 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
const float xscale = HIWORD(wParam) / (float) USER_DEFAULT_SCREEN_DPI;
const float yscale = LOWORD(wParam) / (float) USER_DEFAULT_SCREEN_DPI;
// Only apply the suggested size if the OS is new enough to have
// sent a WM_GETDPISCALEDSIZE before this
if (_glfwIsWindows10CreatorsUpdateOrGreaterWin32())
// Resize windowed mode windows that either permit rescaling or that
// need it to compensate for non-client area scaling
if (!window->monitor &&
(window->win32.scaleToMonitor ||
_glfwIsWindows10CreatorsUpdateOrGreaterWin32()))
{
RECT* suggested = (RECT*) lParam;
SetWindowPos(window->win32.handle, HWND_TOP,
@ -1255,7 +1267,7 @@ static int createNativeWindow(_GLFWwindow* window,
NULL, // No parent window
NULL, // No window menu
GetModuleHandleW(NULL),
NULL);
(LPVOID) wndconfig);
free(wideTitle);

View File

@ -206,6 +206,8 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
window->mousePassthrough = wndconfig.mousePassthrough;
window->cursorMode = GLFW_CURSOR_NORMAL;
window->doublebuffer = fbconfig.doublebuffer;
window->minwidth = GLFW_DONT_CARE;
window->minheight = GLFW_DONT_CARE;
window->maxwidth = GLFW_DONT_CARE;
@ -841,6 +843,8 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib)
return window->floating;
case GLFW_AUTO_ICONIFY:
return window->autoIconify;
case GLFW_DOUBLEBUFFER:
return window->doublebuffer;
case GLFW_CLIENT_API:
return window->context.client;
case GLFW_CONTEXT_CREATION_API:
@ -882,27 +886,18 @@ GLFWAPI void glfwSetWindowAttrib(GLFWwindow* handle, int attrib, int value)
window->autoIconify = value;
else if (attrib == GLFW_RESIZABLE)
{
if (window->resizable == value)
return;
window->resizable = value;
if (!window->monitor)
_glfwPlatformSetWindowResizable(window, value);
}
else if (attrib == GLFW_DECORATED)
{
if (window->decorated == value)
return;
window->decorated = value;
if (!window->monitor)
_glfwPlatformSetWindowDecorated(window, value);
}
else if (attrib == GLFW_FLOATING)
{
if (window->floating == value)
return;
window->floating = value;
if (!window->monitor)
_glfwPlatformSetWindowFloating(window, value);
@ -911,9 +906,6 @@ GLFWAPI void glfwSetWindowAttrib(GLFWwindow* handle, int attrib, int value)
window->focusOnShow = value;
else if (attrib == GLFW_MOUSE_PASSTHROUGH)
{
if (window->mousePassthrough == value)
return;
window->mousePassthrough = value;
_glfwPlatformSetWindowMousePassthrough(window, value);
}

View File

@ -47,15 +47,13 @@ static void outputHandleGeometry(void* data,
int32_t transform)
{
struct _GLFWmonitor *monitor = data;
char name[1024];
monitor->wl.x = x;
monitor->wl.y = y;
monitor->widthMM = physicalWidth;
monitor->heightMM = physicalHeight;
snprintf(name, sizeof(name), "%s %s", make, model);
monitor->name = _glfw_strdup(name);
snprintf(monitor->name, sizeof(monitor->name), "%s %s", make, model);
}
static void outputHandleMode(void* data,
@ -81,22 +79,21 @@ static void outputHandleMode(void* data,
monitor->modes[monitor->modeCount - 1] = mode;
if (flags & WL_OUTPUT_MODE_CURRENT)
{
monitor->wl.currentMode = monitor->modeCount - 1;
if (monitor->widthMM <= 0 || monitor->heightMM <= 0)
{
// If Wayland does not provide a physical size, assume the default 96 DPI
monitor->widthMM = (int) (width * 25.4f / 96.f);
monitor->heightMM = (int) (height * 25.4f / 96.f);
}
}
}
static void outputHandleDone(void* data, struct wl_output* output)
{
struct _GLFWmonitor *monitor = data;
if (monitor->widthMM <= 0 || monitor->heightMM <= 0)
{
// If Wayland does not provide a physical size, assume the default 96 DPI
const GLFWvidmode* mode = &monitor->modes[monitor->wl.currentMode];
monitor->widthMM = (int) (mode->width * 25.4f / 96.f);
monitor->heightMM = (int) (mode->height * 25.4f / 96.f);
}
_glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_LAST);
}
@ -134,7 +131,7 @@ void _glfwAddOutputWayland(uint32_t name, uint32_t version)
}
// The actual name of this output will be set in the geometry handler.
monitor = _glfwAllocMonitor(NULL, 0, 0);
monitor = _glfwAllocMonitor("", 0, 0);
output = wl_registry_bind(_glfw.wl.registry,
name,

View File

@ -813,11 +813,15 @@ static GLFWbool initExtensions(void)
XkbGroupStateMask, XkbGroupStateMask);
}
if (_glfw.hints.init.x11.xcbVulkanSurface)
{
#if defined(__CYGWIN__)
_glfw.x11.x11xcb.handle = _glfw_dlopen("libX11-xcb-1.so");
#else
_glfw.x11.x11xcb.handle = _glfw_dlopen("libX11-xcb.so.1");
#endif
}
if (_glfw.x11.x11xcb.handle)
{
_glfw.x11.x11xcb.GetXCBConnection = (PFN_XGetXCBConnection)

View File

@ -2485,7 +2485,11 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
}
if (window->monitor)
{
_glfwPlatformSetWindowDecorated(window, window->decorated);
_glfwPlatformSetWindowFloating(window, window->floating);
releaseMonitor(window);
}
_glfwInputWindowMonitor(window, monitor);
updateNormalHints(window, width, height);

View File

@ -7,7 +7,8 @@ if (MATH_LIBRARY)
link_libraries("${MATH_LIBRARY}")
endif()
if (MSVC)
# Workaround for the MS CRT deprecating parts of the standard library
if (MSVC OR CMAKE_C_SIMULATE_ID STREQUAL "MSVC")
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif()
@ -58,9 +59,13 @@ set_target_properties(${GUI_ONLY_BINARIES} ${CONSOLE_BINARIES} PROPERTIES
FOLDER "GLFW3/Tests")
if (MSVC)
# Tell MSVC to use main instead of WinMain for Windows subsystem executables
# Tell MSVC to use main instead of WinMain
set_target_properties(${GUI_ONLY_BINARIES} PROPERTIES
LINK_FLAGS "/ENTRY:mainCRTStartup")
elseif (CMAKE_C_SIMULATE_ID STREQUAL "MSVC")
# Tell Clang using MS CRT to use main instead of WinMain
set_target_properties(${GUI_ONLY_BINARIES} PROPERTIES
LINK_FLAGS "-Wl,/entry:mainCRTStartup")
endif()
if (APPLE)

View File

@ -116,6 +116,7 @@ static void usage(void)
ANGLE_TYPE_VULKAN " or "
ANGLE_TYPE_METAL ")\n");
printf(" --graphics-switching request macOS graphics switching\n");
printf(" --disable-xcb-surface disable VK_KHR_xcb_surface extension\n");
}
static void error_callback(int error, const char* description)
@ -360,6 +361,7 @@ int main(int argc, char** argv)
bool fb_doublebuffer = true;
int angle_type = GLFW_ANGLE_PLATFORM_TYPE_NONE;
bool cocoa_graphics_switching = false;
bool disable_xcb_surface = false;
enum { CLIENT, CONTEXT, BEHAVIOR, DEBUG_CONTEXT, FORWARD, HELP,
EXTENSIONS, LAYERS,
@ -367,7 +369,7 @@ int main(int argc, char** argv)
REDBITS, GREENBITS, BLUEBITS, ALPHABITS, DEPTHBITS, STENCILBITS,
ACCUMREDBITS, ACCUMGREENBITS, ACCUMBLUEBITS, ACCUMALPHABITS,
AUXBUFFERS, SAMPLES, STEREO, SRGB, SINGLEBUFFER, NOERROR_SRSLY,
ANGLE_TYPE, GRAPHICS_SWITCHING };
ANGLE_TYPE, GRAPHICS_SWITCHING, XCB_SURFACE };
const struct option options[] =
{
{ "behavior", 1, NULL, BEHAVIOR },
@ -401,6 +403,7 @@ int main(int argc, char** argv)
{ "no-error", 0, NULL, NOERROR_SRSLY },
{ "angle-type", 1, NULL, ANGLE_TYPE },
{ "graphics-switching", 0, NULL, GRAPHICS_SWITCHING },
{ "vk-xcb-surface", 0, NULL, XCB_SURFACE },
{ NULL, 0, NULL, 0 }
};
@ -607,6 +610,9 @@ int main(int argc, char** argv)
case GRAPHICS_SWITCHING:
cocoa_graphics_switching = true;
break;
case XCB_SURFACE:
disable_xcb_surface = true;
break;
default:
usage();
exit(EXIT_FAILURE);
@ -623,6 +629,7 @@ int main(int argc, char** argv)
glfwInitHint(GLFW_COCOA_MENUBAR, false);
glfwInitHint(GLFW_ANGLE_PLATFORM_TYPE, angle_type);
glfwInitHint(GLFW_X11_XCB_VULKAN_SURFACE, !disable_xcb_surface);
if (!glfwInit())
exit(EXIT_FAILURE);
@ -843,6 +850,17 @@ int main(int argc, char** argv)
if (list_extensions)
list_context_extensions(client, major, minor);
glfwDestroyWindow(window);
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
window = glfwCreateWindow(200, 200, "Version", NULL, NULL);
if (!window)
{
glfwTerminate();
exit(EXIT_FAILURE);
}
printf("Vulkan loader: %s\n",
glfwVulkanSupported() ? "available" : "missing");
@ -866,15 +884,14 @@ int main(int argc, char** argv)
uint32_t re_count;
const char** re = glfwGetRequiredInstanceExtensions(&re_count);
printf("Vulkan required instance extensions:");
if (re)
{
printf("Vulkan window surface required instance extensions:\n");
for (uint32_t i = 0; i < re_count; i++)
printf(" %s", re[i]);
putchar('\n');
printf(" %s\n", re[i]);
}
else
printf(" missing\n");
printf("Vulkan window surface extensions missing\n");
if (list_extensions)
list_vulkan_instance_extensions();
@ -908,6 +925,19 @@ int main(int argc, char** argv)
gladLoadVulkanUserPtr(NULL, glad_vulkan_callback, instance);
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");
}
uint32_t pd_count;
vkEnumeratePhysicalDevices(instance, &pd_count, NULL);
VkPhysicalDevice* pd = calloc(pd_count, sizeof(VkPhysicalDevice));
@ -916,7 +946,6 @@ int main(int argc, char** argv)
for (uint32_t i = 0; i < pd_count; i++)
{
VkPhysicalDeviceProperties pdp;
vkGetPhysicalDeviceProperties(pd[i], &pdp);
printf("Vulkan %s device: \"%s\" (API version %i.%i)\n",
@ -925,6 +954,19 @@ int main(int argc, char** argv)
VK_VERSION_MAJOR(pdp.apiVersion),
VK_VERSION_MINOR(pdp.apiVersion));
uint32_t qfp_count;
vkGetPhysicalDeviceQueueFamilyProperties(pd[i], &qfp_count, NULL);
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");
}
if (list_extensions)
list_vulkan_device_extensions(instance, pd[i]);
@ -936,6 +978,8 @@ int main(int argc, char** argv)
vkDestroyInstance(instance, NULL);
}
glfwDestroyWindow(window);
glfwTerminate();
exit(EXIT_SUCCESS);
}