mirror of
https://github.com/glfw/glfw.git
synced 2024-11-26 06:14:35 +00:00
Merge 858436dc77
into b35641f4a3
This commit is contained in:
commit
f372ba2705
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@ -68,6 +68,8 @@ jobs:
|
|||||||
run: cmake -B build-cocoa-static
|
run: cmake -B build-cocoa-static
|
||||||
- name: Build Cocoa static library
|
- name: Build Cocoa static library
|
||||||
run: cmake --build build-cocoa-static --parallel
|
run: cmake --build build-cocoa-static --parallel
|
||||||
|
- run: ./build-cocoa-static/tests/glfwinfo
|
||||||
|
- run: ./build-cocoa-static/examples/offscreen
|
||||||
|
|
||||||
- name: Configure Cocoa shared library
|
- name: Configure Cocoa shared library
|
||||||
run: cmake -B build-cocoa-shared -D BUILD_SHARED_LIBS=ON
|
run: cmake -B build-cocoa-shared -D BUILD_SHARED_LIBS=ON
|
||||||
|
@ -200,6 +200,29 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
|
|||||||
assert((size_t) index < sizeof(attribs) / sizeof(attribs[0])); \
|
assert((size_t) index < sizeof(attribs) / sizeof(attribs[0])); \
|
||||||
attribs[index++] = a; \
|
attribs[index++] = a; \
|
||||||
}
|
}
|
||||||
|
// DELETE_ATTRIB checks a !=0, as SET_ATTRIB(x,0) are used, and needs
|
||||||
|
// a special UNSET_ATTRIB(x,0), instead of "DELETE_ATTRIB(x); DELETE_ATTRIB(0)"
|
||||||
|
#define DELETE_ATTRIB(a) \
|
||||||
|
{ \
|
||||||
|
assert(a != 0); \
|
||||||
|
assert(index > 0); \
|
||||||
|
int i = 0; \
|
||||||
|
while (attribs[i] != a && i < index) i++; \
|
||||||
|
if (i < index) { \
|
||||||
|
index--; \
|
||||||
|
while(i < index) { \
|
||||||
|
attribs[i] = attribs[i+1]; \
|
||||||
|
i++; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
#define DELETE_TERMINATING_NULL \
|
||||||
|
{ \
|
||||||
|
assert(index > 0); \
|
||||||
|
if (attribs[index-1] == 0) { \
|
||||||
|
index--; \
|
||||||
|
} \
|
||||||
|
}
|
||||||
#define SET_ATTRIB(a, v) { ADD_ATTRIB(a); ADD_ATTRIB(v); }
|
#define SET_ATTRIB(a, v) { ADD_ATTRIB(a); ADD_ATTRIB(v); }
|
||||||
|
|
||||||
NSOpenGLPixelFormatAttribute attribs[40];
|
NSOpenGLPixelFormatAttribute attribs[40];
|
||||||
@ -302,20 +325,33 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
|
|||||||
// NOTE: All NSOpenGLPixelFormats on the relevant cards support sRGB
|
// NOTE: All NSOpenGLPixelFormats on the relevant cards support sRGB
|
||||||
// framebuffer, so there's no need (and no way) to request it
|
// framebuffer, so there's no need (and no way) to request it
|
||||||
|
|
||||||
ADD_ATTRIB(0);
|
ADD_ATTRIB(0); // See also DELETE_TERMINATING_NULL!
|
||||||
|
|
||||||
#undef ADD_ATTRIB
|
|
||||||
#undef SET_ATTRIB
|
|
||||||
|
|
||||||
window->context.nsgl.pixelFormat =
|
window->context.nsgl.pixelFormat =
|
||||||
[[NSOpenGLPixelFormat alloc] initWithAttributes:attribs];
|
[[NSOpenGLPixelFormat alloc] initWithAttributes:attribs];
|
||||||
if (window->context.nsgl.pixelFormat == nil)
|
if (window->context.nsgl.pixelFormat == nil)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_FORMAT_UNAVAILABLE,
|
// Re-try with Software Renderer
|
||||||
"NSGL: Failed to find a suitable pixel format");
|
DELETE_ATTRIB(NSOpenGLPFAAccelerated);
|
||||||
return GLFW_FALSE;
|
DELETE_TERMINATING_NULL; // Unterminate.
|
||||||
|
ADD_ATTRIB(NSOpenGLPFARendererID);
|
||||||
|
ADD_ATTRIB(kCGLRendererGenericFloatID);
|
||||||
|
ADD_ATTRIB(0); // Re-terminate.
|
||||||
|
window->context.nsgl.pixelFormat =
|
||||||
|
[[NSOpenGLPixelFormat alloc] initWithAttributes:attribs];
|
||||||
|
if (window->context.nsgl.pixelFormat == nil)
|
||||||
|
{
|
||||||
|
_glfwInputError(GLFW_FORMAT_UNAVAILABLE,
|
||||||
|
"NSGL: Failed to find a suitable pixel format");
|
||||||
|
return GLFW_FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef ADD_ATTRIB
|
||||||
|
#undef DELETE_ATTRIB
|
||||||
|
#undef DELETE_TERMINATING_NULL
|
||||||
|
#undef SET_ATTRIB
|
||||||
|
|
||||||
NSOpenGLContext* share = nil;
|
NSOpenGLContext* share = nil;
|
||||||
|
|
||||||
if (ctxconfig->share)
|
if (ctxconfig->share)
|
||||||
|
Loading…
Reference in New Issue
Block a user