mirror of
https://github.com/glfw/glfw.git
synced 2025-06-07 08:14:57 +00:00
add option to remove titlebar
This commit is contained in:
parent
8e6c8d7eff
commit
f906f7ae3f
File diff suppressed because it is too large
Load Diff
@ -169,8 +169,7 @@ extern "C" {
|
||||
* of the specified monitor, or `NULL` if an [error](@ref error_handling)
|
||||
* occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||
* GLFW_PLATFORM_UNAVAILABLE.
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
@ -187,8 +186,7 @@ GLFWAPI const char* glfwGetWin32Adapter(GLFWmonitor* monitor);
|
||||
* `\\.\DISPLAY1\Monitor0`) of the specified monitor, or `NULL` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||
* GLFW_PLATFORM_UNAVAILABLE.
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
@ -204,8 +202,7 @@ GLFWAPI const char* glfwGetWin32Monitor(GLFWmonitor* monitor);
|
||||
* @return The `HWND` of the specified window, or `NULL` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||
* GLFW_PLATFORM_UNAVAILABLE.
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @remark The `HDC` associated with the window can be queried with the
|
||||
* [GetDC](https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdc)
|
||||
@ -231,8 +228,8 @@ GLFWAPI HWND glfwGetWin32Window(GLFWwindow* window);
|
||||
* @return The `HGLRC` of the specified window, or `NULL` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
|
||||
* GLFW_PLATFORM_UNAVAILABLE and @ref GLFW_NO_WINDOW_CONTEXT.
|
||||
* @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref
|
||||
* GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @remark The `HDC` associated with the window can be queried with the
|
||||
* [GetDC](https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdc)
|
||||
@ -258,8 +255,7 @@ GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* window);
|
||||
* @return The `CGDirectDisplayID` of the specified monitor, or
|
||||
* `kCGNullDirectDisplay` if an [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||
* GLFW_PLATFORM_UNAVAILABLE.
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
@ -275,8 +271,7 @@ GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* monitor);
|
||||
* @return The `NSWindow` of the specified window, or `nil` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||
* GLFW_PLATFORM_UNAVAILABLE.
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
@ -294,8 +289,8 @@ GLFWAPI id glfwGetCocoaWindow(GLFWwindow* window);
|
||||
* @return The `NSOpenGLContext` of the specified window, or `nil` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
|
||||
* GLFW_PLATFORM_UNAVAILABLE and @ref GLFW_NO_WINDOW_CONTEXT.
|
||||
* @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref
|
||||
* GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
@ -313,8 +308,7 @@ GLFWAPI id glfwGetNSGLContext(GLFWwindow* window);
|
||||
* @return The `Display` used by GLFW, or `NULL` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||
* GLFW_PLATFORM_UNAVAILABLE.
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
@ -330,8 +324,7 @@ GLFWAPI Display* glfwGetX11Display(void);
|
||||
* @return The `RRCrtc` of the specified monitor, or `None` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||
* GLFW_PLATFORM_UNAVAILABLE.
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
@ -347,8 +340,7 @@ GLFWAPI RRCrtc glfwGetX11Adapter(GLFWmonitor* monitor);
|
||||
* @return The `RROutput` of the specified monitor, or `None` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||
* GLFW_PLATFORM_UNAVAILABLE.
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
@ -364,8 +356,7 @@ GLFWAPI RROutput glfwGetX11Monitor(GLFWmonitor* monitor);
|
||||
* @return The `Window` of the specified window, or `None` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||
* GLFW_PLATFORM_UNAVAILABLE.
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
@ -380,8 +371,8 @@ GLFWAPI Window glfwGetX11Window(GLFWwindow* window);
|
||||
*
|
||||
* @param[in] string A UTF-8 encoded string.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
|
||||
* GLFW_PLATFORM_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR.
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||
* GLFW_PLATFORM_ERROR.
|
||||
*
|
||||
* @pointer_lifetime The specified string is copied before this function
|
||||
* returns.
|
||||
@ -406,8 +397,8 @@ GLFWAPI void glfwSetX11SelectionString(const char* string);
|
||||
* @return The contents of the selection as a UTF-8 encoded string, or `NULL`
|
||||
* if an [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
|
||||
* GLFW_PLATFORM_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR.
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||
* GLFW_PLATFORM_ERROR.
|
||||
*
|
||||
* @pointer_lifetime The returned string is allocated and freed by GLFW. You
|
||||
* should not free it yourself. It is valid until the next call to @ref
|
||||
@ -433,8 +424,8 @@ GLFWAPI const char* glfwGetX11SelectionString(void);
|
||||
* @return The `GLXContext` of the specified window, or `NULL` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
|
||||
* GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_UNAVAILABLE.
|
||||
* @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref
|
||||
* GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
@ -450,8 +441,8 @@ GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* window);
|
||||
* @return The `GLXWindow` of the specified window, or `None` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
|
||||
* GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_UNAVAILABLE.
|
||||
* @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref
|
||||
* GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
@ -469,8 +460,7 @@ GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* window);
|
||||
* @return The `struct wl_display*` used by GLFW, or `NULL` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||
* GLFW_PLATFORM_UNAVAILABLE.
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
@ -486,8 +476,7 @@ GLFWAPI struct wl_display* glfwGetWaylandDisplay(void);
|
||||
* @return The `struct wl_output*` of the specified monitor, or `NULL` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||
* GLFW_PLATFORM_UNAVAILABLE.
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
@ -503,8 +492,7 @@ GLFWAPI struct wl_output* glfwGetWaylandMonitor(GLFWmonitor* monitor);
|
||||
* @return The main `struct wl_surface*` of the specified window, or `NULL` if
|
||||
* an [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||
* GLFW_PLATFORM_UNAVAILABLE.
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
@ -541,8 +529,8 @@ GLFWAPI EGLDisplay glfwGetEGLDisplay(void);
|
||||
* @return The `EGLContext` of the specified window, or `EGL_NO_CONTEXT` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||
* GLFW_NO_WINDOW_CONTEXT.
|
||||
* @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref
|
||||
* GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
@ -558,8 +546,8 @@ GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* window);
|
||||
* @return The `EGLSurface` of the specified window, or `EGL_NO_SURFACE` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||
* GLFW_NO_WINDOW_CONTEXT.
|
||||
* @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref
|
||||
* GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
@ -584,8 +572,8 @@ GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* window);
|
||||
* @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||
* GLFW_NO_WINDOW_CONTEXT.
|
||||
* @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref
|
||||
* GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
@ -608,8 +596,8 @@ GLFWAPI int glfwGetOSMesaColorBuffer(GLFWwindow* window, int* width, int* height
|
||||
* @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||
* GLFW_NO_WINDOW_CONTEXT.
|
||||
* @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref
|
||||
* GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
@ -625,8 +613,8 @@ GLFWAPI int glfwGetOSMesaDepthBuffer(GLFWwindow* window, int* width, int* height
|
||||
* @return The `OSMesaContext` of the specified window, or `NULL` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||
* GLFW_NO_WINDOW_CONTEXT.
|
||||
* @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref
|
||||
* GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
|
178
src/cocoa_init.m
178
src/cocoa_init.m
@ -59,9 +59,7 @@ static void changeToResourcesDirectory(void)
|
||||
|
||||
if (!CFURLGetFileSystemRepresentation(resourcesURL,
|
||||
true,
|
||||
(UInt8*) resourcesPath,
|
||||
MAXPATHLEN))
|
||||
{
|
||||
(UInt8 *)resourcesPath, MAXPATHLEN)) {
|
||||
CFRelease(resourcesURL);
|
||||
return;
|
||||
}
|
||||
@ -76,12 +74,10 @@ static void changeToResourcesDirectory(void)
|
||||
// could go away at any moment, lots of stuff that really should be
|
||||
// localize(d|able), etc. Add a nib to save us this horror.
|
||||
//
|
||||
static void createMenuBar(void)
|
||||
{
|
||||
static void createMenuBar(void) {
|
||||
NSString *appName = nil;
|
||||
NSDictionary *bundleInfo = [[NSBundle mainBundle] infoDictionary];
|
||||
NSString* nameKeys[] =
|
||||
{
|
||||
NSString *nameKeys[] = {
|
||||
@"CFBundleDisplayName",
|
||||
@"CFBundleName",
|
||||
@"CFBundleExecutable",
|
||||
@ -89,20 +85,16 @@ static void createMenuBar(void)
|
||||
|
||||
// Try to figure out what the calling application is called
|
||||
|
||||
for (size_t i = 0; i < sizeof(nameKeys) / sizeof(nameKeys[0]); i++)
|
||||
{
|
||||
for (size_t i = 0; i < sizeof(nameKeys) / sizeof(nameKeys[0]); i++) {
|
||||
id name = bundleInfo[nameKeys[i]];
|
||||
if (name &&
|
||||
[name isKindOfClass:[NSString class]] &&
|
||||
![name isEqualToString:@""])
|
||||
{
|
||||
if (name && [name isKindOfClass:[NSString class]] &&
|
||||
![name isEqualToString:@""]) {
|
||||
appName = name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!appName)
|
||||
{
|
||||
if (!appName) {
|
||||
char **progname = _NSGetProgname();
|
||||
if (progname && *progname)
|
||||
appName = @(*progname);
|
||||
@ -113,8 +105,9 @@ static void createMenuBar(void)
|
||||
NSMenu *bar = [[NSMenu alloc] init];
|
||||
[NSApp setMainMenu:bar];
|
||||
|
||||
NSMenuItem* appMenuItem =
|
||||
[bar addItemWithTitle:@"" action:NULL keyEquivalent:@""];
|
||||
NSMenuItem *appMenuItem = [bar addItemWithTitle:@""
|
||||
action:NULL
|
||||
keyEquivalent:@""];
|
||||
NSMenu *appMenu = [[NSMenu alloc] init];
|
||||
[appMenuItem setSubmenu:appMenu];
|
||||
|
||||
@ -124,8 +117,7 @@ static void createMenuBar(void)
|
||||
[appMenu addItem:[NSMenuItem separatorItem]];
|
||||
NSMenu *servicesMenu = [[NSMenu alloc] init];
|
||||
[NSApp setServicesMenu:servicesMenu];
|
||||
[[appMenu addItemWithTitle:@"Services"
|
||||
action:NULL
|
||||
[[appMenu addItemWithTitle:@"Services" action:NULL
|
||||
keyEquivalent:@""] setSubmenu:servicesMenu];
|
||||
[servicesMenu release];
|
||||
[appMenu addItem:[NSMenuItem separatorItem]];
|
||||
@ -135,7 +127,8 @@ static void createMenuBar(void)
|
||||
[[appMenu addItemWithTitle:@"Hide Others"
|
||||
action:@selector(hideOtherApplications:)
|
||||
keyEquivalent:@"h"]
|
||||
setKeyEquivalentModifierMask:NSEventModifierFlagOption | NSEventModifierFlagCommand];
|
||||
setKeyEquivalentModifierMask:NSEventModifierFlagOption |
|
||||
NSEventModifierFlagCommand];
|
||||
[appMenu addItemWithTitle:@"Show All"
|
||||
action:@selector(unhideAllApplications:)
|
||||
keyEquivalent:@""];
|
||||
@ -144,8 +137,9 @@ static void createMenuBar(void)
|
||||
action:@selector(terminate:)
|
||||
keyEquivalent:@"q"];
|
||||
|
||||
NSMenuItem* windowMenuItem =
|
||||
[bar addItemWithTitle:@"" action:NULL keyEquivalent:@""];
|
||||
NSMenuItem *windowMenuItem = [bar addItemWithTitle:@""
|
||||
action:NULL
|
||||
keyEquivalent:@""];
|
||||
[bar release];
|
||||
NSMenu *windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];
|
||||
[NSApp setWindowsMenu:windowMenu];
|
||||
@ -167,7 +161,8 @@ static void createMenuBar(void)
|
||||
[[windowMenu addItemWithTitle:@"Enter Full Screen"
|
||||
action:@selector(toggleFullScreen:)
|
||||
keyEquivalent:@"f"]
|
||||
setKeyEquivalentModifierMask:NSEventModifierFlagControl | NSEventModifierFlagCommand];
|
||||
setKeyEquivalentModifierMask:NSEventModifierFlagControl |
|
||||
NSEventModifierFlagCommand];
|
||||
|
||||
// Prior to Snow Leopard, we need to use this oddly-named semi-private API
|
||||
// to get the application menu working properly.
|
||||
@ -177,8 +172,7 @@ static void createMenuBar(void)
|
||||
|
||||
// Create key code translation tables
|
||||
//
|
||||
static void createKeyTables(void)
|
||||
{
|
||||
static void createKeyTables(void) {
|
||||
memset(_glfw.ns.keycodes, -1, sizeof(_glfw.ns.keycodes));
|
||||
memset(_glfw.ns.scancodes, -1, sizeof(_glfw.ns.scancodes));
|
||||
|
||||
@ -297,8 +291,7 @@ static void createKeyTables(void)
|
||||
_glfw.ns.keycodes[0x43] = GLFW_KEY_KP_MULTIPLY;
|
||||
_glfw.ns.keycodes[0x4E] = GLFW_KEY_KP_SUBTRACT;
|
||||
|
||||
for (int scancode = 0; scancode < 256; scancode++)
|
||||
{
|
||||
for (int scancode = 0; scancode < 256; scancode++) {
|
||||
// Store the reverse translation for faster key name lookup
|
||||
if (_glfw.ns.keycodes[scancode] >= 0)
|
||||
_glfw.ns.scancodes[_glfw.ns.keycodes[scancode]] = scancode;
|
||||
@ -307,28 +300,23 @@ static void createKeyTables(void)
|
||||
|
||||
// Retrieve Unicode data for the current keyboard layout
|
||||
//
|
||||
static GLFWbool updateUnicodeData(void)
|
||||
{
|
||||
if (_glfw.ns.inputSource)
|
||||
{
|
||||
static GLFWbool updateUnicodeData(void) {
|
||||
if (_glfw.ns.inputSource) {
|
||||
CFRelease(_glfw.ns.inputSource);
|
||||
_glfw.ns.inputSource = NULL;
|
||||
_glfw.ns.unicodeData = nil;
|
||||
}
|
||||
|
||||
_glfw.ns.inputSource = TISCopyCurrentKeyboardLayoutInputSource();
|
||||
if (!_glfw.ns.inputSource)
|
||||
{
|
||||
if (!_glfw.ns.inputSource) {
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Cocoa: Failed to retrieve keyboard layout input source");
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
_glfw.ns.unicodeData =
|
||||
TISGetInputSourceProperty(_glfw.ns.inputSource,
|
||||
kTISPropertyUnicodeKeyLayoutData);
|
||||
if (!_glfw.ns.unicodeData)
|
||||
{
|
||||
_glfw.ns.unicodeData = TISGetInputSourceProperty(
|
||||
_glfw.ns.inputSource, kTISPropertyUnicodeKeyLayoutData);
|
||||
if (!_glfw.ns.unicodeData) {
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Cocoa: Failed to retrieve keyboard layout Unicode data");
|
||||
return GLFW_FALSE;
|
||||
@ -339,43 +327,36 @@ static GLFWbool updateUnicodeData(void)
|
||||
|
||||
// Load HIToolbox.framework and the TIS symbols we need from it
|
||||
//
|
||||
static GLFWbool initializeTIS(void)
|
||||
{
|
||||
static GLFWbool initializeTIS(void) {
|
||||
// This works only because Cocoa has already loaded it properly
|
||||
_glfw.ns.tis.bundle =
|
||||
CFBundleGetBundleWithIdentifier(CFSTR("com.apple.HIToolbox"));
|
||||
if (!_glfw.ns.tis.bundle)
|
||||
{
|
||||
if (!_glfw.ns.tis.bundle) {
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Cocoa: Failed to load HIToolbox.framework");
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
CFStringRef* kPropertyUnicodeKeyLayoutData =
|
||||
CFBundleGetDataPointerForName(_glfw.ns.tis.bundle,
|
||||
CFSTR("kTISPropertyUnicodeKeyLayoutData"));
|
||||
CFStringRef *kPropertyUnicodeKeyLayoutData = CFBundleGetDataPointerForName(
|
||||
_glfw.ns.tis.bundle, CFSTR("kTISPropertyUnicodeKeyLayoutData"));
|
||||
_glfw.ns.tis.CopyCurrentKeyboardLayoutInputSource =
|
||||
CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle,
|
||||
CFBundleGetFunctionPointerForName(
|
||||
_glfw.ns.tis.bundle,
|
||||
CFSTR("TISCopyCurrentKeyboardLayoutInputSource"));
|
||||
_glfw.ns.tis.GetInputSourceProperty =
|
||||
CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle,
|
||||
CFSTR("TISGetInputSourceProperty"));
|
||||
_glfw.ns.tis.GetKbdType =
|
||||
CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle,
|
||||
CFSTR("LMGetKbdType"));
|
||||
_glfw.ns.tis.GetInputSourceProperty = CFBundleGetFunctionPointerForName(
|
||||
_glfw.ns.tis.bundle, CFSTR("TISGetInputSourceProperty"));
|
||||
_glfw.ns.tis.GetKbdType = CFBundleGetFunctionPointerForName(
|
||||
_glfw.ns.tis.bundle, CFSTR("LMGetKbdType"));
|
||||
|
||||
if (!kPropertyUnicodeKeyLayoutData ||
|
||||
!TISCopyCurrentKeyboardLayoutInputSource ||
|
||||
!TISGetInputSourceProperty ||
|
||||
!LMGetKbdType)
|
||||
{
|
||||
!TISCopyCurrentKeyboardLayoutInputSource || !TISGetInputSourceProperty ||
|
||||
!LMGetKbdType) {
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Cocoa: Failed to load TIS API symbols");
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
_glfw.ns.tis.kPropertyUnicodeKeyLayoutData =
|
||||
*kPropertyUnicodeKeyLayoutData;
|
||||
_glfw.ns.tis.kPropertyUnicodeKeyLayoutData = *kPropertyUnicodeKeyLayoutData;
|
||||
|
||||
return updateUnicodeData();
|
||||
}
|
||||
@ -385,13 +366,11 @@ static GLFWbool initializeTIS(void)
|
||||
|
||||
@implementation GLFWHelper
|
||||
|
||||
- (void)selectedKeyboardInputSourceChanged:(NSObject* )object
|
||||
{
|
||||
- (void)selectedKeyboardInputSourceChanged:(NSObject *)object {
|
||||
updateUnicodeData();
|
||||
}
|
||||
|
||||
- (void)doNothing:(id)object
|
||||
{
|
||||
- (void)doNothing:(id)object {
|
||||
}
|
||||
|
||||
@end // GLFWHelper
|
||||
@ -401,18 +380,18 @@ static GLFWbool initializeTIS(void)
|
||||
|
||||
@implementation GLFWApplicationDelegate
|
||||
|
||||
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
|
||||
{
|
||||
for (_GLFWwindow* window = _glfw.windowListHead; window; window = window->next)
|
||||
- (NSApplicationTerminateReply)applicationShouldTerminate:
|
||||
(NSApplication *)sender {
|
||||
for (_GLFWwindow *window = _glfw.windowListHead; window;
|
||||
window = window->next)
|
||||
_glfwInputWindowCloseRequest(window);
|
||||
|
||||
return NSTerminateCancel;
|
||||
}
|
||||
|
||||
- (void)applicationDidChangeScreenParameters:(NSNotification *) notification
|
||||
{
|
||||
for (_GLFWwindow* window = _glfw.windowListHead; window; window = window->next)
|
||||
{
|
||||
- (void)applicationDidChangeScreenParameters:(NSNotification *)notification {
|
||||
for (_GLFWwindow *window = _glfw.windowListHead; window;
|
||||
window = window->next) {
|
||||
if (window->context.client != GLFW_NO_API)
|
||||
[window->context.nsgl.object update];
|
||||
}
|
||||
@ -420,45 +399,37 @@ static GLFWbool initializeTIS(void)
|
||||
_glfwPollMonitorsCocoa();
|
||||
}
|
||||
|
||||
- (void)applicationWillFinishLaunching:(NSNotification *)notification
|
||||
{
|
||||
if (_glfw.hints.init.ns.menubar)
|
||||
{
|
||||
- (void)applicationWillFinishLaunching:(NSNotification *)notification {
|
||||
if (_glfw.hints.init.ns.menubar) {
|
||||
// Menu bar setup must go between sharedApplication and finishLaunching
|
||||
// in order to properly emulate the behavior of NSApplicationMain
|
||||
|
||||
if ([[NSBundle mainBundle] pathForResource:@"MainMenu" ofType:@"nib"])
|
||||
{
|
||||
if ([[NSBundle mainBundle] pathForResource:@"MainMenu" ofType:@"nib"]) {
|
||||
[[NSBundle mainBundle] loadNibNamed:@"MainMenu"
|
||||
owner:NSApp
|
||||
topLevelObjects:&_glfw.ns.nibObjects];
|
||||
}
|
||||
else
|
||||
} else
|
||||
createMenuBar();
|
||||
}
|
||||
}
|
||||
|
||||
- (void)applicationDidFinishLaunching:(NSNotification *)notification
|
||||
{
|
||||
- (void)applicationDidFinishLaunching:(NSNotification *)notification {
|
||||
_glfwPostEmptyEventCocoa();
|
||||
[NSApp stop:nil];
|
||||
}
|
||||
|
||||
- (void)applicationDidHide:(NSNotification *)notification
|
||||
{
|
||||
- (void)applicationDidHide:(NSNotification *)notification {
|
||||
for (int i = 0; i < _glfw.monitorCount; i++)
|
||||
_glfwRestoreVideoModeCocoa(_glfw.monitors[i]);
|
||||
}
|
||||
|
||||
@end // GLFWApplicationDelegate
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW internal API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void* _glfwLoadLocalVulkanLoaderCocoa(void)
|
||||
{
|
||||
void *_glfwLoadLocalVulkanLoaderCocoa(void) {
|
||||
CFBundleRef bundle = CFBundleGetMainBundle();
|
||||
if (!bundle)
|
||||
return NULL;
|
||||
@ -469,8 +440,7 @@ void* _glfwLoadLocalVulkanLoaderCocoa(void)
|
||||
|
||||
CFURLRef loaderUrl = CFURLCreateCopyAppendingPathComponent(
|
||||
kCFAllocatorDefault, frameworksUrl, CFSTR("libvulkan.1.dylib"), false);
|
||||
if (!loaderUrl)
|
||||
{
|
||||
if (!loaderUrl) {
|
||||
CFRelease(frameworksUrl);
|
||||
return NULL;
|
||||
}
|
||||
@ -478,7 +448,8 @@ void* _glfwLoadLocalVulkanLoaderCocoa(void)
|
||||
char path[PATH_MAX];
|
||||
void *handle = NULL;
|
||||
|
||||
if (CFURLGetFileSystemRepresentation(loaderUrl, true, (UInt8*) path, sizeof(path) - 1))
|
||||
if (CFURLGetFileSystemRepresentation(loaderUrl, true, (UInt8 *)path,
|
||||
sizeof(path) - 1))
|
||||
handle = _glfwPlatformLoadModule(path);
|
||||
|
||||
CFRelease(loaderUrl);
|
||||
@ -486,15 +457,12 @@ void* _glfwLoadLocalVulkanLoaderCocoa(void)
|
||||
return handle;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW platform API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GLFWbool _glfwConnectCocoa(int platformID, _GLFWplatform* platform)
|
||||
{
|
||||
const _GLFWplatform cocoa =
|
||||
{
|
||||
GLFWbool _glfwConnectCocoa(int platformID, _GLFWplatform *platform) {
|
||||
const _GLFWplatform cocoa = {
|
||||
GLFW_PLATFORM_COCOA,
|
||||
_glfwInitCocoa,
|
||||
_glfwTerminateCocoa,
|
||||
@ -554,6 +522,7 @@ GLFWbool _glfwConnectCocoa(int platformID, _GLFWplatform* platform)
|
||||
_glfwGetWindowOpacityCocoa,
|
||||
_glfwSetWindowResizableCocoa,
|
||||
_glfwSetWindowDecoratedCocoa,
|
||||
_glfwSetWindowTitlebarCocoa,
|
||||
_glfwSetWindowFloatingCocoa,
|
||||
_glfwSetWindowOpacityCocoa,
|
||||
_glfwSetWindowMousePassthroughCocoa,
|
||||
@ -622,7 +591,8 @@ int _glfwInitCocoa(void)
|
||||
|
||||
createKeyTables();
|
||||
|
||||
_glfw.ns.eventSource = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
|
||||
_glfw.ns.eventSource =
|
||||
CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
|
||||
if (!_glfw.ns.eventSource)
|
||||
return GLFW_FALSE;
|
||||
|
||||
@ -645,38 +615,33 @@ int _glfwInitCocoa(void)
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
void _glfwTerminateCocoa(void)
|
||||
{
|
||||
void _glfwTerminateCocoa(void) {
|
||||
@autoreleasepool {
|
||||
|
||||
if (_glfw.ns.inputSource)
|
||||
{
|
||||
if (_glfw.ns.inputSource) {
|
||||
CFRelease(_glfw.ns.inputSource);
|
||||
_glfw.ns.inputSource = NULL;
|
||||
_glfw.ns.unicodeData = nil;
|
||||
}
|
||||
|
||||
if (_glfw.ns.eventSource)
|
||||
{
|
||||
if (_glfw.ns.eventSource) {
|
||||
CFRelease(_glfw.ns.eventSource);
|
||||
_glfw.ns.eventSource = NULL;
|
||||
}
|
||||
|
||||
if (_glfw.ns.delegate)
|
||||
{
|
||||
if (_glfw.ns.delegate) {
|
||||
[NSApp setDelegate:nil];
|
||||
[_glfw.ns.delegate release];
|
||||
_glfw.ns.delegate = nil;
|
||||
}
|
||||
|
||||
if (_glfw.ns.helper)
|
||||
{
|
||||
if (_glfw.ns.helper) {
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
removeObserver:_glfw.ns.helper
|
||||
name:NSTextInputContextKeyboardSelectionDidChangeNotification
|
||||
name:
|
||||
NSTextInputContextKeyboardSelectionDidChangeNotification
|
||||
object:nil];
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
removeObserver:_glfw.ns.helper];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:_glfw.ns.helper];
|
||||
[_glfw.ns.helper release];
|
||||
_glfw.ns.helper = nil;
|
||||
}
|
||||
@ -694,4 +659,3 @@ void _glfwTerminateCocoa(void)
|
||||
}
|
||||
|
||||
#endif // _GLFW_COCOA
|
||||
|
||||
|
@ -243,6 +243,7 @@ GLFWbool _glfwWindowHoveredCocoa(_GLFWwindow* window);
|
||||
GLFWbool _glfwFramebufferTransparentCocoa(_GLFWwindow* window);
|
||||
void _glfwSetWindowResizableCocoa(_GLFWwindow* window, GLFWbool enabled);
|
||||
void _glfwSetWindowDecoratedCocoa(_GLFWwindow* window, GLFWbool enabled);
|
||||
void _glfwSetWindowTitlebarCocoa(_GLFWwindow* window, GLFWbool enabled);
|
||||
void _glfwSetWindowFloatingCocoa(_GLFWwindow* window, GLFWbool enabled);
|
||||
float _glfwGetWindowOpacityCocoa(_GLFWwindow* window);
|
||||
void _glfwSetWindowOpacityCocoa(_GLFWwindow* window, float opacity);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -24,6 +24,8 @@
|
||||
// distribution.
|
||||
//
|
||||
//========================================================================
|
||||
// Please use C89 style variable declarations in this file because VS 2010
|
||||
//========================================================================
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
|
240
src/internal.h
240
src/internal.h
@ -31,16 +31,11 @@
|
||||
#include "glfw_config.h"
|
||||
#endif
|
||||
|
||||
#if defined(GLFW_INCLUDE_GLCOREARB) || \
|
||||
defined(GLFW_INCLUDE_ES1) || \
|
||||
defined(GLFW_INCLUDE_ES2) || \
|
||||
defined(GLFW_INCLUDE_ES3) || \
|
||||
defined(GLFW_INCLUDE_ES31) || \
|
||||
defined(GLFW_INCLUDE_ES32) || \
|
||||
defined(GLFW_INCLUDE_NONE) || \
|
||||
defined(GLFW_INCLUDE_GLEXT) || \
|
||||
defined(GLFW_INCLUDE_GLU) || \
|
||||
defined(GLFW_INCLUDE_VULKAN) || \
|
||||
#if defined(GLFW_INCLUDE_GLCOREARB) || defined(GLFW_INCLUDE_ES1) || \
|
||||
defined(GLFW_INCLUDE_ES2) || defined(GLFW_INCLUDE_ES3) || \
|
||||
defined(GLFW_INCLUDE_ES31) || defined(GLFW_INCLUDE_ES32) || \
|
||||
defined(GLFW_INCLUDE_NONE) || defined(GLFW_INCLUDE_GLEXT) || \
|
||||
defined(GLFW_INCLUDE_GLU) || defined(GLFW_INCLUDE_VULKAN) || \
|
||||
defined(GLFW_DLL)
|
||||
#error "You must not define any header option macros when compiling GLFW"
|
||||
#endif
|
||||
@ -200,18 +195,27 @@ typedef void* EGLNativeDisplayType;
|
||||
typedef void *EGLNativeWindowType;
|
||||
|
||||
// EGL function pointer typedefs
|
||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigAttrib)(EGLDisplay,EGLConfig,EGLint,EGLint*);
|
||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigs)(EGLDisplay,EGLConfig*,EGLint,EGLint*);
|
||||
typedef EGLBoolean(EGLAPIENTRY *PFN_eglGetConfigAttrib)(EGLDisplay, EGLConfig,
|
||||
EGLint, EGLint *);
|
||||
typedef EGLBoolean(EGLAPIENTRY *PFN_eglGetConfigs)(EGLDisplay, EGLConfig *,
|
||||
EGLint, EGLint *);
|
||||
typedef EGLDisplay(EGLAPIENTRY *PFN_eglGetDisplay)(EGLNativeDisplayType);
|
||||
typedef EGLint(EGLAPIENTRY *PFN_eglGetError)(void);
|
||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglInitialize)(EGLDisplay,EGLint*,EGLint*);
|
||||
typedef EGLBoolean(EGLAPIENTRY *PFN_eglInitialize)(EGLDisplay, EGLint *,
|
||||
EGLint *);
|
||||
typedef EGLBoolean(EGLAPIENTRY *PFN_eglTerminate)(EGLDisplay);
|
||||
typedef EGLBoolean(EGLAPIENTRY *PFN_eglBindAPI)(EGLenum);
|
||||
typedef EGLContext (EGLAPIENTRY * PFN_eglCreateContext)(EGLDisplay,EGLConfig,EGLContext,const EGLint*);
|
||||
typedef EGLContext(EGLAPIENTRY *PFN_eglCreateContext)(EGLDisplay, EGLConfig,
|
||||
EGLContext,
|
||||
const EGLint *);
|
||||
typedef EGLBoolean(EGLAPIENTRY *PFN_eglDestroySurface)(EGLDisplay, EGLSurface);
|
||||
typedef EGLBoolean(EGLAPIENTRY *PFN_eglDestroyContext)(EGLDisplay, EGLContext);
|
||||
typedef EGLSurface (EGLAPIENTRY * PFN_eglCreateWindowSurface)(EGLDisplay,EGLConfig,EGLNativeWindowType,const EGLint*);
|
||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglMakeCurrent)(EGLDisplay,EGLSurface,EGLSurface,EGLContext);
|
||||
typedef EGLSurface(EGLAPIENTRY *PFN_eglCreateWindowSurface)(EGLDisplay,
|
||||
EGLConfig,
|
||||
EGLNativeWindowType,
|
||||
const EGLint *);
|
||||
typedef EGLBoolean(EGLAPIENTRY *PFN_eglMakeCurrent)(EGLDisplay, EGLSurface,
|
||||
EGLSurface, EGLContext);
|
||||
typedef EGLBoolean(EGLAPIENTRY *PFN_eglSwapBuffers)(EGLDisplay, EGLSurface);
|
||||
typedef EGLBoolean(EGLAPIENTRY *PFN_eglSwapInterval)(EGLDisplay, EGLint);
|
||||
typedef const char *(EGLAPIENTRY *PFN_eglQueryString)(EGLDisplay, EGLint);
|
||||
@ -233,10 +237,13 @@ typedef GLFWglproc (EGLAPIENTRY * PFN_eglGetProcAddress)(const char*);
|
||||
#define eglQueryString _glfw.egl.QueryString
|
||||
#define eglGetProcAddress _glfw.egl.GetProcAddress
|
||||
|
||||
typedef EGLDisplay (EGLAPIENTRY * PFNEGLGETPLATFORMDISPLAYEXTPROC)(EGLenum,void*,const EGLint*);
|
||||
typedef EGLSurface (EGLAPIENTRY * PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC)(EGLDisplay,EGLConfig,void*,const EGLint*);
|
||||
typedef EGLDisplay(EGLAPIENTRY *PFNEGLGETPLATFORMDISPLAYEXTPROC)(
|
||||
EGLenum, void *, const EGLint *);
|
||||
typedef EGLSurface(EGLAPIENTRY *PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC)(
|
||||
EGLDisplay, EGLConfig, void *, const EGLint *);
|
||||
#define eglGetPlatformDisplayEXT _glfw.egl.GetPlatformDisplayEXT
|
||||
#define eglCreatePlatformWindowSurfaceEXT _glfw.egl.CreatePlatformWindowSurfaceEXT
|
||||
#define eglCreatePlatformWindowSurfaceEXT \
|
||||
_glfw.egl.CreatePlatformWindowSurfaceEXT
|
||||
|
||||
#define OSMESA_RGBA 0x1908
|
||||
#define OSMESA_FORMAT 0x22
|
||||
@ -252,12 +259,18 @@ typedef EGLSurface (EGLAPIENTRY * PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC)(EGLD
|
||||
typedef void *OSMesaContext;
|
||||
typedef void (*OSMESAproc)(void);
|
||||
|
||||
typedef OSMesaContext (GLAPIENTRY * PFN_OSMesaCreateContextExt)(GLenum,GLint,GLint,GLint,OSMesaContext);
|
||||
typedef OSMesaContext (GLAPIENTRY * PFN_OSMesaCreateContextAttribs)(const int*,OSMesaContext);
|
||||
typedef OSMesaContext(GLAPIENTRY *PFN_OSMesaCreateContextExt)(GLenum, GLint,
|
||||
GLint, GLint,
|
||||
OSMesaContext);
|
||||
typedef OSMesaContext(GLAPIENTRY *PFN_OSMesaCreateContextAttribs)(
|
||||
const int *, OSMesaContext);
|
||||
typedef void(GLAPIENTRY *PFN_OSMesaDestroyContext)(OSMesaContext);
|
||||
typedef int (GLAPIENTRY * PFN_OSMesaMakeCurrent)(OSMesaContext,void*,int,int,int);
|
||||
typedef int (GLAPIENTRY * PFN_OSMesaGetColorBuffer)(OSMesaContext,int*,int*,int*,void**);
|
||||
typedef int (GLAPIENTRY * PFN_OSMesaGetDepthBuffer)(OSMesaContext,int*,int*,int*,void**);
|
||||
typedef int(GLAPIENTRY *PFN_OSMesaMakeCurrent)(OSMesaContext, void *, int, int,
|
||||
int);
|
||||
typedef int(GLAPIENTRY *PFN_OSMesaGetColorBuffer)(OSMesaContext, int *, int *,
|
||||
int *, void **);
|
||||
typedef int(GLAPIENTRY *PFN_OSMesaGetDepthBuffer)(OSMesaContext, int *, int *,
|
||||
int *, void **);
|
||||
typedef GLFWglproc(GLAPIENTRY *PFN_OSMesaGetProcAddress)(const char *);
|
||||
#define OSMesaCreateContextExt _glfw.osmesa.CreateContextExt
|
||||
#define OSMesaCreateContextAttribs _glfw.osmesa.CreateContextAttribs
|
||||
@ -275,8 +288,7 @@ typedef uint64_t VkSurfaceKHR;
|
||||
typedef uint32_t VkFlags;
|
||||
typedef uint32_t VkBool32;
|
||||
|
||||
typedef enum VkStructureType
|
||||
{
|
||||
typedef enum VkStructureType {
|
||||
VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR = 1000004000,
|
||||
VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR = 1000005000,
|
||||
VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR = 1000006000,
|
||||
@ -286,8 +298,7 @@ typedef enum VkStructureType
|
||||
VK_STRUCTURE_TYPE_MAX_ENUM = 0x7FFFFFFF
|
||||
} VkStructureType;
|
||||
|
||||
typedef enum VkResult
|
||||
{
|
||||
typedef enum VkResult {
|
||||
VK_SUCCESS = 0,
|
||||
VK_NOT_READY = 1,
|
||||
VK_TIMEOUT = 2,
|
||||
@ -316,30 +327,29 @@ typedef enum VkResult
|
||||
|
||||
typedef struct VkAllocationCallbacks VkAllocationCallbacks;
|
||||
|
||||
typedef struct VkExtensionProperties
|
||||
{
|
||||
typedef struct VkExtensionProperties {
|
||||
char extensionName[256];
|
||||
uint32_t specVersion;
|
||||
} VkExtensionProperties;
|
||||
|
||||
typedef void(APIENTRY *PFN_vkVoidFunction)(void);
|
||||
|
||||
typedef PFN_vkVoidFunction (APIENTRY * PFN_vkGetInstanceProcAddr)(VkInstance,const char*);
|
||||
typedef VkResult (APIENTRY * PFN_vkEnumerateInstanceExtensionProperties)(const char*,uint32_t*,VkExtensionProperties*);
|
||||
typedef PFN_vkVoidFunction(APIENTRY *PFN_vkGetInstanceProcAddr)(VkInstance,
|
||||
const char *);
|
||||
typedef VkResult(APIENTRY *PFN_vkEnumerateInstanceExtensionProperties)(
|
||||
const char *, uint32_t *, VkExtensionProperties *);
|
||||
#define vkGetInstanceProcAddr _glfw.vk.GetInstanceProcAddr
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
// Checks for whether the library has been initialized
|
||||
#define _GLFW_REQUIRE_INIT() \
|
||||
if (!_glfw.initialized) \
|
||||
{ \
|
||||
if (!_glfw.initialized) { \
|
||||
_glfwInputError(GLFW_NOT_INITIALIZED, NULL); \
|
||||
return; \
|
||||
}
|
||||
#define _GLFW_REQUIRE_INIT_OR_RETURN(x) \
|
||||
if (!_glfw.initialized) \
|
||||
{ \
|
||||
if (!_glfw.initialized) { \
|
||||
_glfwInputError(GLFW_NOT_INITIALIZED, NULL); \
|
||||
return x; \
|
||||
}
|
||||
@ -355,8 +365,7 @@ typedef VkResult (APIENTRY * PFN_vkEnumerateInstanceExtensionProperties)(const c
|
||||
|
||||
// Per-thread error structure
|
||||
//
|
||||
struct _GLFWerror
|
||||
{
|
||||
struct _GLFWerror {
|
||||
_GLFWerror *next;
|
||||
int code;
|
||||
char description[_GLFW_MESSAGE_SIZE];
|
||||
@ -366,8 +375,7 @@ struct _GLFWerror
|
||||
//
|
||||
// Parameters relating to the initialization of the library
|
||||
//
|
||||
struct _GLFWinitconfig
|
||||
{
|
||||
struct _GLFWinitconfig {
|
||||
GLFWbool hatButtons;
|
||||
int angleType;
|
||||
int platformID;
|
||||
@ -390,8 +398,7 @@ struct _GLFWinitconfig
|
||||
// to the framebuffer. This is used to pass window creation parameters from
|
||||
// shared code to the platform API.
|
||||
//
|
||||
struct _GLFWwndconfig
|
||||
{
|
||||
struct _GLFWwndconfig {
|
||||
int xpos;
|
||||
int ypos;
|
||||
int width;
|
||||
@ -400,6 +407,7 @@ struct _GLFWwndconfig
|
||||
GLFWbool resizable;
|
||||
GLFWbool visible;
|
||||
GLFWbool decorated;
|
||||
GLFWbool titlebar;
|
||||
GLFWbool focused;
|
||||
GLFWbool autoIconify;
|
||||
GLFWbool floating;
|
||||
@ -430,8 +438,7 @@ struct _GLFWwndconfig
|
||||
// to the framebuffer. This is used to pass context creation parameters from
|
||||
// shared code to the platform API.
|
||||
//
|
||||
struct _GLFWctxconfig
|
||||
{
|
||||
struct _GLFWctxconfig {
|
||||
int client;
|
||||
int source;
|
||||
int major;
|
||||
@ -456,8 +463,7 @@ struct _GLFWctxconfig
|
||||
// It is used to pass framebuffer parameters from shared code to the platform
|
||||
// API and also to enumerate and select available framebuffer configs.
|
||||
//
|
||||
struct _GLFWfbconfig
|
||||
{
|
||||
struct _GLFWfbconfig {
|
||||
int redBits;
|
||||
int greenBits;
|
||||
int blueBits;
|
||||
@ -479,8 +485,7 @@ struct _GLFWfbconfig
|
||||
|
||||
// Context structure
|
||||
//
|
||||
struct _GLFWcontext
|
||||
{
|
||||
struct _GLFWcontext {
|
||||
int client;
|
||||
int source;
|
||||
int major, minor, revision;
|
||||
@ -520,8 +525,7 @@ struct _GLFWcontext
|
||||
|
||||
// Window and context structure
|
||||
//
|
||||
struct _GLFWwindow
|
||||
{
|
||||
struct _GLFWwindow {
|
||||
struct _GLFWwindow *next;
|
||||
|
||||
// Window settings and state
|
||||
@ -556,6 +560,7 @@ struct _GLFWwindow
|
||||
|
||||
struct {
|
||||
GLFWwindowposfun pos;
|
||||
GLFWtitlebarhittestfun tbhittest;
|
||||
GLFWwindowsizefun size;
|
||||
GLFWwindowclosefun close;
|
||||
GLFWwindowrefreshfun refresh;
|
||||
@ -580,8 +585,7 @@ struct _GLFWwindow
|
||||
|
||||
// Monitor structure
|
||||
//
|
||||
struct _GLFWmonitor
|
||||
{
|
||||
struct _GLFWmonitor {
|
||||
char name[128];
|
||||
void *userPointer;
|
||||
|
||||
@ -604,8 +608,7 @@ struct _GLFWmonitor
|
||||
|
||||
// Cursor structure
|
||||
//
|
||||
struct _GLFWcursor
|
||||
{
|
||||
struct _GLFWcursor {
|
||||
_GLFWcursor *next;
|
||||
// This is defined in platform.h
|
||||
GLFW_PLATFORM_CURSOR_STATE
|
||||
@ -613,8 +616,7 @@ struct _GLFWcursor
|
||||
|
||||
// Gamepad mapping element structure
|
||||
//
|
||||
struct _GLFWmapelement
|
||||
{
|
||||
struct _GLFWmapelement {
|
||||
uint8_t type;
|
||||
uint8_t index;
|
||||
int8_t axisScale;
|
||||
@ -623,8 +625,7 @@ struct _GLFWmapelement
|
||||
|
||||
// Gamepad mapping structure
|
||||
//
|
||||
struct _GLFWmapping
|
||||
{
|
||||
struct _GLFWmapping {
|
||||
char name[128];
|
||||
char guid[33];
|
||||
_GLFWmapelement buttons[15];
|
||||
@ -633,8 +634,7 @@ struct _GLFWmapping
|
||||
|
||||
// Joystick structure
|
||||
//
|
||||
struct _GLFWjoystick
|
||||
{
|
||||
struct _GLFWjoystick {
|
||||
GLFWbool allocated;
|
||||
GLFWbool connected;
|
||||
float *axes;
|
||||
@ -654,24 +654,21 @@ struct _GLFWjoystick
|
||||
|
||||
// Thread local storage structure
|
||||
//
|
||||
struct _GLFWtls
|
||||
{
|
||||
struct _GLFWtls {
|
||||
// This is defined in platform.h
|
||||
GLFW_PLATFORM_TLS_STATE
|
||||
};
|
||||
|
||||
// Mutex structure
|
||||
//
|
||||
struct _GLFWmutex
|
||||
{
|
||||
struct _GLFWmutex {
|
||||
// This is defined in platform.h
|
||||
GLFW_PLATFORM_MUTEX_STATE
|
||||
};
|
||||
|
||||
// Platform API structure
|
||||
//
|
||||
struct _GLFWplatform
|
||||
{
|
||||
struct _GLFWplatform {
|
||||
int platformID;
|
||||
// init
|
||||
GLFWbool (*init)(void);
|
||||
@ -705,7 +702,8 @@ struct _GLFWplatform
|
||||
GLFWbool (*getGammaRamp)(_GLFWmonitor *, GLFWgammaramp *);
|
||||
void (*setGammaRamp)(_GLFWmonitor *, const GLFWgammaramp *);
|
||||
// window
|
||||
GLFWbool (*createWindow)(_GLFWwindow*,const _GLFWwndconfig*,const _GLFWctxconfig*,const _GLFWfbconfig*);
|
||||
GLFWbool (*createWindow)(_GLFWwindow *, const _GLFWwndconfig *,
|
||||
const _GLFWctxconfig *, const _GLFWfbconfig *);
|
||||
void (*destroyWindow)(_GLFWwindow *);
|
||||
void (*setWindowTitle)(_GLFWwindow *, const char *);
|
||||
void (*setWindowIcon)(_GLFWwindow *, int, const GLFWimage *);
|
||||
@ -725,7 +723,8 @@ struct _GLFWplatform
|
||||
void (*hideWindow)(_GLFWwindow *);
|
||||
void (*requestWindowAttention)(_GLFWwindow *);
|
||||
void (*focusWindow)(_GLFWwindow *);
|
||||
void (*setWindowMonitor)(_GLFWwindow*,_GLFWmonitor*,int,int,int,int,int);
|
||||
void (*setWindowMonitor)(_GLFWwindow *, _GLFWmonitor *, int, int, int, int,
|
||||
int);
|
||||
GLFWbool (*windowFocused)(_GLFWwindow *);
|
||||
GLFWbool (*windowIconified)(_GLFWwindow *);
|
||||
GLFWbool (*windowVisible)(_GLFWwindow *);
|
||||
@ -735,6 +734,7 @@ struct _GLFWplatform
|
||||
float (*getWindowOpacity)(_GLFWwindow *);
|
||||
void (*setWindowResizable)(_GLFWwindow *, GLFWbool);
|
||||
void (*setWindowDecorated)(_GLFWwindow *, GLFWbool);
|
||||
void (*setWindowTitlebar)(_GLFWwindow *, GLFWbool);
|
||||
void (*setWindowFloating)(_GLFWwindow *, GLFWbool);
|
||||
void (*setWindowOpacity)(_GLFWwindow *, float);
|
||||
void (*setWindowMousePassthrough)(_GLFWwindow *, GLFWbool);
|
||||
@ -748,14 +748,16 @@ struct _GLFWplatform
|
||||
EGLNativeWindowType (*getEGLNativeWindow)(_GLFWwindow *);
|
||||
// vulkan
|
||||
void (*getRequiredInstanceExtensions)(char **);
|
||||
GLFWbool (*getPhysicalDevicePresentationSupport)(VkInstance,VkPhysicalDevice,uint32_t);
|
||||
VkResult (*createWindowSurface)(VkInstance,_GLFWwindow*,const VkAllocationCallbacks*,VkSurfaceKHR*);
|
||||
GLFWbool (*getPhysicalDevicePresentationSupport)(VkInstance, VkPhysicalDevice,
|
||||
uint32_t);
|
||||
VkResult (*createWindowSurface)(VkInstance, _GLFWwindow *,
|
||||
const VkAllocationCallbacks *,
|
||||
VkSurfaceKHR *);
|
||||
};
|
||||
|
||||
// Library global data
|
||||
//
|
||||
struct _GLFWlibrary
|
||||
{
|
||||
struct _GLFWlibrary {
|
||||
GLFWbool initialized;
|
||||
GLFWallocator allocator;
|
||||
|
||||
@ -878,7 +880,6 @@ struct _GLFWlibrary
|
||||
//
|
||||
extern _GLFWlibrary _glfw;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW platform API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@ -887,6 +888,65 @@ void _glfwPlatformInitTimer(void);
|
||||
uint64_t _glfwPlatformGetTimerValue(void);
|
||||
uint64_t _glfwPlatformGetTimerFrequency(void);
|
||||
|
||||
int _glfwPlatformCreateWindow(_GLFWwindow *window,
|
||||
const _GLFWwndconfig *wndconfig,
|
||||
const _GLFWctxconfig *ctxconfig,
|
||||
const _GLFWfbconfig *fbconfig);
|
||||
void _glfwPlatformDestroyWindow(_GLFWwindow *window);
|
||||
void _glfwPlatformSetWindowTitle(_GLFWwindow *window, const char *title);
|
||||
void _glfwPlatformSetWindowIcon(_GLFWwindow *window, int count,
|
||||
const GLFWimage *images);
|
||||
void _glfwPlatformGetWindowPos(_GLFWwindow *window, int *xpos, int *ypos);
|
||||
void _glfwPlatformSetWindowPos(_GLFWwindow *window, int xpos, int ypos);
|
||||
void _glfwPlatformGetWindowSize(_GLFWwindow *window, int *width, int *height);
|
||||
void _glfwPlatformSetWindowSize(_GLFWwindow *window, int width, int height);
|
||||
void _glfwPlatformSetWindowSizeLimits(_GLFWwindow *window, int minwidth,
|
||||
int minheight, int maxwidth,
|
||||
int maxheight);
|
||||
void _glfwPlatformSetWindowAspectRatio(_GLFWwindow *window, int numer,
|
||||
int denom);
|
||||
void _glfwPlatformGetFramebufferSize(_GLFWwindow *window, int *width,
|
||||
int *height);
|
||||
void _glfwPlatformGetWindowFrameSize(_GLFWwindow *window, int *left, int *top,
|
||||
int *right, int *bottom);
|
||||
void _glfwPlatformGetWindowContentScale(_GLFWwindow *window, float *xscale,
|
||||
float *yscale);
|
||||
void _glfwPlatformIconifyWindow(_GLFWwindow *window);
|
||||
void _glfwPlatformRestoreWindow(_GLFWwindow *window);
|
||||
void _glfwPlatformMaximizeWindow(_GLFWwindow *window);
|
||||
void _glfwPlatformShowWindow(_GLFWwindow *window);
|
||||
void _glfwPlatformHideWindow(_GLFWwindow *window);
|
||||
void _glfwPlatformRequestWindowAttention(_GLFWwindow *window);
|
||||
void _glfwPlatformFocusWindow(_GLFWwindow *window);
|
||||
void _glfwPlatformSetWindowMonitor(_GLFWwindow *window, _GLFWmonitor *monitor,
|
||||
int xpos, int ypos, int width, int height,
|
||||
int refreshRate);
|
||||
int _glfwPlatformWindowFocused(_GLFWwindow *window);
|
||||
int _glfwPlatformWindowIconified(_GLFWwindow *window);
|
||||
int _glfwPlatformWindowVisible(_GLFWwindow *window);
|
||||
int _glfwPlatformWindowMaximized(_GLFWwindow *window);
|
||||
int _glfwPlatformWindowHovered(_GLFWwindow *window);
|
||||
int _glfwPlatformFramebufferTransparent(_GLFWwindow *window);
|
||||
float _glfwPlatformGetWindowOpacity(_GLFWwindow *window);
|
||||
void _glfwPlatformSetWindowResizable(_GLFWwindow *window, GLFWbool enabled);
|
||||
void _glfwPlatformSetWindowDecorated(_GLFWwindow *window, GLFWbool enabled);
|
||||
void _glfwPlatformSetWindowTitlebar(_GLFWwindow *window, GLFWbool enabled);
|
||||
void _glfwPlatformSetWindowFloating(_GLFWwindow *window, GLFWbool enabled);
|
||||
void _glfwPlatformSetWindowOpacity(_GLFWwindow *window, float opacity);
|
||||
|
||||
void _glfwPlatformPollEvents(void);
|
||||
void _glfwPlatformWaitEvents(void);
|
||||
void _glfwPlatformWaitEventsTimeout(double timeout);
|
||||
void _glfwPlatformPostEmptyEvent(void);
|
||||
|
||||
void _glfwPlatformGetRequiredInstanceExtensions(char **extensions);
|
||||
int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,
|
||||
VkPhysicalDevice device,
|
||||
uint32_t queuefamily);
|
||||
VkResult
|
||||
_glfwPlatformCreateWindowSurface(VkInstance instance, _GLFWwindow *window,
|
||||
const VkAllocationCallbacks *allocator,
|
||||
VkSurfaceKHR *surface);
|
||||
GLFWbool _glfwPlatformCreateTls(_GLFWtls *tls);
|
||||
void _glfwPlatformDestroyTls(_GLFWtls *tls);
|
||||
void *_glfwPlatformGetTls(_GLFWtls *tls);
|
||||
@ -901,7 +961,6 @@ void* _glfwPlatformLoadModule(const char* path);
|
||||
void _glfwPlatformFreeModule(void *module);
|
||||
GLFWproc _glfwPlatformGetModuleSymbol(void *module, const char *name);
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW event API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@ -909,21 +968,24 @@ GLFWproc _glfwPlatformGetModuleSymbol(void* module, const char* name);
|
||||
void _glfwInputWindowFocus(_GLFWwindow *window, GLFWbool focused);
|
||||
void _glfwInputWindowPos(_GLFWwindow *window, int xpos, int ypos);
|
||||
void _glfwInputWindowSize(_GLFWwindow *window, int width, int height);
|
||||
void _glfwInputTitleBarHitTest(_GLFWwindow *window, int posX, int posY,
|
||||
int *hit);
|
||||
void _glfwInputFramebufferSize(_GLFWwindow *window, int width, int height);
|
||||
void _glfwInputWindowContentScale(_GLFWwindow* window,
|
||||
float xscale, float yscale);
|
||||
void _glfwInputWindowContentScale(_GLFWwindow *window, float xscale,
|
||||
float yscale);
|
||||
void _glfwInputWindowIconify(_GLFWwindow *window, GLFWbool iconified);
|
||||
void _glfwInputWindowMaximize(_GLFWwindow *window, GLFWbool maximized);
|
||||
void _glfwInputWindowDamage(_GLFWwindow *window);
|
||||
void _glfwInputWindowCloseRequest(_GLFWwindow *window);
|
||||
void _glfwInputWindowMonitor(_GLFWwindow *window, _GLFWmonitor *monitor);
|
||||
|
||||
void _glfwInputKey(_GLFWwindow* window,
|
||||
int key, int scancode, int action, int mods);
|
||||
void _glfwInputChar(_GLFWwindow* window,
|
||||
uint32_t codepoint, int mods, GLFWbool plain);
|
||||
void _glfwInputKey(_GLFWwindow *window, int key, int scancode, int action,
|
||||
int mods);
|
||||
void _glfwInputChar(_GLFWwindow *window, uint32_t codepoint, int mods,
|
||||
GLFWbool plain);
|
||||
void _glfwInputScroll(_GLFWwindow *window, double xoffset, double yoffset);
|
||||
void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods);
|
||||
void _glfwInputMouseClick(_GLFWwindow *window, int button, int action,
|
||||
int mods);
|
||||
void _glfwInputCursorPos(_GLFWwindow *window, double xpos, double ypos);
|
||||
void _glfwInputCursorEnter(_GLFWwindow *window, GLFWbool entered);
|
||||
void _glfwInputDrop(_GLFWwindow *window, int count, const char **names);
|
||||
@ -942,14 +1004,14 @@ void _glfwInputError(int code, const char* format, ...)
|
||||
void _glfwInputError(int code, const char *format, ...);
|
||||
#endif
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW internal API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GLFWbool _glfwSelectPlatform(int platformID, _GLFWplatform *platform);
|
||||
|
||||
GLFWbool _glfwStringInExtensionString(const char* string, const char* extensions);
|
||||
GLFWbool _glfwStringInExtensionString(const char *string,
|
||||
const char *extensions);
|
||||
const _GLFWfbconfig *_glfwChooseFBConfig(const _GLFWfbconfig *desired,
|
||||
const _GLFWfbconfig *alternatives,
|
||||
unsigned int count);
|
||||
@ -967,11 +1029,8 @@ void _glfwFreeGammaArrays(GLFWgammaramp* ramp);
|
||||
void _glfwSplitBPP(int bpp, int *red, int *green, int *blue);
|
||||
|
||||
void _glfwInitGamepadMappings(void);
|
||||
_GLFWjoystick* _glfwAllocJoystick(const char* name,
|
||||
const char* guid,
|
||||
int axisCount,
|
||||
int buttonCount,
|
||||
int hatCount);
|
||||
_GLFWjoystick *_glfwAllocJoystick(const char *name, const char *guid,
|
||||
int axisCount, int buttonCount, int hatCount);
|
||||
void _glfwFreeJoystick(_GLFWjoystick *js);
|
||||
void _glfwCenterCursorInContentArea(_GLFWwindow *window);
|
||||
|
||||
@ -983,8 +1042,8 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
|
||||
#if defined(_GLFW_X11)
|
||||
GLFWbool _glfwChooseVisualEGL(const _GLFWwndconfig *wndconfig,
|
||||
const _GLFWctxconfig *ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig,
|
||||
Visual** visual, int* depth);
|
||||
const _GLFWfbconfig *fbconfig, Visual **visual,
|
||||
int *depth);
|
||||
#endif /*_GLFW_X11*/
|
||||
|
||||
GLFWbool _glfwInitOSMesa(void);
|
||||
@ -1009,4 +1068,3 @@ float _glfw_fmaxf(float a, float b);
|
||||
void *_glfw_calloc(size_t count, size_t size);
|
||||
void *_glfw_realloc(void *pointer, size_t size);
|
||||
void _glfw_free(void *pointer);
|
||||
|
||||
|
@ -2130,6 +2130,10 @@ int main(const int argc, const char *argv[]) {
|
||||
demo_create_window(&demo);
|
||||
demo_init_vk_swapchain(&demo);
|
||||
|
||||
glfwSetWindowAttrib(demo.window, GLFW_RESIZABLE, GLFW_TRUE);
|
||||
glfwSetWindowAttrib(demo.window, GLFW_TITLEBAR, GLFW_FALSE);
|
||||
|
||||
|
||||
demo_prepare(&demo);
|
||||
demo_run(&demo);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user