Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ video tutorials.
- Luca Bacci
- Keith Bauer
- John Bartholomew
- Garett Bass
- Coşku Baş
- Bayemite
- Niklas Behrens
Expand Down
36 changes: 35 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,41 @@ features, reviewing or testing code, debugging, proofreading docs, suggesting
features or fixing bugs.


## System requirements
## Compiling GLFW

GLFW itself requires only the headers and libraries for your OS and window
system. It does not need the headers for any context creation API (WGL, GLX,
EGL, NSGL, OSMesa) or rendering API (OpenGL, OpenGL ES, Vulkan) to enable
support for them.

GLFW supports compilation on Windows with Visual C++ 2010 and later, MinGW and
MinGW-w64, on macOS with Clang and on Linux and other Unix-like systems with GCC
and Clang. It will likely compile in other environments as well, but this is
not regularly tested.

There are [pre-compiled Windows binaries](https://www.glfw.org/download.html)
available for all supported compilers.

See the [compilation guide](https://www.glfw.org/docs/latest/compile.html) for
more information about how to compile GLFW yourself.

Alternatively, you can `#include <GLFW/glfw3impl.h>` in exactly one compilation
unit of a C or C++ project to compile the entire implementation directly into
your application, avoiding the need to separately compile and link with GLFW.


## Using GLFW

See the [documentation](https://www.glfw.org/docs/latest/) for tutorials, guides
and the API reference.


## Contributing to GLFW

See the [contribution
guide](https://github.com/glfw/glfw/blob/master/docs/CONTRIBUTING.md) for
more information.


GLFW supports Windows 7 and later and macOS 10.11 and later. On GNOME Wayland,
window decorations will be very basic unless the
Expand Down
105 changes: 105 additions & 0 deletions include/GLFW/glfw3impl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*************************************************************************
* GLFW 3.4 - www.glfw.org
* A library for OpenGL, window and input
*------------------------------------------------------------------------
* Copyright (c) 2002-2006 Marcus Geelnard
* Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would
* be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not
* be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*
*************************************************************************/

#ifndef _glfw3impl_h_
#define _glfw3impl_h_

#ifdef __cplusplus
extern "C" {
#endif

#if defined(_WIN32)

#define _GLFW_WIN32
// -D_CRT_SECURE_NO_WARNINGS
// -lgdi32
// -lshell32
// -luser32

#elif defined(__APPLE__)

#define _GLFW_COCOA
// -framework Cocoa
// -framework IOKit
// -framework QuartzCore
// -x objective-c
// or
// -x objective-c++

#endif

#if !defined(_GNU_SOURCE)
#define _GNU_SOURCE
#endif

#include "../../src/cocoa_init.m"
#include "../../src/cocoa_joystick.m"
#include "../../src/cocoa_monitor.m"
#include "../../src/cocoa_window.m"
#include "../../src/context.c"
#include "../../src/egl_context.c"
#include "../../src/glx_context.c"
#include "../../src/init.c"
#include "../../src/input.c"
#include "../../src/linux_joystick.c"
#include "../../src/macos_time.c"
#include "../../src/monitor.c"
#include "../../src/nsgl_context.m"
#include "../../src/null_init.c"
#include "../../src/null_joystick.c"
#include "../../src/null_monitor.c"
#include "../../src/null_window.c"
#include "../../src/osmesa_context.c"
#include "../../src/platform.c"
#include "../../src/posix_module.c"
#include "../../src/posix_poll.c"
#include "../../src/posix_thread.c"
#include "../../src/posix_time.c"
#include "../../src/vulkan.c"
#include "../../src/wgl_context.c"
#include "../../src/win32_init.c"
#include "../../src/win32_joystick.c"
#include "../../src/win32_module.c"
#include "../../src/win32_monitor.c"
#include "../../src/win32_thread.c"
#include "../../src/win32_time.c"
#include "../../src/win32_window.c"
#include "../../src/window.c"
#include "../../src/wl_init.c"
#include "../../src/wl_monitor.c"
#include "../../src/wl_window.c"
#include "../../src/x11_init.c"
#include "../../src/x11_monitor.c"
#include "../../src/x11_window.c"
#include "../../src/xkb_unicode.c"

#ifdef __cplusplus
} // extern "C"
#endif

#endif /* _glfw3impl_h_ */
29 changes: 17 additions & 12 deletions src/cocoa_init.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

// Change to our application bundle's resources directory, if present
//
static void changeToResourcesDirectory(void)
static void _glfwChangeToResourcesDirectoryCocoa(void)
{
char resourcesPath[MAXPATHLEN];

Expand Down Expand Up @@ -74,7 +74,7 @@ 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 _glfwCreateMenuBarCocoa(void)
{
NSString* appName = nil;
NSDictionary* bundleInfo = [[NSBundle mainBundle] infoDictionary];
Expand Down Expand Up @@ -175,7 +175,7 @@ static void createMenuBar(void)

// Create key code translation tables
//
static void createKeyTables(void)
static void _glfwCreateKeyTablesCocoa(void)
{
memset(_glfw.ns.keycodes, -1, sizeof(_glfw.ns.keycodes));
memset(_glfw.ns.scancodes, -1, sizeof(_glfw.ns.scancodes));
Expand Down Expand Up @@ -305,7 +305,7 @@ static void createKeyTables(void)

// Retrieve Unicode data for the current keyboard layout
//
static GLFWbool updateUnicodeData(void)
static GLFWbool _glfwUpdateUnicodeDataCocoa(void)
{
if (_glfw.ns.inputSource)
{
Expand All @@ -323,7 +323,8 @@ static GLFWbool updateUnicodeData(void)
}

_glfw.ns.unicodeData =
TISGetInputSourceProperty(_glfw.ns.inputSource,
(id)
TISGetInputSourceProperty((TISInputSourceRef) _glfw.ns.inputSource,
kTISPropertyUnicodeKeyLayoutData);
if (!_glfw.ns.unicodeData)
{
Expand All @@ -337,7 +338,7 @@ static GLFWbool updateUnicodeData(void)

// Load HIToolbox.framework and the TIS symbols we need from it
//
static GLFWbool initializeTIS(void)
static GLFWbool _glfwInitializeTISCocoa(void)
{
// This works only because Cocoa has already loaded it properly
_glfw.ns.tis.bundle =
Expand All @@ -350,15 +351,19 @@ static GLFWbool initializeTIS(void)
}

CFStringRef* kPropertyUnicodeKeyLayoutData =
(CFStringRef*)
CFBundleGetDataPointerForName(_glfw.ns.tis.bundle,
CFSTR("kTISPropertyUnicodeKeyLayoutData"));
_glfw.ns.tis.CopyCurrentKeyboardLayoutInputSource =
(PFN_TISCopyCurrentKeyboardLayoutInputSource)
CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle,
CFSTR("TISCopyCurrentKeyboardLayoutInputSource"));
_glfw.ns.tis.GetInputSourceProperty =
(PFN_TISGetInputSourceProperty)
CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle,
CFSTR("TISGetInputSourceProperty"));
_glfw.ns.tis.GetKbdType =
(PFN_LMGetKbdType)
CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle,
CFSTR("LMGetKbdType"));

Expand All @@ -375,7 +380,7 @@ static GLFWbool initializeTIS(void)
_glfw.ns.tis.kPropertyUnicodeKeyLayoutData =
*kPropertyUnicodeKeyLayoutData;

return updateUnicodeData();
return _glfwUpdateUnicodeDataCocoa();
}

@interface GLFWHelper : NSObject
Expand All @@ -385,7 +390,7 @@ @implementation GLFWHelper

- (void)selectedKeyboardInputSourceChanged:(NSObject* )object
{
updateUnicodeData();
_glfwUpdateUnicodeDataCocoa();
}

- (void)doNothing:(id)object
Expand Down Expand Up @@ -432,7 +437,7 @@ - (void)applicationWillFinishLaunching:(NSNotification *)notification
topLevelObjects:&_glfw.ns.nibObjects];
}
else
createMenuBar();
_glfwCreateMenuBarCocoa();
}
}

Expand Down Expand Up @@ -571,7 +576,7 @@ int _glfwInitCocoa(void)
handler:block];

if (_glfw.hints.init.ns.chdir)
changeToResourcesDirectory();
_glfwChangeToResourcesDirectoryCocoa();

// Press and Hold prevents some keys from emitting repeated characters
NSDictionary* defaults = @{@"ApplePressAndHoldEnabled":@NO};
Expand All @@ -583,15 +588,15 @@ int _glfwInitCocoa(void)
name:NSTextInputContextKeyboardSelectionDidChangeNotification
object:nil];

createKeyTables();
_glfwCreateKeyTablesCocoa();

_glfw.ns.eventSource = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
if (!_glfw.ns.eventSource)
return GLFW_FALSE;

CGEventSourceSetLocalEventsSuppressionInterval(_glfw.ns.eventSource, 0.0);

if (!initializeTIS())
if (!_glfwInitializeTISCocoa())
return GLFW_FALSE;

_glfwPollMonitorsCocoa();
Expand Down
Loading