Compare commits

..

95 Commits

Author SHA1 Message Date
Camilla Berglund 0a9038f47a X11: Add last event time tracking
Command time stamps help the server in the async wilderness.
2016-08-21 15:39:52 +02:00
Camilla Berglund 3d62c9ed9d Update .gitignore 2016-08-18 23:59:52 +02:00
Camilla Berglund 53fafad915 Start 3.3 2016-08-18 23:55:49 +02:00
Camilla Berglund 999f3556fd Documentation work 2016-08-18 13:32:27 +02:00
Camilla Berglund 4f5731ac39 Add description of 3.2.1 release 2016-08-17 16:09:11 +02:00
Camilla Berglund 4aafdea5a7 X11: Fix glfw*WindowPos operating on window frame
Fixes #800.
2016-08-17 01:45:41 +02:00
Camilla Berglund c18d3aecbc Cocoa: Remove duplicate includes
Fixes #838.
2016-08-17 01:39:47 +02:00
Camilla Berglund f1c536fe13 X11: Fix BadMatch on XSetInputFocus
Input focus was in some cases set before the window was visible (ICCCM
section 4.2.2).

Related to #798.
Fixes #789.
2016-08-12 14:01:03 +02:00
Camilla Berglund ad9233e620 X11: Clean up event wait timeout logic
Simplify interface and implement timeout updating.
2016-08-12 13:33:21 +02:00
Camilla Berglund f88a609000 X11: Only unmaximize visible windows 2016-08-12 13:33:21 +02:00
Camilla Berglund 80ba9944e5 Remove msvcrt recommendation 2016-08-12 13:33:03 +02:00
Camilla Berglund 0f12be7549 Documentation work 2016-08-12 01:57:17 +02:00
Camilla Berglund b581799c9a Fix comment 2016-08-12 01:46:21 +02:00
Camilla Berglund 067d1d6935 Cleanup 2016-08-12 01:46:21 +02:00
Camilla Berglund ada1fdc14d Formatting 2016-08-12 01:46:21 +02:00
Camilla Berglund c98d09f15d Documentation work 2016-08-12 01:46:17 +02:00
Camilla Berglund a6676e6bc2 Update changelog 2016-08-08 17:34:05 +02:00
Camilla Berglund 51e59f4873 Cleanup
Cleanup of 74ed35792f.

Add credit and change log entry.
2016-08-08 16:59:50 +02:00
Patrick Snape 74ed35792f Cocoa: Add missing call to removeObserver:
As noted in the documentation for NSDistributedNotificationCenter,
(under the Discussion heading) before an observer is deallocated a call
should be made to removeObserver: in order to ensure that the listener
is correctly removed from all observation pools.

Fixes #817.
Closes #826.
2016-08-08 16:57:24 +02:00
Camilla Berglund 25914d381a Fix glfwVulkanSupported emitting errors
Regression caused by 614debd13f.
2016-08-05 11:50:05 +02:00
Camilla Berglund fcdef1d0a0 Fix potential context resource leaks
There is a gap between the creation of the context and the call to
_glfwRefreshContextAttribs.
2016-08-05 11:23:05 +02:00
Camilla Berglund 1d3240ff9c Fix Vulkan header macro not breaking compilation
Fixes #823.
2016-08-05 01:32:23 +02:00
Camilla Berglund 7c3706763a Cleanup
Cleanup of 8bdb105897.

Add build macro to configuration header and documentation.  Add
corresponding CMake option.  Add change log entry and credit.  Add
loader static library to link dependencies and add detection to
FindVulkan.cmake.
2016-08-05 01:00:08 +02:00
Philip Rideout 8bdb105897 Add _GLFW_VULKAN_STATIC build macro
This allows clients to link GLFW with a staticly-built loader library.
This is useful in hermetic build systems that build the Khronos loader
from source, rather than depending on the LunarG SDK binaries.

Closes #820.
2016-08-04 18:24:41 +02:00
Alexandre Pretyman d3775b973e Fix clobbering of CMAKE_MODULE_PATH
Closes #822.
2016-08-04 18:14:44 +02:00
Camilla Berglund e77a76a284 Cleanup 2016-08-04 13:19:22 +02:00
Camilla Berglund 00b91a07cb Documentation work 2016-08-02 15:58:58 +02:00
Camilla Berglund 52e47b5a53 Formatting 2016-08-02 15:39:01 +02:00
Camilla Berglund 7be62631ae Cleanup 2016-08-01 23:13:11 +02:00
Camilla Berglund d2686c8413 Fix comment 2016-08-01 23:13:11 +02:00
Camilla Berglund cba652e4f3 Cleanup 2016-08-01 23:13:11 +02:00
Camilla Berglund 370cd14b46 Comment work 2016-08-01 23:13:11 +02:00
Camilla Berglund d3e288cc4d Fix glfwinfo not accepting -c option 2016-08-01 23:13:11 +02:00
Camilla Berglund 06a6629eef EGL: Fix missing include 2016-08-01 23:13:11 +02:00
Camilla Berglund a19490c291 Cleanup
Cleanup of a42d27011b3ef1e6229a1b83aaa075727a5521f3.
2016-08-01 23:13:11 +02:00
Keringar d4eb88b255 X11: Fix application of window size limits
Closes #805.
2016-08-01 23:12:05 +02:00
Camilla Berglund c844fea9df Improve client API error messages
Add separate strings for each client API to make it easier to grep.
Remove 'client' from fallback error messages as API-related error tokens
are used for non-client APIs as well.
2016-08-01 20:49:22 +02:00
Camilla Berglund 923568a279 Add support for WGL_ARB_create_context errors 2016-08-01 20:46:59 +02:00
Camilla Berglund 2c32503b10 Fix comment 2016-08-01 12:15:08 +02:00
Camilla Berglund fe0317aee5 Documentation work 2016-08-01 11:51:30 +02:00
Camilla Berglund 751be1ae8c Fix comment 2016-07-31 19:26:57 +02:00
Camilla Berglund f48b63de38 Fix Valgrind false-positive
Fixes #818.
2016-07-31 17:54:30 +02:00
Camilla Berglund 3beb200c68 Remove unused variable 2016-07-31 13:48:11 +02:00
Camilla Berglund d43b743ff4 Fix GCC warnings 2016-07-21 00:15:55 +02:00
Camilla Berglund 70423af38c Clarify comments 2016-07-21 00:15:42 +02:00
Camilla Berglund f7006f64fb Update changelog 2016-07-20 15:51:57 +02:00
Camilla Berglund 6431c26e8b Add EGL library missing error 2016-07-20 15:39:38 +02:00
Camilla Berglund 04d05fbdc2 Formatting 2016-07-20 15:19:02 +02:00
Camilla Berglund 614debd13f Initialize Vulkan API on demand 2016-07-20 15:18:42 +02:00
Camilla Berglund 2060de5ed0 Match presence of lib prefix on EGL/GLES binaries 2016-07-20 13:11:08 +02:00
Camilla Berglund d5e00e6b0f Initialize context creation APIs on demand 2016-07-20 13:10:51 +02:00
Camilla Berglund 52d801bd19 Cleanup 2016-07-19 00:15:34 +02:00
Camilla Berglund ac09592355 Call context GetProcAddress directly 2016-07-18 23:31:54 +02:00
Camilla Berglund fb418b26d7 Fix grammar
Fixes #776.
2016-07-17 15:39:25 +02:00
Camilla Berglund 4888d7d410 Documentation work
[ci skip]
2016-07-14 18:36:45 +02:00
Camilla Berglund 89bc316a7a Documentation work
[ci skip]
2016-07-14 18:36:42 +02:00
Camilla Berglund c1b1e0aab1 Documentation work
[ci skip]
2016-07-14 18:21:43 +02:00
Camilla Berglund 2bea621f7d Documentation work
[ci skip]
2016-07-14 18:16:49 +02:00
Camilla Berglund 868f248696 Documentation work 2016-07-14 18:07:25 +02:00
A. Tombs 30111efc6d Update name in credits
Closes #807.
2016-07-14 12:49:46 +02:00
Camilla Berglund a28236d939 Fix matrix rotation regression
Related to #785.
2016-07-13 22:22:43 +02:00
Camilla Berglund 6fd4a87881 Update changelog 2016-07-13 22:22:41 +02:00
Camilla Berglund 9c5b994369 Make readme reference contribution guide 2016-07-12 16:29:59 +02:00
Camilla Berglund 9befef1b03 Update changelog 2016-07-12 16:23:46 +02:00
Camilla Berglund 0ff22e4a49 Win32: Fix GLFW_MAXIMIZED ignored by first window
Fixes #780.
2016-07-12 16:04:02 +02:00
Camilla Berglund 18b6ba0af4 Remove trailing whitespace 2016-07-12 15:35:06 +02:00
Camilla Berglund 9f14ac291f Add question section to contribution guide 2016-07-12 01:03:08 +02:00
ndogxj 65d4652e92 Fix VS 2010 build errors
VS 2010 cannot handle C99-style variable declarations in C mode.

Fixes #785.
2016-07-12 01:02:58 +02:00
Camilla Berglund 613868b893 Add missing assertion 2016-07-11 16:39:53 +02:00
Camilla Berglund 73abf8a800 Documentation work 2016-07-06 13:06:59 +02:00
Camilla Berglund 3bb5c459d6 GLX: Verify all entry points during load 2016-07-01 18:18:04 +02:00
Camilla Berglund 145ea03ca2 EGL: Verify all entry points during load 2016-07-01 18:17:30 +02:00
Camilla Berglund 49f429018e Win32: Fix code analysis warning 2016-06-23 17:41:22 +02:00
Camilla Berglund 66149a29da Cleanup 2016-06-23 17:40:30 +02:00
Camilla Berglund 0ee8159f6c Win32: Remove intermediate clipboard string copy 2016-06-23 17:06:03 +02:00
Camilla Berglund e81f4b29db Add Coverity badge, I guess 2016-06-23 16:09:55 +02:00
Camilla Berglund 1b82546b90 Cleanup 2016-06-23 15:34:23 +02:00
Camilla Berglund e250c226ca Cleanup 2016-06-23 14:48:25 +02:00
Camilla Berglund d67a0259cf Documentation work
[ci skip]
2016-06-23 14:18:01 +02:00
Camilla Berglund 7f2e4d8ace Win32: Fix possible leak of dummy context 2016-06-23 14:17:54 +02:00
Camilla Berglund 6f313ff245 Win32: Use helper window to load WGL extensions
This removes window re-creation logic by performing the initial context
creation on the helper window, simplifying both window and context
creation and paving the way for attaching to existing window handles
without compromising on context or framebuffer hint support.
2016-06-22 23:33:34 +02:00
Camilla Berglund a991c01731 Fail sharing if either window is context-less 2016-06-22 14:36:46 +02:00
Camilla Berglund b5aae7e901 Documentation work
[ci skip]
2016-06-22 13:33:25 +02:00
Camilla Berglund 5b7d6ed8b9 Documentation work 2016-06-21 16:46:17 +02:00
Camilla Berglund 38856886e6 Documentation work 2016-06-21 16:36:16 +02:00
Camilla Berglund f2ba78e04b Rename static functions to allow unity build
Fixes regression introduced by GLFW_CONTEXT_CREATION_API.

Fixes #783.
2016-06-15 01:35:07 +02:00
Camilla Berglund ae32d968b9 Fix test program line endings 2016-06-15 01:35:07 +02:00
Camilla Berglund df5dcf5162 Win32: Fix stub comment 2016-06-15 01:35:07 +02:00
Camilla Berglund 76801973e1 Cocoa: Clean up joystick globals 2016-06-15 01:35:07 +02:00
Camilla Berglund b6b8ff591d Fix cursor position coordinate delimiter
Comma would be great but we don't control the locale.
2016-06-15 01:35:07 +02:00
Camilla Berglund 9a781cef53 Formatting 2016-06-15 01:35:07 +02:00
Camilla Berglund aaccfd8201 I don't know how to C
Fixes #773.
2016-06-15 01:35:07 +02:00
Camilla Berglund 4bccb3dc9f Start 3.2.1 2016-06-15 01:35:05 +02:00
A. Tombs d8c278bf52 Add explanation of parameters to gamma test
Unlike similar test programs (e.g. tearing.c), the gamma test does not
explain the meanings of the optional parameters `h` and `f`. This patch
adds these explanations to the usage text.

Closes #775.
2016-06-06 21:25:13 +02:00
A. Tombs 407385dc72 Correct program name printed by tearing test
The tearing test incorrectly calls itself "iconify" when printing usage
information, probably just a copy-paste error.

Closes #774.
2016-06-06 21:23:30 +02:00
75 changed files with 1419 additions and 1051 deletions
+285 -45
View File
@@ -1,35 +1,118 @@
# Contribution Guide
This file is a work in progress and you can report errors or submit patches for
it the same as any other file.
## Contents
- [Asking a question](#asking-a-question)
- [Reporting a bug](#reporting-a-bug)
- [Reporting a compile or link bug](#reporting-a-compile-or-link-bug)
- [Reporting a segfault or other crash bug](#reporting-a-segfault-or-other-crash-bug)
- [Reporting a context creation bug](#reporting-a-context-creation-bug)
- [Reporting a monitor or video mode bug](#reporting-a-monitor-or-video-mode-bug)
- [Reporting an input or event bug](#reporting-an-input-or-event-bug)
- [Reporting some other library bug](#reporting-some-other-library-bug)
- [Reporting a documentation bug](#reporting-a-documentation-bug)
- [Reporting a website bug](#reporting-a-website-bug)
- [Requesting a feature](#requesting-a-feature)
- [Contributing a bug fix](#contributing-a-bug-fix)
- [Contributing a feature](#contributing-a-feature)
## Asking a question
Questions about how to use GLFW should be asked either in the [support
section](http://discourse.glfw.org/c/support) of the forum, under the [Stack
Overflow tag](https://stackoverflow.com/questions/tagged/glfw) or [Game
Development tag](https://gamedev.stackexchange.com/questions/tagged/glfw) on
Stack Exchange or in the IRC channel `#glfw` on
[Freenode](http://freenode.net/).
Questions about the design or implementation of GLFW or about future plans
should be asked in the [dev section](http://discourse.glfw.org/c/dev) of the
forum or in the IRC channel. Please don't open a GitHub issue to discuss design
questions without first checking with a maintainer.
## Reporting a bug
If GLFW is behaving unexpectedly, make sure you have set an error callback.
GLFW will often tell you the cause of an issue via this callback.
If GLFW is behaving unexpectedly at run-time, start by setting an [error
callback](http://www.glfw.org/docs/latest/intro_guide.html#error_handling).
GLFW will often tell you the cause of an error via this callback. If it
doesn't, that might be a separate bug.
If GLFW is crashing or triggering asserts, make sure that all your object
handles and other pointers are valid.
Always include the __operating system name and version__ (i.e. `Windows
7 64-bit` or `Ubuntu 15.10`). If you are using an official release of GLFW,
include the __GLFW release version__ (i.e. `3.1.2`), otherwise include the
__GLFW commit ID__ (i.e. `3795d78b14ef06008889cc422a1fb8d642597751`) from Git.
If possible, please also include the __GLFW version string__ (`3.2.0 X11 EGL
clock_gettime /dev/js XI Xf86vm`), as described
[here](http://www.glfw.org/docs/latest/intro.html#intro_version_string).
For bugs where it makes sense, a [Short, Self Contained, Correct (Compilable),
Example](http://www.sscce.org/) is absolutely invaluable. Just put it inline in
the body text. Note that if the bug is reproducible with one of the test
programs that come with GLFW, just mention that instead.
__Don't worry about adding too much information__. Unimportant information can
be abbreviated or removed later, but missing information can stall bug fixing,
especially when your schedule doesn't align with that of the maintainer.
There are issue labels for both platforms and GPU manufacturers, so there is no
need to mention these in the subject line. If you do, it will be removed when
the issue is labeled.
If your bug is already reported, please add any new information you have, or if
it already has everything, give it a :+1:.
### Reporting a compile or link bug
__Note:__ GLFW needs many system APIs to do its job. See the [Building
applications](http://www.glfw.org/docs/latest/build.html) guide for more
information.
__Note:__ GLFW needs many system APIs to do its job, which on some platforms
means linking to many system libraries. If you are using GLFW as a static
library, that means your application needs to link to these in addition to GLFW.
In addition to the information above, always include the complete build log from
your compiler and linker. Issue posts are editable so it can always be
shortened later.
__Note:__ Check the [Compiling
GLFW](http://www.glfw.org/docs/latest/compile.html) guide and or [Building
applications](http://www.glfw.org/docs/latest/build.html) guide for before
opening an issue of this kind. Most issues are caused by a missing package or
linker flag.
Always include the __operating system name and version__ (e.g. `Windows
7 64-bit` or `Ubuntu 15.10`) and the __compiler name and version__ (e.g. `Visual
C++ 2015 Update 2`). If you are using an official release of GLFW,
include the __GLFW release version__ (e.g. `3.1.2`), otherwise include the
__GLFW commit ID__ (e.g. `3795d78b14ef06008889cc422a1fb8d642597751`) from Git.
Please also include the __complete build log__ from your compiler and linker,
even if it's long. It can always be shortened later, if necessary.
#### Quick template
```
OS and version:
Compiler version:
Release or commit:
Build log:
```
### Reporting a segfault or other crash bug
Always include the __operating system name and version__ (e.g. `Windows
7 64-bit` or `Ubuntu 15.10`). If you are using an official release of GLFW,
include the __GLFW release version__ (e.g. `3.1.2`), otherwise include the
__GLFW commit ID__ (e.g. `3795d78b14ef06008889cc422a1fb8d642597751`) from Git.
Please also include any __error messages__ provided to your application via the
[error
callback](http://www.glfw.org/docs/latest/intro_guide.html#error_handling) and
the __full call stack__ of the crash, or if the crash does not occur in debug
mode, mention that instead.
#### Quick template
```
OS and version:
Release or commit:
Error messages:
Call stack:
```
### Reporting a context creation bug
@@ -38,23 +121,42 @@ __Note:__ Windows ships with graphics drivers that do not support OpenGL. If
GLFW says that your machine lacks support for OpenGL, it very likely does.
Install drivers from the computer manufacturer or graphics card manufacturer
([Nvidia](http://www.geforce.com/drivers),
[AMD](http://support.amd.com/en-us/download),
[Intel](https://www-ssl.intel.com/content/www/us/en/support/detect.html)) to
[AMD](http://support.amd.com/en-us/download),
[Intel](https://www-ssl.intel.com/content/www/us/en/support/detect.html)) to
fix this.
__Note:__ AMD only supports OpenGL ES on Windows via EGL. EGL support is not
enabled in GLFW by default. You need to [enable EGL when
compiling](http://www.glfw.org/docs/latest/compile.html) GLFW to use this.
__Note:__ AMD only supports OpenGL ES on Windows via EGL. See the
[GLFW\_CONTEXT\_CREATION\_API](http://www.glfw.org/docs/latest/window_guide.html#window_hints_ctx)
hint for how to select EGL.
The `glfwinfo` tool is included in the GLFW source tree as `tests/glfwinfo.c`
and is built along with the library. It lets you request any kind of context
and framebuffer format supported by the GLFW API without having to recompile.
If context creation fails in your application, please verify that it also fails
with this tool before reporting it as a bug.
Please verify that context creation also fails with the `glfwinfo` tool before
reporting it as a bug. This tool is included in the GLFW source tree as
`tests/glfwinfo.c` and is built along with the library. It has switches for all
GLFW context and framebuffer hints. Run `glfwinfo -h` for a complete list.
In addition to the information above (OS and GLFW version), always include the
__GPU model and driver version__ (i.e. `GeForce GTX660 with 352.79`) when
reporting this kind of bug.
Always include the __operating system name and version__ (e.g. `Windows
7 64-bit` or `Ubuntu 15.10`). If you are using an official release of GLFW,
include the __GLFW release version__ (e.g. `3.1.2`), otherwise include the
__GLFW commit ID__ (e.g. `3795d78b14ef06008889cc422a1fb8d642597751`) from Git.
Please also include the __GLFW version string__ (`3.2.0 X11 EGL clock_gettime
/dev/js XI Xf86vm`), as described
[here](http://www.glfw.org/docs/latest/intro.html#intro_version_string), the
__GPU model and driver version__ (e.g. `GeForce GTX660 with 352.79`), and the
__output of `glfwinfo`__ (with switches matching any hints you set in your
code) when reporting this kind of bug. If this tool doesn't run on the machine,
mention that instead.
#### Quick template
```
OS and version:
GPU and driver:
Release or commit:
Version string:
glfwinfo output:
```
### Reporting a monitor or video mode bug
@@ -63,23 +165,44 @@ __Note:__ On headless systems on some platforms, no monitors are reported. This
causes glfwGetPrimaryMonitor to return `NULL`, which not all applications are
prepared for.
__Note:__ Some third-party tools report more video modes than those approved of
by the OS. For safety and compatbility, GLFW only reports video modes the OS
__Note:__ Some third-party tools report more video modes than are approved of
by the OS. For safety and compatibility, GLFW only reports video modes the OS
wants programs to use. This is not a bug.
The `monitors` tool is included in the GLFW source tree as `tests/monitors.c`
and is built along with the library. lists all information about connected
monitors made available by GLFW.
and is built along with the library. It lists all information GLFW provides
about monitors it detects.
In addition to the information above (OS and GLFW version), please also include
the output of the `monitors` tool when reporting this kind of bug. If it
doesn't work at all, please mention this.
Always include the __operating system name and version__ (e.g. `Windows
7 64-bit` or `Ubuntu 15.10`). If you are using an official release of GLFW,
include the __GLFW release version__ (e.g. `3.1.2`), otherwise include the
__GLFW commit ID__ (e.g. `3795d78b14ef06008889cc422a1fb8d642597751`) from Git.
Please also include any __error messages__ provided to your application via the
[error
callback](http://www.glfw.org/docs/latest/intro_guide.html#error_handling) and
the __output of `monitors`__ when reporting this kind of bug. If this tool
doesn't run on the machine, mention this instead.
### Reporting a window event bug
#### Quick template
__Note:__ While GLFW tries to provide the exact same behavior between platforms,
the exact ordering of related window events will sometimes differ.
```
OS and version:
Release or commit:
Error messages:
monitors output:
```
### Reporting an input or event bug
__Note:__ The exact ordering of related window events will sometimes differ.
__Note:__ Window moving and resizing (by the user) will block the main thread on some
platforms. This is not a bug. Set a [refresh
callback](http://www.glfw.org/docs/latest/window.html#window_refresh) if you
want to keep the window contents updated during a move or size operation.
The `events` tool is included in the GLFW source tree as `tests/events.c` and is
built along with the library. It prints all information provided to every
@@ -87,20 +210,137 @@ callback supported by GLFW as events occur. Each event is listed with the time
and a unique number to make discussions about event logs easier. The tool has
command-line options for creating multiple windows and full screen windows.
Always include the __operating system name and version__ (e.g. `Windows
7 64-bit` or `Ubuntu 15.10`). If you are using an official release of GLFW,
include the __GLFW release version__ (e.g. `3.1.2`), otherwise include the
__GLFW commit ID__ (e.g. `3795d78b14ef06008889cc422a1fb8d642597751`) from Git.
Please also include any __error messages__ provided to your application via the
[error
callback](http://www.glfw.org/docs/latest/intro_guide.html#error_handling) and
if relevant, the __output of `events`__ when reporting this kind of bug. If
this tool doesn't run on the machine, mention this instead.
#### Quick template
```
OS and version:
Release or commit:
Error messages:
events output:
```
### Reporting some other library bug
Always include the __operating system name and version__ (e.g. `Windows
7 64-bit` or `Ubuntu 15.10`). If you are using an official release of GLFW,
include the __GLFW release version__ (e.g. `3.1.2`), otherwise include the
__GLFW commit ID__ (e.g. `3795d78b14ef06008889cc422a1fb8d642597751`) from Git.
Please also include any __error messages__ provided to your application via the
[error
callback](http://www.glfw.org/docs/latest/intro_guide.html#error_handling), if
relevant.
#### Quick template
```
OS and version:
Release or commit:
Error messages:
```
### Reporting a documentation bug
If you found the error in the generated documentation then it's fine to just
link to that webpage. You don't need to figure out which documentation source
file the text comes from.
If you found a bug in the documentation, including this file, then it's fine to
just link to that web page or mention that source file. You don't need to match
the source to the output or vice versa.
### Reporting a website bug
If the bug is in the documentation (anything under `/docs/`) then please see the
section above. Bugs in the rest of the site are reported to to the [website
source repository](https://github.com/glfw/website/issues).
## Requesting a feature
Please explain why you need the feature and how you intend to use it. If you
have a specific API design in mind, please add that as well. If you have or are
planning to write code for the feature, see the section below.
If there already is a request for the feature you need, add your specific use
case unless it is already mentioned. If it is, give it a :+1:.
## Contributing a bug fix
There should be text here, but there isn't.
__Note:__ You must have all necessary [intellectual
property rights](https://en.wikipedia.org/wiki/Intellectual_property) to any
code you contribute. If you did not write the code yourself, you must explain
where it came from and under what license you received it. Even code using the
same license as GLFW may not be copied without attribution.
__There is no preferred patch size__. A one character fix is just as welcome as
a thousand line one, if that is the appropriate size for the fix.
In addition to the code, a complete bug fix includes:
- Change log entry in `README.md`, describing the incorrect behavior
- Credits entries for all authors of the bug fix
Bug fixes will not be rejected because they don't include all the above parts,
but please keep in mind that maintainer time is finite and that there are many
other bugs and features to work on.
If the patch fixes a bug introduced after the last release, it should not get
a change log entry.
## Contributing a feature
This is not (yet) the text you are looking for.
__Note:__ You must have all necessary rights to any code you contribute. If you
did not write the code yourself, you must explain where it came from and under
what license. Even code using the same license as GLFW may not be copied
without attribution.
__There is no preferred patch size__. A one character change is just as welcome
as one adding a thousand line one, if that is the appropriate size for the
feature.
In addition to the code, a complete feature includes:
- Change log entry in `README.md`, listing all new symbols
- News page entry, briefly describing the feature
- Guide documentation, with minimal examples, in the relevant guide
- Reference documentation, with all applicable tags
- Cross-references and mentions in appropriate places
- Credits entries for all authors of the feature
If the feature requires platform-specific code, at minimum stubs must be added
for the new platform function to all supported and experimental platforms.
If it adds a new callback, support for it must be added to `tests/event.c`.
If it adds a new monitor property, support for it must be added to
`tests/monitor.c`.
If it adds a new OpenGL, OpenGL ES or Vulkan option or extension, support
for it must be added to `tests/glfwinfo.c` and the behavior of the library when
the extension is missing documented in `docs/compat.dox`.
Features will not be rejected because they don't include all the above parts,
but please keep in mind that maintainer time is finite and that there are many
other features and bugs to work on.
Please also keep in mind that any part of the public API that has been included
in a release cannot be changed until the next _major_ version. Features can be
added and existing parts can sometimes be overloaded (in the general sense of
doing more things, not in the C++ sense), but code written to the API of one
minor release should both compile and run on subsequent minor releases.
+4 -2
View File
@@ -40,11 +40,11 @@ src/wayland-relative-pointer-unstable-v1-protocol.c
# Compiled binaries
src/libglfw.so
src/libglfw.so.3
src/libglfw.so.3.2
src/libglfw.so.3.3
src/libglfw.dylib
src/libglfw.dylib
src/libglfw.3.dylib
src/libglfw.3.2.dylib
src/libglfw.3.3.dylib
src/libglfw3.a
src/glfw3.lib
src/glfw3.dll
@@ -67,6 +67,7 @@ tests/empty
tests/events
tests/gamma
tests/glfwinfo
tests/icon
tests/iconify
tests/joysticks
tests/monitors
@@ -75,6 +76,7 @@ tests/reopen
tests/sharing
tests/tearing
tests/threads
tests/timeout
tests/title
tests/version
tests/vulkan
+4 -1
View File
@@ -12,6 +12,9 @@ if (WIN32)
find_library(VULKAN_LIBRARY NAMES vulkan-1 HINTS
"$ENV{VULKAN_SDK}/Bin"
"$ENV{VK_SDK_PATH}/Bin")
find_library(VULKAN_STATIC_LIBRARY NAMES vkstatic.1 HINTS
"$ENV{VULKAN_SDK}/Bin"
"$ENV{VK_SDK_PATH}/Bin")
else()
find_library(VULKAN_LIBRARY NAMES vulkan-1 HINTS
"$ENV{VULKAN_SDK}/Bin32"
@@ -27,5 +30,5 @@ endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Vulkan DEFAULT_MSG VULKAN_LIBRARY VULKAN_INCLUDE_DIR)
mark_as_advanced(VULKAN_INCLUDE_DIR VULKAN_LIBRARY)
mark_as_advanced(VULKAN_INCLUDE_DIR VULKAN_LIBRARY VULKAN_STATIC_LIBRARY)
+23 -3
View File
@@ -11,7 +11,7 @@ if (NOT CMAKE_VERSION VERSION_LESS "3.0")
endif()
set(GLFW_VERSION_MAJOR "3")
set(GLFW_VERSION_MINOR "2")
set(GLFW_VERSION_MINOR "3")
set(GLFW_VERSION_PATCH "0")
set(GLFW_VERSION_EXTRA "")
set(GLFW_VERSION "${GLFW_VERSION_MAJOR}.${GLFW_VERSION_MINOR}")
@@ -25,6 +25,7 @@ option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" ON)
option(GLFW_BUILD_TESTS "Build the GLFW test programs" ON)
option(GLFW_BUILD_DOCS "Build the GLFW documentation" ON)
option(GLFW_INSTALL "Generate installation target" ON)
option(GLFW_VULKAN_STATIC "Use the Vulkan loader statically linked into application" OFF)
option(GLFW_DOCUMENT_INTERNALS "Include internals in documentation" OFF)
if (WIN32)
@@ -57,7 +58,11 @@ else()
set(GLFW_LIB_NAME glfw3)
endif()
set(CMAKE_MODULE_PATH "${GLFW_SOURCE_DIR}/CMake/modules")
if (GLFW_VULKAN_STATIC)
set(_GLFW_VULKAN_STATIC 1)
endif()
list(APPEND CMAKE_MODULE_PATH "${GLFW_SOURCE_DIR}/CMake/modules")
find_package(Threads REQUIRED)
find_package(Vulkan)
@@ -148,6 +153,21 @@ else()
message(FATAL_ERROR "No supported platform was detected")
endif()
#--------------------------------------------------------------------
# Add Vulkan static library if requested
#--------------------------------------------------------------------
if (GLFW_VULKAN_STATIC)
if (VULKAN_FOUND AND VULKAN_STATIC_LIBRARY)
list(APPEND glfw_LIBRARIES ${VULKAN_STATIC_LIBRARY})
else()
if (BUILD_SHARED_LIBS OR GLFW_BUILD_EXAMPLES OR GLFW_BUILD_TESTS)
message(FATAL_ERROR "Vulkan loader static library not found")
else()
message(WARNING "Vulkan loader static library not found")
endif()
endif()
endif()
#--------------------------------------------------------------------
# Find and add Unix math and time libraries
#--------------------------------------------------------------------
@@ -253,7 +273,7 @@ endif()
#--------------------------------------------------------------------
if (_GLFW_WAYLAND)
find_package(ECM REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH})
list(APPEND CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
find_package(Wayland REQUIRED)
find_package(WaylandScanner REQUIRED)
+60 -104
View File
@@ -2,22 +2,25 @@
[![Build status](https://travis-ci.org/glfw/glfw.svg?branch=master)](https://travis-ci.org/glfw/glfw)
[![Build status](https://ci.appveyor.com/api/projects/status/0kf0ct9831i5l6sp/branch/master?svg=true)](https://ci.appveyor.com/project/elmindreda/glfw)
[![Coverity Scan](https://scan.coverity.com/projects/4884/badge.svg)](https://scan.coverity.com/projects/glfw-glfw)
## Introduction
GLFW is a free, Open Source, multi-platform library for OpenGL, OpenGL ES and
Vulkan application development. It provides a simple, platform-independent API
for creating windows, contexts and surfaces, reading input, handling events, etc.
GLFW is an Open Source, multi-platform library for OpenGL, OpenGL ES and Vulkan
application development. It provides a simple, platform-independent API for
creating windows, contexts and surfaces, reading input, handling events, etc.
Version 3.2 adds support for Vulkan surface creation, window mode switching,
window maximization, window input focus control, window size and aspect ratio
limits, human-readable key names, window icons, joystick connection events,
XInput and DirectInput joystick input, event waiting with timeout, 64-bit
integer raw timer, context-less window creation, error-less contexts via
`GL_KHR_no_error` (where available), run-time context creation API selection,
Windows 8.1 per-monitor DPI and the CMake config-file package system, adds
simpler build-time configuration, improved documentation and fixes for a large
number of bugs that together affect all supported platforms.
GLFW is licensed under the [zlib/libpng
license](https://opensource.org/licenses/Zlib).
The latest stable release is version 3.2.1.
See the [downloads](http://www.glfw.org/download.html) page for details and
files, or fetch the `latest` branch, which always points to the latest stable
release. Each release starting with 3.0 also has a corresponding [annotated
tag](https://github.com/glfw/glfw/releases) with source and binary archives.
This is a development branch for version 3.3, which is _not yet described_.
If you are new to GLFW, you may find the
[tutorial](http://www.glfw.org/docs/latest/quick.html) for GLFW
@@ -28,37 +31,43 @@ the GLFW 3 API.
## Compiling GLFW
See the [Compiling GLFW](http://www.glfw.org/docs/latest/compile.html) guide in
the GLFW documentation.
GLFW itself requires only the headers and libraries for your window system. It
does not need the headers for any context creation API (WGL, GLX, EGL, NSGL) 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 OS X 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 also [pre-compiled Windows
binaries](http://www.glfw.org/download.html) available for all compilers
supported on that platform.
See the [compilation guide](http://www.glfw.org/docs/latest/compile.html) in the
documentation for more information.
## Using GLFW
See the
[Building programs that use GLFW](http://www.glfw.org/docs/latest/build.html)
guide in the GLFW documentation.
See the [building application guide](http://www.glfw.org/docs/latest/build.html)
guide in the documentation for more information.
## Reporting bugs
## System requirements
Bugs are reported to our [issue tracker](https://github.com/glfw/glfw/issues).
Please always include the name and version of the OS where the bug occurs and
the version of GLFW used. If you have cloned it, include the commit ID used.
GLFW supports Windows XP and later, OS X 10.7 Lion and later, and Linux and
other Unix-like systems with the X Window System. Experimental implementations
for the Wayland protocol and the Mir display server are available but not yet
officially supported.
If it's a build issue, please also include the build log and the name and
version of your development environment.
If it's a context creation issue, please also include the make and model of your
graphics card and the version of your driver.
This will help both us and other people experiencing the same bug.
See the [compatibility guide](http://www.glfw.org/docs/latest/compat.html)
in the documentation for more information.
## Dependencies
GLFW itself needs only the headers and libraries for your window system. It
does not need the headers for any context creation API (WGL, GLX, EGL, NSGL) or
rendering API (OpenGL, OpenGL ES, Vulkan) to enable support for them.
GLFW itself depends only on the headers and libraries for your window system.
The examples and test programs depend on a number of tiny libraries. These are
located in the `deps/` directory.
@@ -77,94 +86,37 @@ The Vulkan example additionally requires the Vulkan SDK to be installed, or it
will not be included in the build.
The documentation is generated with [Doxygen](http://doxygen.org/). If CMake
does not find Doxygen, the documentation will not be generated.
does not find Doxygen, the documentation will not be generated when you build.
## Reporting bugs
Bugs are reported to our [issue tracker](https://github.com/glfw/glfw/issues).
Please check the [contribution
guide](https://github.com/glfw/glfw/blob/master/.github/CONTRIBUTING.md) for
information on what to include when reporting a bug.
## Changelog
- Added `glfwVulkanSupported`, `glfwGetRequiredInstanceExtensions`,
`glfwGetInstanceProcAddress`, `glfwGetPhysicalDevicePresentationSupport` and
`glfwCreateWindowSurface` for platform independent Vulkan support
- Added `glfwSetWindowMonitor` for switching between windowed and full screen
modes and updating the monitor and desired video mode of full screen windows
- Added `glfwMaximizeWindow` and `GLFW_MAXIMIZED` for window maximization
- Added `glfwFocusWindow` for giving windows input focus
- Added `glfwSetWindowSizeLimits` and `glfwSetWindowAspectRatio` for setting
absolute and relative window size limits
- Added `glfwGetKeyName` for querying the layout-specific name of printable
keys
- Added `glfwWaitEventsTimeout` for waiting for events for a set amount of time
- Added `glfwSetWindowIcon` for setting the icon of a window
- Added `glfwGetTimerValue` and `glfwGetTimerFrequency` for raw timer access
- Added `glfwSetJoystickCallback` and `GLFWjoystickfun` for joystick connection
and disconnection events
- Added `GLFW_NO_API` for creating window without contexts
- Added `GLFW_INCLUDE_VULKAN` for including the Vulkan header
- Added `GLFW_CONTEXT_CREATION_API`, `GLFW_NATIVE_CONTEXT_API` and
`GLFW_EGL_CONTEXT_API` for run-time context creation API selection
- Added `GLFW_CONTEXT_NO_ERROR` context hint for `GL_KHR_no_error` support
- Added `GLFW_TRUE` and `GLFW_FALSE` as client API independent boolean values
- Added icons to examples on Windows and OS X
- Relaxed rules for native access header macros
- Removed dependency on external OpenGL or OpenGL ES headers
- Removed `_GLFW_USE_OPENGL`, `_GLFW_USE_GLESV1`, `_GLFW_USE_GLESV2`,
`_GLFW_WGL`, `_GLFW_NSGL`, `_GLFW_GLX` and `_GLFW_EGL` configuration macros
- [Win32] Added support for Windows 8.1 per-monitor DPI
- [Win32] Replaced winmm with XInput and DirectInput for joystick input
- [Win32] Bugfix: Window creation would segfault if video mode setting required
the system to be restarted
- [Win32] Bugfix: MinGW import library lacked the `lib` prefix
- [Win32] Bugfix: Monitor connection and disconnection events were not reported
when no windows existed
- [Win32] Bugfix: Activating or deactivating displays in software did not
trigger monitor callback
- [Win32] Bugfix: No monitors were listed on headless and VMware guest systems
- [Win32] Bugfix: Pressing Ctrl+Pause would report `GLFW_KEY_UNKNOWN`
- [Win32] Bugfix: Window size events would be reported in wrong order when
restoring a full screen window
- [Cocoa] Made joystick polling more efficient
- [Cocoa] Removed support for OS X 10.6
- [Cocoa] Bugfix: Full screen windows on secondary monitors were mispositioned
- [Cocoa] Bugfix: Connecting a joystick that reports no name would segfault
- [Cocoa] Bugfix: Modifier flags cache was not updated when window became key
- [Cocoa] Bugfix: Dead key character composition did not work
- [Cocoa] Bugfix: The CGL context was not released until the autorelease pool
was drained by another function
- [X11] Bugfix: Monitor connection and disconnection events were not reported
- [X11] Bugfix: Decoding of UTF-8 text from XIM could continue past the end
- [X11] Bugfix: An XKB structure was leaked during `glfwInit`
- [X11] Bugfix: XInput2 `XI_Motion` events interfered with the Steam overlay
- [POSIX] Bugfix: An unrelated TLS key could be deleted by `glfwTerminate`
- [Linux] Made joystick polling more efficient
- [WGL] Changed extension loading to only be performed once
- [WGL] Removed dependency on external WGL headers
- [GLX] Added `glfwGetGLXWindow` to query the `GLXWindow` of a window
- [GLX] Replaced legacy drawable with `GLXWindow`
- [GLX] Removed dependency on external GLX headers
- [GLX] Bugfix: NetBSD does not provide `libGL.so.1`
- [EGL] Added `_GLFW_USE_EGLPLATFORM_H` configuration macro for controlling
whether to use an existing `EGL/eglplatform.h` header
- [EGL] Added and documented test for if the context is current on the calling
thread during buffer swap
- [EGL] Removed dependency on external EGL headers
- [X11] Bugfix: The last interaction event time was not tracked
## Contact
The official website for GLFW is [glfw.org](http://www.glfw.org/). There you
can find the latest version of GLFW, as well as news, documentation and other
information about the project.
On [glfw.org](http://www.glfw.org/) you can find the latest version of GLFW, as
well as news, documentation and other information about the project.
If you have questions related to the use of GLFW, we have a
[support forum](http://discourse.glfw.org/), and the IRC
channel `#glfw` on [Freenode](http://freenode.net/).
[forum](http://discourse.glfw.org/), and the `#glfw` IRC channel on
[Freenode](http://freenode.net/).
If you have a bug to report, a patch to submit or a feature you'd like to
request, please file it in the
[issue tracker](https://github.com/glfw/glfw/issues) on GitHub.
Finally, if you're interested in helping out with the development of GLFW or
porting it to your favorite platform, join us on GitHub or IRC.
porting it to your favorite platform, join us on the forum, GitHub or IRC.
## Acknowledgements
@@ -207,8 +159,10 @@ skills.
- heromyth
- Lucas Hinderberger
- Paul Holden
- Warren Hu
- IntellectualKitty
- Aaron Jacobs
- Erik S. V. Jansson
- Toni Jovanoski
- Arseny Kapoulkine
- Osman Keskin
@@ -248,6 +202,7 @@ skills.
- Emmanuel Gil Peyrot
- Cyril Pichard
- Pieroman
- Philip Rideout
- Jorge Rodriguez
- Ed Ropple
- Aleksey Rybalkin
@@ -262,6 +217,7 @@ skills.
- Dmitri Shuralyov
- Daniel Skorupski
- Bradley Smith
- Patrick Snape
- Julian Squires
- Johannes Stein
- Justin Stoecker
@@ -269,7 +225,7 @@ skills.
- Nathan Sweet
- TTK-Bandit
- Sergey Tikhomirov
- A. Tombs
- Arthur Tombs
- Ioannis Tsakpinis
- Samuli Tuomola
- urraka
+27 -24
View File
@@ -3,7 +3,7 @@
#include <math.h>
#ifdef _MSC_VER
#ifdef _MSC_VER
#define inline __inline
#endif
@@ -192,19 +192,20 @@ static inline void mat4x4_rotate(mat4x4 R, mat4x4 M, float x, float y, float z,
vec3 u = {x, y, z};
if(vec3_len(u) > 1e-4) {
mat4x4 T, C, S;
vec3_norm(u, u);
mat4x4 T;
mat4x4_from_vec3_mul_outer(T, u, u);
mat4x4 S = {
{ 0, u[2], -u[1], 0},
{-u[2], 0, u[0], 0},
{ u[1], -u[0], 0, 0},
{ 0, 0, 0, 0}
};
S[1][2] = u[0];
S[2][1] = -u[0];
S[2][0] = u[1];
S[0][2] = -u[1];
S[0][1] = u[2];
S[1][0] = -u[2];
mat4x4_scale(S, S, s);
mat4x4 C;
mat4x4_identity(C);
mat4x4_sub(C, C, T);
@@ -213,7 +214,7 @@ static inline 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.;
mat4x4_mul(R, M, T);
} else {
mat4x4_dup(R, M);
@@ -257,6 +258,7 @@ static inline void mat4x4_rotate_Z(mat4x4 Q, mat4x4 M, float angle)
}
static inline void mat4x4_invert(mat4x4 T, mat4x4 M)
{
float idet;
float s[6];
float c[6];
s[0] = M[0][0]*M[1][1] - M[1][0]*M[0][1];
@@ -272,10 +274,10 @@ static inline void mat4x4_invert(mat4x4 T, mat4x4 M)
c[3] = M[2][1]*M[3][2] - M[3][1]*M[2][2];
c[4] = M[2][1]*M[3][3] - M[3][1]*M[2][3];
c[5] = M[2][2]*M[3][3] - M[3][2]*M[2][3];
/* Assumes it is invertible */
float idet = 1.0f/( s[0]*c[5]-s[1]*c[4]+s[2]*c[3]+s[3]*c[2]-s[4]*c[1]+s[5]*c[0] );
idet = 1.0f/( s[0]*c[5]-s[1]*c[4]+s[2]*c[3]+s[3]*c[2]-s[4]*c[1]+s[5]*c[0] );
T[0][0] = ( M[1][1] * c[5] - M[1][2] * c[4] + M[1][3] * c[3]) * idet;
T[0][1] = (-M[0][1] * c[5] + M[0][2] * c[4] - M[0][3] * c[3]) * idet;
T[0][2] = ( M[3][1] * s[5] - M[3][2] * s[4] + M[3][3] * s[3]) * idet;
@@ -298,12 +300,12 @@ static inline void mat4x4_invert(mat4x4 T, mat4x4 M)
}
static inline void mat4x4_orthonormalize(mat4x4 R, mat4x4 M)
{
mat4x4_dup(R, M);
float s = 1.;
vec3 h;
mat4x4_dup(R, M);
vec3_norm(R[2], R[2]);
s = vec3_mul_inner(R[1], R[2]);
vec3_scale(h, R[2], s);
vec3_sub(R[1], R[1], h);
@@ -324,7 +326,7 @@ static inline void mat4x4_frustum(mat4x4 M, float l, float r, float b, float t,
{
M[0][0] = 2.f*n/(r-l);
M[0][1] = M[0][2] = M[0][3] = 0.f;
M[1][1] = 2.f*n/(t-b);
M[1][0] = M[1][2] = M[1][3] = 0.f;
@@ -332,7 +334,7 @@ static inline void mat4x4_frustum(mat4x4 M, float l, float r, float b, float t,
M[2][1] = (t+b)/(t-b);
M[2][2] = -(f+n)/(f-n);
M[2][3] = -1.f;
M[3][2] = -2.f*(f*n)/(f-n);
M[3][0] = M[3][1] = M[3][3] = 0.f;
}
@@ -346,7 +348,7 @@ static inline void mat4x4_ortho(mat4x4 M, float l, float r, float b, float t, fl
M[2][2] = -2.f/(f-n);
M[2][0] = M[2][1] = M[2][3] = 0.f;
M[3][0] = -(r+l)/(r-l);
M[3][1] = -(t+b)/(t-b);
M[3][2] = -(f+n)/(f-n);
@@ -387,14 +389,15 @@ static inline void mat4x4_look_at(mat4x4 m, vec3 eye, vec3 center, vec3 up)
/* TODO: The negation of of can be spared by swapping the order of
* operands in the following cross products in the right way. */
vec3 f;
vec3_sub(f, center, eye);
vec3_norm(f, f);
vec3 s;
vec3 t;
vec3_sub(f, center, eye);
vec3_norm(f, f);
vec3_mul_cross(s, f, up);
vec3_norm(s, s);
vec3 t;
vec3_mul_cross(t, s, f);
m[0][0] = s[0];
@@ -470,9 +473,9 @@ static inline void quat_conj(quat r, quat q)
r[3] = q[3];
}
static inline void quat_rotate(quat r, float angle, vec3 axis) {
int i;
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);
@@ -507,7 +510,7 @@ static inline void mat4x4_from_quat(mat4x4 M, quat q)
float b2 = b*b;
float c2 = c*c;
float d2 = d*d;
M[0][0] = a2 + b2 - c2 - d2;
M[0][1] = 2.f*(b*c + a*d);
M[0][2] = 2.f*(b*d - a*c);
+45 -21
View File
@@ -103,7 +103,8 @@ and only for compatibility with legacy code. GLU has been deprecated and should
not be used in new code.
@note GLFW does not provide any of the API headers mentioned above. They must
be provided by your development environment or your OpenGL or OpenGL ES SDK.
be provided by your development environment or your OpenGL, OpenGL ES or Vulkan
SDK.
@note None of these macros may be defined during the compilation of GLFW itself.
If your build includes GLFW and you define any these in your build files, make
@@ -184,21 +185,35 @@ the include directory for the GLFW header and, when applicable, the
target_link_libraries(myapp glfw)
@endcode
Note that it does not include GLU, as GLFW does not use it. If your application
needs GLU, you can find it by requiring the OpenGL package.
Note that the dependencies do not include OpenGL or GLU, as GLFW loads any
OpenGL, OpenGL ES or Vulkan libraries it needs at runtime and does not use GLU.
If your application calls OpenGL directly, instead of using a modern
[extension loader library](@ref context_glext_auto) you can find it by requiring
the OpenGL package.
@code{.cmake}
find_package(OpenGL REQUIRED)
@endcode
If GLU is found, the `OPENGL_GLU_FOUND` variable is true and the
`OPENGL_INCLUDE_DIR` and `OPENGL_glu_LIBRARY` cache variables can be used.
If OpenGL is found, the `OPENGL_FOUND` variable is true and the
`OPENGL_INCLUDE_DIR` and `OPENGL_gl_LIBRARY` cache variables can be used.
@code{.cmake}
target_include_directories(myapp ${OPENGL_INCLUDE_DIR})
target_link_libraries(myapp ${OPENGL_gl_LIBRARY})
@endcode
The OpenGL CMake package also looks for GLU. If GLU is found, the
`OPENGL_GLU_FOUND` variable is true and the `OPENGL_INCLUDE_DIR` and
`OPENGL_glu_LIBRARY` cache variables can be used.
@code{.cmake}
target_link_libraries(myapp ${OPENGL_glu_LIBRARY})
@endcode
@note GLU has been deprecated and should not be used in new code, but some
legacy code requires it.
@subsection build_link_cmake_package With CMake and installed GLFW binaries
@@ -210,33 +225,38 @@ With just a few changes to your `CMakeLists.txt`, you can locate the package and
target files generated when GLFW is installed.
@code{.cmake}
find_package(glfw3 3.2 REQUIRED)
find_package(glfw3 3.3 REQUIRED)
@endcode
Once GLFW has been located, link against it with the `glfw` target. This adds
all link-time dependencies of GLFW as it is currently configured, the include
directory for the GLFW header and, when applicable, the
[GLFW_DLL](@ref build_macros) macro.
@code{.cmake}
target_link_libraries(myapp glfw)
@endcode
Note that it does not include GLU, as GLFW does not use it. If your application
needs GLU, you can find it by requiring the OpenGL package.
Note that the dependencies do not include OpenGL or GLU, as GLFW loads any
OpenGL, OpenGL ES or Vulkan libraries it needs at runtime and does not use GLU.
If your application calls OpenGL directly, instead of using a modern
[extension loader library](@ref context_glext_auto) you can find it by requiring
the OpenGL package.
@code{.cmake}
find_package(OpenGL REQUIRED)
@endcode
If GLU is found, the `OPENGL_GLU_FOUND` variable is true and the
`OPENGL_INCLUDE_DIR` and `OPENGL_glu_LIBRARY` cache variables can be used.
If OpenGL is found, the `OPENGL_FOUND` variable is true and the
`OPENGL_INCLUDE_DIR` and `OPENGL_gl_LIBRARY` cache variables can be used.
@code{.cmake}
target_include_directories(myapp ${OPENGL_INCLUDE_DIR})
target_link_libraries(myapp ${OPENGL_gl_LIBRARY})
@endcode
The OpenGL CMake package also looks for GLU. If GLU is found, the
`OPENGL_GLU_FOUND` variable is true and the `OPENGL_INCLUDE_DIR` and
`OPENGL_glu_LIBRARY` cache variables can be used.
@code{.cmake}
target_link_libraries(myapp ${OPENGL_glu_LIBRARY})
@endcode
@note GLU has been deprecated and should not be used in new code, but some
legacy code requires it.
@subsection build_link_pkgconfig With makefiles and pkg-config on Unix
@@ -268,8 +288,9 @@ You can also use the `glfw3.pc` file without installing it first, by using the
env PKG_CONFIG_PATH=path/to/glfw/src cc `pkg-config --cflags glfw3` -o myprog myprog.c `pkg-config --libs glfw3`
@endcode
The dependencies do not include GLU, as GLFW does not use it. On OS X, GLU is
built into the OpenGL framework, so if you need GLU you don't need to do
The dependencies do not include OpenGL or GLU, as GLFW loads any OpenGL, OpenGL
ES or Vulkan libraries it needs at runtime and does not use GLU. On OS X, GLU
is built into the OpenGL framework, so if you need GLU you don't need to do
anything extra. If you need GLU and are using Linux or BSD, you should add the
`glu` pkg-config package.
@@ -277,6 +298,9 @@ anything extra. If you need GLU and are using Linux or BSD, you should add the
cc `pkg-config --cflags glfw3 glu` -o myprog myprog.c `pkg-config --libs glfw3 glu`
@endcode
@note GLU has been deprecated and should not be used in new code, but some
legacy code requires it.
If you are using the static version of the GLFW library, make sure you don't
link statically against GLU.
+1 -1
View File
@@ -185,7 +185,7 @@ a non-default value will cause @ref glfwCreateWindow to fail and the
@section compat_vulkan Vulkan loader and API
GLFW uses the standard system-wside Vulkan loader to access the Vulkan API.
GLFW uses the standard system-wide Vulkan loader to access the Vulkan API.
This should be installed by graphics drivers and Vulkan SDKs. If this is not
available, @ref glfwVulkanSupported will return `GLFW_FALSE` and all other
Vulkan-related functions will fail with an @ref GLFW_API_UNAVAILABLE error.
+8 -3
View File
@@ -197,6 +197,9 @@ built along with the library.
`GLFW_BUILD_DOCS` determines whether the GLFW documentation is built along with
the library.
`GLFW_VULKAN_STATIC` determines whether to use the Vulkan loader linked
statically into the application.
@subsubsection compile_options_osx OS X specific CMake options
@@ -214,9 +217,7 @@ Retina displays.
`USE_MSVC_RUNTIME_LIBRARY_DLL` determines whether to use the DLL version or the
static library version of the Visual C++ runtime library. If set to `ON`, the
DLL version of the Visual C++ library is used. It is recommended to set this to
`ON`, as this keeps the executable smaller and benefits from security and bug
fix updates of the Visual C++ runtime.
DLL version of the Visual C++ library is used.
`GLFW_USE_HYBRID_HPG` determines whether to export the `NvOptimusEnablement` and
`AmdPowerXpressRequestHighPerformance` symbols, which force the use of the
@@ -251,6 +252,10 @@ ramps and clipboard. The options are:
If you are building GLFW as a shared library / dynamic library / DLL then you
must also define `_GLFW_BUILD_DLL`. Otherwise, you must not define it.
If you are linking the Vulkan loader statically into your application then you
must also define `_GLFW_VULKAN_STATIC`. Otherwise, GLFW will attempt to use the
external version.
For the EGL context creation API, the following options are available:
- `_GLFW_USE_EGLPLATFORM_H` to use `EGL/eglplatform.h` for native handle
+2 -3
View File
@@ -5,9 +5,8 @@
@tableofcontents
This guide introduces the OpenGL and OpenGL ES context related functions of
GLFW. For details on a specific function, see the
[reference documentation](@ref context). There are also guides for the other
areas of the GLFW API.
GLFW. For details on a specific function in this category, see the @ref
context. There are also guides for the other areas of the GLFW API.
- @ref intro_guide
- @ref window_guide
+3 -2
View File
@@ -5,12 +5,13 @@
@tableofcontents
This guide introduces the input related functions of GLFW. For details on
a specific function, see the [reference documentation](@ref input). There are
also guides for the other areas of GLFW.
a specific function in this category, see the @ref input. There are also guides
for the other areas of GLFW.
- @ref intro_guide
- @ref window_guide
- @ref context_guide
- @ref vulkan_guide
- @ref monitor_guide
GLFW provides many kinds of input. While some can only be polled, like time, or
+16 -13
View File
@@ -4,10 +4,10 @@
@tableofcontents
This guide introduces the basic concepts of GLFW and describes initialization reference
This guide introduces the basic concepts of GLFW and describes initialization,
error handling and API guarantees and limitations. For a broad but shallow
tutorial, see @ref quick_guide instead. For details on a specific function, see the
[reference documentation](@ref init).
tutorial, see @ref quick_guide instead. For details on a specific function in
this category, see the @ref init.
There are also guides for the other areas of GLFW.
@@ -34,8 +34,8 @@ successfully initialized, and only from the main thread.
- @ref glfwInit
- @ref glfwTerminate
Calling any other function before that time will cause a @ref
GLFW_NOT_INITIALIZED error.
Calling any other function before successful initialization will cause a @ref
GLFW_NOT_INITIALIZED error.
@subsection intro_init_init Initializing GLFW
@@ -50,13 +50,15 @@ if (!glfwInit())
}
@endcode
If any part of initialization fails, all remaining bits are terminated as if
@ref glfwTerminate was called. The library only needs to be initialized once
and additional calls to an already initialized library will simply return
If any part of initialization fails, any parts that succeeded are terminated as
if @ref glfwTerminate had been called. The library only needs to be initialized
once and additional calls to an already initialized library will simply return
`GLFW_TRUE` immediately.
Once the library has been successfully initialized, it should be terminated
before the application exits.
before the application exits. Modern systems are very good at freeing resources
allocated by programs that simply exit, but GLFW sometimes has to change global
system settings and these might not be restored without termination.
@subsection intro_init_terminate Terminating GLFW
@@ -70,7 +72,7 @@ glfwTerminate();
This will destroy any remaining window, monitor and cursor objects, restore any
modified gamma ramps, re-enable the screensaver if it had been disabled and free
any resources allocated by GLFW.
any other resources allocated by GLFW.
Once the library is terminated, it is as if it had never been initialized and
you will need to initialize it again before being able to use GLFW. If the
@@ -282,9 +284,10 @@ allow calls from any thread in future releases.
@subsection compatibility Version compatibility
GLFW guarantees binary backward compatibility with earlier minor versions of the
API. This means that you can drop in a newer version of the GLFW DLL / shared
library / dynamic library and existing applications will continue to run.
GLFW guarantees source and binary backward compatibility with earlier minor
versions of the API. This means that you can drop in a newer version of the
library and existing programs will continue to compile and existing binaries
will continue to run.
Once a function or constant has been added, the signature of that function or
value of that constant will remain unchanged until the next major version of
+1 -1
View File
@@ -8,7 +8,7 @@ GLFW is a free, Open Source, multi-platform library for OpenGL, OpenGL ES and
Vulkan application development. It provides a simple, platform-independent API
for creating windows, contexts and surfaces, reading input, handling events, etc.
See @ref news_32 for release highlights or the
See @ref news_33 for release highlights or the
[version history](http://www.glfw.org/changelog.html) for details.
@ref quick_guide is a guide for users new to GLFW. It takes you through how to
+3 -2
View File
@@ -5,12 +5,13 @@
@tableofcontents
This guide introduces the monitor related functions of GLFW. For details on
a specific function, see the [reference documentation](@ref monitor). There are
also guides for the other areas of GLFW.
a specific function in this category, see the @ref monitor. There are also
guides for the other areas of GLFW.
- @ref intro_guide
- @ref window_guide
- @ref context_guide
- @ref vulkan_guide
- @ref input_guide
+4 -1
View File
@@ -2,6 +2,9 @@
@page news New features
@section news_33 New features in 3.3
@section news_32 New features in 3.2
@@ -345,7 +348,7 @@ well as moving a window to a specific position before showing it.
@subsection news_30_undecorated Undecorated windows
Windowed mode windows can now be created without decorations, i.e. things like
Windowed mode windows can now be created without decorations, e.g. things like
a frame, a title bar, with the `GLFW_DECORATED` window hint. This allows for
the creation of things like splash screens.
+4 -5
View File
@@ -18,9 +18,8 @@ The GLFW library does not need the Vulkan SDK to enable support for Vulkan.
However, any Vulkan-specific test and example programs are built only if the
CMake files find a Vulkan SDK.
For details on a specific function, see the
[reference documentation](@ref vulkan). There are also guides for the other
areas of the GLFW API.
For details on a specific function in this category, see the @ref vulkan. There
are also guides for the other areas of the GLFW API.
- @ref intro_guide
- @ref window_guide
@@ -39,8 +38,8 @@ before including the GLFW header.
#include <GLFW/glfw3.h>
@endcode
If you want to include the Vulkan header from a custom location or use your own
custom Vulkan header then you need to include them before the GLFW header.
If you instead want to include the Vulkan header from a custom location or use
your own custom Vulkan header then do this before the GLFW header.
@code
#include <path/to/vulkan.h>
+10 -4
View File
@@ -5,11 +5,12 @@
@tableofcontents
This guide introduces the window related functions of GLFW. For details on
a specific function, see the [reference documentation](@ref window). There are
also guides for the other areas of GLFW.
a specific function in this category, see the @ref window. There are also
guides for the other areas of GLFW.
- @ref intro_guide
- @ref context_guide
- @ref vulkan_guide
- @ref monitor_guide
- @ref input_guide
@@ -79,7 +80,8 @@ Once you have a full screen window, you can change its resolution, refresh rate
and monitor with @ref glfwSetWindowMonitor. If you just need change its
resolution you can also call @ref glfwSetWindowSize. In all cases, the new
video mode will be selected the same way as the video mode chosen by @ref
glfwCreateWindow.
glfwCreateWindow. If the window has an OpenGL or OpenGL ES context, it will be
unaffected.
By default, the original video mode of the monitor will be restored and the
window iconified if it loses input focus, to allow the user to switch back to
@@ -268,6 +270,10 @@ 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.
`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.
@@ -645,7 +651,7 @@ As long as your source file is encoded as UTF-8, you can use any Unicode
characters directly in the source.
@code
glfwSetWindowTitle(window, "星を追う子ども");
glfwSetWindowTitle(window, "ラストエグザイル");
@endcode
If you are using C++11 or C11, you can use a UTF-8 string literal.
+26 -13
View File
@@ -1,5 +1,5 @@
/*************************************************************************
* GLFW 3.2 - www.glfw.org
* GLFW 3.3 - www.glfw.org
* A library for OpenGL, window and input
*------------------------------------------------------------------------
* Copyright (c) 2002-2006 Marcus Geelnard
@@ -115,11 +115,14 @@ extern "C" {
#define GLFW_CALLBACK_DEFINED
#endif /* CALLBACK */
/* Most Windows GLU headers need wchar_t.
* The OS X OpenGL header blocks the definition of ptrdiff_t by glext.h.
/* Include because most Windows GLU headers need wchar_t and
* the OS X OpenGL header blocks the definition of ptrdiff_t by glext.h.
* Include it unconditionally to avoid surprising side-effects.
*/
#include <stddef.h>
/* Include because it is needed by Vulkan and related functions.
*/
#include <stdint.h>
/* Include the chosen client API headers.
@@ -219,7 +222,7 @@ extern "C" {
* backward-compatible.
* @ingroup init
*/
#define GLFW_VERSION_MINOR 2
#define GLFW_VERSION_MINOR 3
/*! @brief The revision number of the GLFW library.
*
* This is incremented when a bug fix release is made that does not contain any
@@ -1182,6 +1185,7 @@ typedef struct GLFWgammaramp
/*! @brief Image data.
*
* @sa @ref cursor_custom
* @sa @ref window_icon
*
* @since Added in version 2.1.
* @glfw3 Removed format and bytes-per-pixel members.
@@ -1739,6 +1743,10 @@ GLFWAPI void glfwWindowHint(int hint, int value);
* screen windows, including the creation of so called _windowed full screen_
* or _borderless full screen_ windows, see @ref window_windowed_full_screen.
*
* Once you have created the window, you can switch it between windowed and
* full screen mode with @ref glfwSetWindowMonitor. If the window has an
* OpenGL or OpenGL ES context, it will be unaffected.
*
* By default, newly created windows use the placement recommended by the
* window system. To create the window at a specific position, make it
* initially invisible using the [GLFW_VISIBLE](@ref window_hints_wnd) window
@@ -2390,8 +2398,8 @@ GLFWAPI void glfwFocusWindow(GLFWwindow* window);
* in full screen on.
*
* @param[in] window The window to query.
* @return The monitor, or `NULL` if the window is in windowed mode or an error
* occurred.
* @return The monitor, or `NULL` if the window is in windowed mode or an
* [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
*
@@ -2846,7 +2854,7 @@ GLFWAPI void glfwWaitEventsTimeout(double timeout);
/*! @brief Posts an empty event to the event queue.
*
* This function posts an empty event from the current thread to the event
* queue, causing @ref glfwWaitEvents to return.
* queue, causing @ref glfwWaitEvents or @ref glfwWaitEventsTimeout to return.
*
* If no windows exist, this function returns immediately. For synchronization
* of threads in applications that do not create windows, use your threading
@@ -2859,6 +2867,7 @@ GLFWAPI void glfwWaitEventsTimeout(double timeout);
*
* @sa @ref events
* @sa glfwWaitEvents
* @sa glfwWaitEventsTimeout
*
* @since Added in version 3.1.
*
@@ -3354,7 +3363,7 @@ GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* window, GLFWcharfun cbfun);
* @param[in] cbfun The new callback, or `NULL` to remove the currently set
* callback.
* @return The previously set callback, or `NULL` if no callback was set or an
* error occurred.
* [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
*
@@ -3533,8 +3542,10 @@ GLFWAPI int glfwJoystickPresent(int joy);
*
* @param[in] joy The [joystick](@ref joysticks) to query.
* @param[out] count Where to store the number of axis values in the returned
* array. This is set to zero if an error occurred.
* @return An array of axis values, or `NULL` if the joystick is not present.
* array. This is set to zero if the joystick is not present or an error
* occurred.
* @return An array of axis values, or `NULL` if the joystick is not present or
* an [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
* GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
@@ -3565,8 +3576,10 @@ GLFWAPI const float* glfwGetJoystickAxes(int joy, int* count);
*
* @param[in] joy The [joystick](@ref joysticks) to query.
* @param[out] count Where to store the number of button states in the returned
* array. This is set to zero if an error occurred.
* @return An array of button states, or `NULL` if the joystick is not present.
* array. This is set to zero if the joystick is not present or an error
* occurred.
* @return An array of button states, or `NULL` if the joystick is not present
* or an [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
* GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
@@ -3599,7 +3612,7 @@ GLFWAPI const unsigned char* glfwGetJoystickButtons(int joy, int* count);
*
* @param[in] joy The [joystick](@ref joysticks) to query.
* @return The UTF-8 encoded name of the joystick, or `NULL` if the joystick
* is not present.
* is not present or an [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
* GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
+1 -1
View File
@@ -1,5 +1,5 @@
/*************************************************************************
* GLFW 3.2 - www.glfw.org
* GLFW 3.3 - www.glfw.org
* A library for OpenGL, window and input
*------------------------------------------------------------------------
* Copyright (c) 2002-2006 Marcus Geelnard
+3 -4
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 OS X - www.glfw.org
// GLFW 3.3 OS X - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2009-2016 Camilla Berglund <elmindreda@glfw.org>
//
@@ -325,9 +325,6 @@ int _glfwPlatformInit(void)
if (!_glfwInitThreadLocalStoragePOSIX())
return GLFW_FALSE;
if (!_glfwInitNSGL())
return GLFW_FALSE;
_glfwInitTimerNS();
_glfwInitJoysticksNS();
@@ -362,6 +359,8 @@ void _glfwPlatformTerminate(void)
removeObserver:_glfw.ns.listener
name:(__bridge NSString*)kTISNotifySelectedKeyboardInputSourceChanged
object:nil];
[[NSDistributedNotificationCenter defaultCenter]
removeObserver:_glfw.ns.listener];
[_glfw.ns.listener release];
_glfw.ns.listener = nil;
}
+5 -12
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 Cocoa - www.glfw.org
// GLFW 3.3 Cocoa - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2006-2016 Camilla Berglund <elmindreda@glfw.org>
//
@@ -32,12 +32,13 @@
#include <IOKit/hid/IOHIDLib.h>
#include <IOKit/hid/IOHIDKeys.h>
#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE _GLFWjoystickNS ns_js
#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE \
_GLFWjoystickNS ns_js[GLFW_JOYSTICK_LAST + 1]
// Cocoa-specific per-joystick data
//
typedef struct _GLFWjoydeviceNS
typedef struct _GLFWjoystickNS
{
GLFWbool present;
char name[256];
@@ -50,17 +51,9 @@ typedef struct _GLFWjoydeviceNS
float* axes;
unsigned char* buttons;
} _GLFWjoydeviceNS;
// Cocoa-specific joystick API data
//
typedef struct _GLFWjoystickNS
{
_GLFWjoydeviceNS js[GLFW_JOYSTICK_LAST + 1];
IOHIDManagerRef managerRef;
} _GLFWjoystickNS;
void _glfwInitJoysticksNS(void);
void _glfwTerminateJoysticksNS(void);
+29 -29
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 Cocoa - www.glfw.org
// GLFW 3.3 Cocoa - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2009-2016 Camilla Berglund <elmindreda@glfw.org>
// Copyright (c) 2012 Torsten Walluhn <tw@mad-cad.net>
@@ -57,7 +57,7 @@ static void getElementsCFArrayHandler(const void* value, void* parameter);
// Adds an element to the specified joystick
//
static void addJoystickElement(_GLFWjoydeviceNS* js,
static void addJoystickElement(_GLFWjoystickNS* js,
IOHIDElementRef elementRef)
{
IOHIDElementType elementType;
@@ -126,14 +126,14 @@ static void getElementsCFArrayHandler(const void* value, void* parameter)
{
if (CFGetTypeID(value) == IOHIDElementGetTypeID())
{
addJoystickElement((_GLFWjoydeviceNS*) parameter,
addJoystickElement((_GLFWjoystickNS*) parameter,
(IOHIDElementRef) value);
}
}
// Returns the value of the specified element of the specified joystick
//
static long getElementValue(_GLFWjoydeviceNS* js, _GLFWjoyelementNS* element)
static long getElementValue(_GLFWjoystickNS* js, _GLFWjoyelementNS* element)
{
IOReturn result = kIOReturnSuccess;
IOHIDValueRef valueRef;
@@ -163,7 +163,7 @@ static long getElementValue(_GLFWjoydeviceNS* js, _GLFWjoyelementNS* element)
// Removes the specified joystick
//
static void removeJoystick(_GLFWjoydeviceNS* js)
static void removeJoystick(_GLFWjoystickNS* js)
{
int i;
@@ -188,14 +188,14 @@ static void removeJoystick(_GLFWjoydeviceNS* js)
free(js->axes);
free(js->buttons);
memset(js, 0, sizeof(_GLFWjoydeviceNS));
memset(js, 0, sizeof(_GLFWjoystickNS));
_glfwInputJoystickChange(js - _glfw.ns_js.js, GLFW_DISCONNECTED);
_glfwInputJoystickChange(js - _glfw.ns_js, GLFW_DISCONNECTED);
}
// Polls for joystick axis events and updates GLFW state
//
static GLFWbool pollJoystickAxisEvents(_GLFWjoydeviceNS* js)
static GLFWbool pollJoystickAxisEvents(_GLFWjoystickNS* js)
{
CFIndex i;
@@ -221,7 +221,7 @@ static GLFWbool pollJoystickAxisEvents(_GLFWjoydeviceNS* js)
// Polls for joystick button events and updates GLFW state
//
static GLFWbool pollJoystickButtonEvents(_GLFWjoydeviceNS* js)
static GLFWbool pollJoystickButtonEvents(_GLFWjoystickNS* js)
{
CFIndex i;
int buttonIndex = 0;
@@ -271,25 +271,25 @@ static void matchCallback(void* context,
void* sender,
IOHIDDeviceRef deviceRef)
{
_GLFWjoydeviceNS* js;
_GLFWjoystickNS* js;
int joy;
for (joy = GLFW_JOYSTICK_1; joy <= GLFW_JOYSTICK_LAST; joy++)
{
if (_glfw.ns_js.js[joy].present && _glfw.ns_js.js[joy].deviceRef == deviceRef)
if (_glfw.ns_js[joy].present && _glfw.ns_js[joy].deviceRef == deviceRef)
return;
}
for (joy = GLFW_JOYSTICK_1; joy <= GLFW_JOYSTICK_LAST; joy++)
{
if (!_glfw.ns_js.js[joy].present)
if (!_glfw.ns_js[joy].present)
break;
}
if (joy > GLFW_JOYSTICK_LAST)
return;
js = _glfw.ns_js.js + joy;
js = _glfw.ns_js + joy;
js->present = GLFW_TRUE;
js->deviceRef = deviceRef;
@@ -338,9 +338,9 @@ static void removeCallback(void* context,
for (joy = GLFW_JOYSTICK_1; joy <= GLFW_JOYSTICK_LAST; joy++)
{
if (_glfw.ns_js.js[joy].deviceRef == deviceRef)
if (_glfw.ns_js[joy].deviceRef == deviceRef)
{
removeJoystick(_glfw.ns_js.js + joy);
removeJoystick(_glfw.ns_js + joy);
break;
}
}
@@ -397,8 +397,8 @@ void _glfwInitJoysticksNS(void)
{
CFMutableArrayRef matchingCFArrayRef;
_glfw.ns_js.managerRef = IOHIDManagerCreate(kCFAllocatorDefault,
kIOHIDOptionsTypeNone);
_glfw.ns.hidManager = IOHIDManagerCreate(kCFAllocatorDefault,
kIOHIDOptionsTypeNone);
matchingCFArrayRef = CFArrayCreateMutable(kCFAllocatorDefault,
0,
@@ -431,21 +431,21 @@ void _glfwInitJoysticksNS(void)
CFRelease(matchingCFDictRef);
}
IOHIDManagerSetDeviceMatchingMultiple(_glfw.ns_js.managerRef,
IOHIDManagerSetDeviceMatchingMultiple(_glfw.ns.hidManager,
matchingCFArrayRef);
CFRelease(matchingCFArrayRef);
}
IOHIDManagerRegisterDeviceMatchingCallback(_glfw.ns_js.managerRef,
IOHIDManagerRegisterDeviceMatchingCallback(_glfw.ns.hidManager,
&matchCallback, NULL);
IOHIDManagerRegisterDeviceRemovalCallback(_glfw.ns_js.managerRef,
IOHIDManagerRegisterDeviceRemovalCallback(_glfw.ns.hidManager,
&removeCallback, NULL);
IOHIDManagerScheduleWithRunLoop(_glfw.ns_js.managerRef,
IOHIDManagerScheduleWithRunLoop(_glfw.ns.hidManager,
CFRunLoopGetMain(),
kCFRunLoopDefaultMode);
IOHIDManagerOpen(_glfw.ns_js.managerRef, kIOHIDOptionsTypeNone);
IOHIDManagerOpen(_glfw.ns.hidManager, kIOHIDOptionsTypeNone);
// Execute the run loop once in order to register any initially-attached
// joysticks
@@ -460,12 +460,12 @@ void _glfwTerminateJoysticksNS(void)
for (joy = GLFW_JOYSTICK_1; joy <= GLFW_JOYSTICK_LAST; joy++)
{
_GLFWjoydeviceNS* js = _glfw.ns_js.js + joy;
_GLFWjoystickNS* js = _glfw.ns_js + joy;
removeJoystick(js);
}
CFRelease(_glfw.ns_js.managerRef);
_glfw.ns_js.managerRef = NULL;
CFRelease(_glfw.ns.hidManager);
_glfw.ns.hidManager = NULL;
}
@@ -475,13 +475,13 @@ void _glfwTerminateJoysticksNS(void)
int _glfwPlatformJoystickPresent(int joy)
{
_GLFWjoydeviceNS* js = _glfw.ns_js.js + joy;
_GLFWjoystickNS* js = _glfw.ns_js + joy;
return js->present;
}
const float* _glfwPlatformGetJoystickAxes(int joy, int* count)
{
_GLFWjoydeviceNS* js = _glfw.ns_js.js + joy;
_GLFWjoystickNS* js = _glfw.ns_js + joy;
if (!pollJoystickAxisEvents(js))
return NULL;
@@ -491,7 +491,7 @@ const float* _glfwPlatformGetJoystickAxes(int joy, int* count)
const unsigned char* _glfwPlatformGetJoystickButtons(int joy, int* count)
{
_GLFWjoydeviceNS* js = _glfw.ns_js.js + joy;
_GLFWjoystickNS* js = _glfw.ns_js + joy;
if (!pollJoystickButtonEvents(js))
return NULL;
@@ -502,7 +502,7 @@ const unsigned char* _glfwPlatformGetJoystickButtons(int joy, int* count)
const char* _glfwPlatformGetJoystickName(int joy)
{
_GLFWjoydeviceNS* js = _glfw.ns_js.js + joy;
_GLFWjoystickNS* js = _glfw.ns_js + joy;
if (!js->present)
return NULL;
+2 -4
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 OS X - www.glfw.org
// GLFW 3.3 OS X - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2016 Camilla Berglund <elmindreda@glfw.org>
@@ -27,11 +27,9 @@
#include "internal.h"
#include <stdlib.h>
#include <stdlib.h>
#include <limits.h>
#include <IOKit/graphics/IOGraphicsLib.h>
#include <IOKit/graphics/IOGraphicsLib.h>
#include <CoreVideo/CVBase.h>
#include <CoreVideo/CVDisplayLink.h>
@@ -66,7 +64,7 @@ static char* getDisplayName(CGDirectDisplayID displayID)
size = CFStringGetMaximumSizeForEncoding(CFStringGetLength(value),
kCFStringEncodingUTF8);
name = calloc(size + 1, sizeof(char));
name = calloc(size + 1, 1);
CFStringGetCString(value, name, size, kCFStringEncodingUTF8);
CFRelease(info);
+2 -5
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 OS X - www.glfw.org
// GLFW 3.3 OS X - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2009-2016 Camilla Berglund <elmindreda@glfw.org>
//
@@ -82,7 +82,6 @@ typedef struct _GLFWwindowNS
} _GLFWwindowNS;
// Cocoa-specific global data
//
typedef struct _GLFWlibraryNS
@@ -92,6 +91,7 @@ typedef struct _GLFWlibraryNS
id autoreleasePool;
id cursor;
TISInputSourceRef inputSource;
IOHIDManagerRef hidManager;
id unicodeData;
id listener;
@@ -115,7 +115,6 @@ typedef struct _GLFWlibraryNS
} _GLFWlibraryNS;
// Cocoa-specific per-monitor data
//
typedef struct _GLFWmonitorNS
@@ -126,7 +125,6 @@ typedef struct _GLFWmonitorNS
} _GLFWmonitorNS;
// Cocoa-specific per-cursor data
//
typedef struct _GLFWcursorNS
@@ -135,7 +133,6 @@ typedef struct _GLFWcursorNS
} _GLFWcursorNS;
// Cocoa-specific global timer data
//
typedef struct _GLFWtimeNS
+1 -1
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 OS X - www.glfw.org
// GLFW 3.3 OS X - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2009-2016 Camilla Berglund <elmindreda@glfw.org>
//
+8 -6
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 OS X - www.glfw.org
// GLFW 3.3 OS X - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2009-2016 Camilla Berglund <elmindreda@glfw.org>
//
@@ -944,8 +944,8 @@ static GLFWbool initializeAppKit(void)
// Create the Cocoa window
//
static GLFWbool createWindow(_GLFWwindow* window,
const _GLFWwndconfig* wndconfig)
static GLFWbool createNativeWindow(_GLFWwindow* window,
const _GLFWwndconfig* wndconfig)
{
window->ns.delegate = [[GLFWWindowDelegate alloc] initWithGlfwWindow:window];
if (window->ns.delegate == nil)
@@ -1027,13 +1027,15 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
if (!initializeAppKit())
return GLFW_FALSE;
if (!createWindow(window, wndconfig))
if (!createNativeWindow(window, wndconfig))
return GLFW_FALSE;
if (ctxconfig->client != GLFW_NO_API)
{
if (ctxconfig->source == GLFW_NATIVE_CONTEXT_API)
{
if (!_glfwInitNSGL())
return GLFW_FALSE;
if (!_glfwCreateContextNSGL(window, ctxconfig, fbconfig))
return GLFW_FALSE;
}
@@ -1067,7 +1069,7 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
if (window->monitor)
releaseMonitor(window);
if (window->context.client != GLFW_NO_API)
if (window->context.destroy)
window->context.destroy(window);
[window->ns.object setDelegate:nil];
@@ -1538,7 +1540,7 @@ int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
memcpy([rep bitmapData], image->pixels, image->width * image->height * 4);
native = [[NSImage alloc] initWithSize:NSMakeSize(image->width, image->height)];
[native addRepresentation: rep];
[native addRepresentation:rep];
cursor->ns.object = [[NSCursor alloc] initWithImage:native
hotSpot:NSMakePoint(xhot, yhot)];
+79 -65
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 - www.glfw.org
// GLFW 3.3 - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2016 Camilla Berglund <elmindreda@glfw.org>
@@ -34,56 +34,6 @@
#include <stdio.h>
// Parses the client API version string and extracts the version number
//
static GLFWbool parseVersionString(int* api, int* major, int* minor, int* rev)
{
int i;
_GLFWwindow* window;
const char* version;
const char* prefixes[] =
{
"OpenGL ES-CM ",
"OpenGL ES-CL ",
"OpenGL ES ",
NULL
};
*api = GLFW_OPENGL_API;
window = _glfwPlatformGetCurrentContext();
version = (const char*) window->context.GetString(GL_VERSION);
if (!version)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Client API version string retrieval is broken");
return GLFW_FALSE;
}
for (i = 0; prefixes[i]; i++)
{
const size_t length = strlen(prefixes[i]);
if (strncmp(version, prefixes[i], length) == 0)
{
version += length;
*api = GLFW_OPENGL_ES_API;
break;
}
}
if (!sscanf(version, "%d.%d.%d", major, minor, rev))
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"No version found in client API version string");
return GLFW_FALSE;
}
return GLFW_TRUE;
}
//////////////////////////////////////////////////////////////////////////
////// GLFW internal API //////
//////////////////////////////////////////////////////////////////////////
@@ -369,27 +319,79 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
GLFWbool _glfwRefreshContextAttribs(const _GLFWctxconfig* ctxconfig)
{
_GLFWwindow* window = _glfwPlatformGetCurrentContext();
int i;
_GLFWwindow* window;
const char* version;
const char* prefixes[] =
{
"OpenGL ES-CM ",
"OpenGL ES-CL ",
"OpenGL ES ",
NULL
};
window = _glfwPlatformGetCurrentContext();
window->context.source = ctxconfig->source;
window->context.client = GLFW_OPENGL_API;
window->context.GetIntegerv = (PFNGLGETINTEGERVPROC)
glfwGetProcAddress("glGetIntegerv");
window->context.getProcAddress("glGetIntegerv");
window->context.GetString = (PFNGLGETSTRINGPROC)
glfwGetProcAddress("glGetString");
window->context.getProcAddress("glGetString");
if (!window->context.GetIntegerv || !window->context.GetString)
{
_glfwInputError(GLFW_PLATFORM_ERROR, "Entry point retrieval is broken");
return GLFW_FALSE;
}
if (!parseVersionString(&window->context.client,
&window->context.major,
&window->context.minor,
&window->context.revision))
version = (const char*) window->context.GetString(GL_VERSION);
if (!version)
{
if (ctxconfig->client == GLFW_OPENGL_API)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"OpenGL version string retrieval is broken");
}
else
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"OpenGL ES version string retrieval is broken");
}
return GLFW_FALSE;
}
window->context.source = ctxconfig->source;
for (i = 0; prefixes[i]; i++)
{
const size_t length = strlen(prefixes[i]);
if (strncmp(version, prefixes[i], length) == 0)
{
version += length;
window->context.client = GLFW_OPENGL_ES_API;
break;
}
}
if (!sscanf(version, "%d.%d.%d",
&window->context.major,
&window->context.minor,
&window->context.revision))
{
if (window->context.client == GLFW_OPENGL_API)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"No version found in OpenGL version string");
}
else
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"No version found in OpenGL ES version string");
}
return GLFW_FALSE;
}
if (window->context.major < ctxconfig->major ||
(window->context.major == ctxconfig->major &&
@@ -402,10 +404,21 @@ GLFWbool _glfwRefreshContextAttribs(const _GLFWctxconfig* ctxconfig)
// For API consistency, we emulate the behavior of the
// {GLX|WGL}_ARB_create_context extension and fail here
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"Requested client API version %i.%i, got version %i.%i",
ctxconfig->major, ctxconfig->minor,
window->context.major, window->context.minor);
if (window->context.client == GLFW_OPENGL_API)
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"Requested OpenGL version %i.%i, got version %i.%i",
ctxconfig->major, ctxconfig->minor,
window->context.major, window->context.minor);
}
else
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"Requested OpenGL ES version %i.%i, got version %i.%i",
ctxconfig->major, ctxconfig->minor,
window->context.major, window->context.minor);
}
return GLFW_FALSE;
}
@@ -416,7 +429,7 @@ GLFWbool _glfwRefreshContextAttribs(const _GLFWctxconfig* ctxconfig)
// users as early as possible that their build may be broken
window->context.GetStringi = (PFNGLGETSTRINGIPROC)
glfwGetProcAddress("glGetStringi");
window->context.getProcAddress("glGetStringi");
if (!window->context.GetStringi)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
@@ -521,7 +534,8 @@ GLFWbool _glfwRefreshContextAttribs(const _GLFWctxconfig* ctxconfig)
// Clearing the front buffer to black to avoid garbage pixels left over from
// previous uses of our bit of VRAM
{
PFNGLCLEARPROC glClear = (PFNGLCLEARPROC) glfwGetProcAddress("glClear");
PFNGLCLEARPROC glClear = (PFNGLCLEARPROC)
window->context.getProcAddress("glClear");
glClear(GL_COLOR_BUFFER_BIT);
window->context.swapBuffers(window);
}
+81 -43
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 EGL - www.glfw.org
// GLFW 3.3 EGL - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2016 Camilla Berglund <elmindreda@glfw.org>
@@ -28,13 +28,14 @@
#include "internal.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
// Return a description of the specified EGL error
//
static const char* getErrorString(EGLint error)
static const char* getEGLErrorString(EGLint error)
{
switch (error)
{
@@ -75,16 +76,16 @@ static const char* getErrorString(EGLint error)
// Returns the specified attribute of the specified EGLConfig
//
static int getConfigAttrib(EGLConfig config, int attrib)
static int getEGLConfigAttrib(EGLConfig config, int attrib)
{
int value;
eglGetConfigAttrib(_glfw.egl.display, config, attrib, &value);
return value;
}
// Return a list of available and usable framebuffer configs
// Return the EGLConfig most closely matching the specified hints
//
static GLFWbool chooseFBConfigs(const _GLFWctxconfig* ctxconfig,
static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* desired,
EGLConfig* result)
{
@@ -112,16 +113,16 @@ static GLFWbool chooseFBConfigs(const _GLFWctxconfig* ctxconfig,
_GLFWfbconfig* u = usableConfigs + usableCount;
// Only consider RGB(A) EGLConfigs
if (!(getConfigAttrib(n, EGL_COLOR_BUFFER_TYPE) & EGL_RGB_BUFFER))
if (!(getEGLConfigAttrib(n, EGL_COLOR_BUFFER_TYPE) & EGL_RGB_BUFFER))
continue;
// Only consider window EGLConfigs
if (!(getConfigAttrib(n, EGL_SURFACE_TYPE) & EGL_WINDOW_BIT))
if (!(getEGLConfigAttrib(n, EGL_SURFACE_TYPE) & EGL_WINDOW_BIT))
continue;
#if defined(_GLFW_X11)
// Only consider EGLConfigs with associated Visuals
if (!getConfigAttrib(n, EGL_NATIVE_VISUAL_ID))
if (!getEGLConfigAttrib(n, EGL_NATIVE_VISUAL_ID))
continue;
#endif // _GLFW_X11
@@ -129,30 +130,30 @@ static GLFWbool chooseFBConfigs(const _GLFWctxconfig* ctxconfig,
{
if (ctxconfig->major == 1)
{
if (!(getConfigAttrib(n, EGL_RENDERABLE_TYPE) & EGL_OPENGL_ES_BIT))
if (!(getEGLConfigAttrib(n, EGL_RENDERABLE_TYPE) & EGL_OPENGL_ES_BIT))
continue;
}
else
{
if (!(getConfigAttrib(n, EGL_RENDERABLE_TYPE) & EGL_OPENGL_ES2_BIT))
if (!(getEGLConfigAttrib(n, EGL_RENDERABLE_TYPE) & EGL_OPENGL_ES2_BIT))
continue;
}
}
else if (ctxconfig->client == GLFW_OPENGL_API)
{
if (!(getConfigAttrib(n, EGL_RENDERABLE_TYPE) & EGL_OPENGL_BIT))
if (!(getEGLConfigAttrib(n, EGL_RENDERABLE_TYPE) & EGL_OPENGL_BIT))
continue;
}
u->redBits = getConfigAttrib(n, EGL_RED_SIZE);
u->greenBits = getConfigAttrib(n, EGL_GREEN_SIZE);
u->blueBits = getConfigAttrib(n, EGL_BLUE_SIZE);
u->redBits = getEGLConfigAttrib(n, EGL_RED_SIZE);
u->greenBits = getEGLConfigAttrib(n, EGL_GREEN_SIZE);
u->blueBits = getEGLConfigAttrib(n, EGL_BLUE_SIZE);
u->alphaBits = getConfigAttrib(n, EGL_ALPHA_SIZE);
u->depthBits = getConfigAttrib(n, EGL_DEPTH_SIZE);
u->stencilBits = getConfigAttrib(n, EGL_STENCIL_SIZE);
u->alphaBits = getEGLConfigAttrib(n, EGL_ALPHA_SIZE);
u->depthBits = getEGLConfigAttrib(n, EGL_DEPTH_SIZE);
u->stencilBits = getEGLConfigAttrib(n, EGL_STENCIL_SIZE);
u->samples = getConfigAttrib(n, EGL_SAMPLES);
u->samples = getEGLConfigAttrib(n, EGL_SAMPLES);
u->doublebuffer = GLFW_TRUE;
u->handle = (uintptr_t) n;
@@ -169,7 +170,7 @@ static GLFWbool chooseFBConfigs(const _GLFWctxconfig* ctxconfig,
return closest != NULL;
}
static void makeContextCurrent(_GLFWwindow* window)
static void makeContextCurrentEGL(_GLFWwindow* window)
{
if (window)
{
@@ -180,7 +181,7 @@ static void makeContextCurrent(_GLFWwindow* window)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"EGL: Failed to make context current: %s",
getErrorString(eglGetError()));
getEGLErrorString(eglGetError()));
return;
}
}
@@ -193,7 +194,7 @@ static void makeContextCurrent(_GLFWwindow* window)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"EGL: Failed to clear current context: %s",
getErrorString(eglGetError()));
getEGLErrorString(eglGetError()));
return;
}
}
@@ -201,7 +202,7 @@ static void makeContextCurrent(_GLFWwindow* window)
_glfwPlatformSetCurrentContext(window);
}
static void swapBuffers(_GLFWwindow* window)
static void swapBuffersEGL(_GLFWwindow* window)
{
if (window != _glfwPlatformGetCurrentContext())
{
@@ -213,12 +214,12 @@ static void swapBuffers(_GLFWwindow* window)
eglSwapBuffers(_glfw.egl.display, window->context.egl.surface);
}
static void swapInterval(int interval)
static void swapIntervalEGL(int interval)
{
eglSwapInterval(_glfw.egl.display, interval);
}
static int extensionSupported(const char* extension)
static int extensionSupportedEGL(const char* extension)
{
const char* extensions = eglQueryString(_glfw.egl.display, EGL_EXTENSIONS);
if (extensions)
@@ -230,7 +231,7 @@ static int extensionSupported(const char* extension)
return GLFW_FALSE;
}
static GLFWglproc getProcAddress(const char* procname)
static GLFWglproc getProcAddressEGL(const char* procname)
{
_GLFWwindow* window = _glfwPlatformGetCurrentContext();
@@ -245,7 +246,7 @@ static GLFWglproc getProcAddress(const char* procname)
return eglGetProcAddress(procname);
}
static void destroyContext(_GLFWwindow* window)
static void destroyContextEGL(_GLFWwindow* window)
{
#if defined(_GLFW_X11)
// NOTE: Do not unload libGL.so.1 while the X11 display is still open,
@@ -296,6 +297,9 @@ GLFWbool _glfwInitEGL(void)
NULL
};
if (_glfw.egl.handle)
return GLFW_TRUE;
for (i = 0; sonames[i]; i++)
{
_glfw.egl.handle = _glfw_dlopen(sonames[i]);
@@ -304,7 +308,12 @@ GLFWbool _glfwInitEGL(void)
}
if (!_glfw.egl.handle)
{
_glfwInputError(GLFW_API_UNAVAILABLE, "EGL: Library not found");
return GLFW_FALSE;
}
_glfw.egl.prefix = (strncmp(sonames[i], "lib", 3) == 0);
_glfw.egl.GetConfigAttrib = (PFNEGLGETCONFIGATTRIBPROC)
_glfw_dlsym(_glfw.egl.handle, "eglGetConfigAttrib");
@@ -339,12 +348,36 @@ GLFWbool _glfwInitEGL(void)
_glfw.egl.GetProcAddress = (PFNEGLGETPROCADDRESSPROC)
_glfw_dlsym(_glfw.egl.handle, "eglGetProcAddress");
if (!_glfw.egl.GetConfigAttrib ||
!_glfw.egl.GetConfigs ||
!_glfw.egl.GetDisplay ||
!_glfw.egl.GetError ||
!_glfw.egl.Initialize ||
!_glfw.egl.Terminate ||
!_glfw.egl.BindAPI ||
!_glfw.egl.CreateContext ||
!_glfw.egl.DestroySurface ||
!_glfw.egl.DestroyContext ||
!_glfw.egl.CreateWindowSurface ||
!_glfw.egl.MakeCurrent ||
!_glfw.egl.SwapBuffers ||
!_glfw.egl.SwapInterval ||
!_glfw.egl.QueryString ||
!_glfw.egl.GetProcAddress)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"EGL: Failed to load required entry points");
_glfwTerminateEGL();
return GLFW_FALSE;
}
_glfw.egl.display = eglGetDisplay(_GLFW_EGL_NATIVE_DISPLAY);
if (_glfw.egl.display == EGL_NO_DISPLAY)
{
_glfwInputError(GLFW_API_UNAVAILABLE,
"EGL: Failed to get EGL display: %s",
getErrorString(eglGetError()));
getEGLErrorString(eglGetError()));
_glfwTerminateEGL();
return GLFW_FALSE;
@@ -354,18 +387,18 @@ GLFWbool _glfwInitEGL(void)
{
_glfwInputError(GLFW_API_UNAVAILABLE,
"EGL: Failed to initialize EGL: %s",
getErrorString(eglGetError()));
getEGLErrorString(eglGetError()));
_glfwTerminateEGL();
return GLFW_FALSE;
}
_glfw.egl.KHR_create_context =
extensionSupported("EGL_KHR_create_context");
extensionSupportedEGL("EGL_KHR_create_context");
_glfw.egl.KHR_create_context_no_error =
extensionSupported("EGL_KHR_create_context_no_error");
extensionSupportedEGL("EGL_KHR_create_context_no_error");
_glfw.egl.KHR_gl_colorspace =
extensionSupported("EGL_KHR_gl_colorspace");
extensionSupportedEGL("EGL_KHR_gl_colorspace");
return GLFW_TRUE;
}
@@ -413,7 +446,7 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
if (ctxconfig->share)
share = ctxconfig->share->context.egl.handle;
if (!chooseFBConfigs(ctxconfig, fbconfig, &config))
if (!chooseEGLConfig(ctxconfig, fbconfig, &config))
{
_glfwInputError(GLFW_FORMAT_UNAVAILABLE,
"EGL: Failed to find a suitable EGLConfig");
@@ -426,7 +459,7 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
{
_glfwInputError(GLFW_API_UNAVAILABLE,
"EGL: Failed to bind OpenGL ES: %s",
getErrorString(eglGetError()));
getEGLErrorString(eglGetError()));
return GLFW_FALSE;
}
}
@@ -436,7 +469,7 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
{
_glfwInputError(GLFW_API_UNAVAILABLE,
"EGL: Failed to bind OpenGL: %s",
getErrorString(eglGetError()));
getEGLErrorString(eglGetError()));
return GLFW_FALSE;
}
}
@@ -515,7 +548,7 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"EGL: Failed to create context: %s",
getErrorString(eglGetError()));
getEGLErrorString(eglGetError()));
return GLFW_FALSE;
}
@@ -543,7 +576,7 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"EGL: Failed to create window surface: %s",
getErrorString(eglGetError()));
getEGLErrorString(eglGetError()));
return GLFW_FALSE;
}
@@ -600,6 +633,11 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
for (i = 0; sonames[i]; i++)
{
// HACK: Match presence of lib prefix to increase chance of finding
// a matching pair in the jungle that is Win32 EGL/GLES
if (_glfw.egl.prefix != (strncmp(sonames[i], "lib", 3) == 0))
continue;
window->context.egl.client = _glfw_dlopen(sonames[i]);
if (window->context.egl.client)
break;
@@ -613,12 +651,12 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
}
}
window->context.makeCurrent = makeContextCurrent;
window->context.swapBuffers = swapBuffers;
window->context.swapInterval = swapInterval;
window->context.extensionSupported = extensionSupported;
window->context.getProcAddress = getProcAddress;
window->context.destroy = destroyContext;
window->context.makeCurrent = makeContextCurrentEGL;
window->context.swapBuffers = swapBuffersEGL;
window->context.swapInterval = swapIntervalEGL;
window->context.extensionSupported = extensionSupportedEGL;
window->context.getProcAddress = getProcAddressEGL;
window->context.destroy = destroyContextEGL;
return GLFW_TRUE;
}
@@ -638,7 +676,7 @@ GLFWbool _glfwChooseVisualEGL(const _GLFWctxconfig* ctxconfig,
EGLint visualID = 0, count = 0;
const long vimask = VisualScreenMask | VisualIDMask;
if (!chooseFBConfigs(ctxconfig, fbconfig, &native))
if (!chooseEGLConfig(ctxconfig, fbconfig, &native))
{
_glfwInputError(GLFW_FORMAT_UNAVAILABLE,
"EGL: Failed to find a suitable EGLConfig");
+2 -2
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 EGL - www.glfw.org
// GLFW 3.3 EGL - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2016 Camilla Berglund <elmindreda@glfw.org>
@@ -165,13 +165,13 @@ typedef struct _GLFWcontextEGL
} _GLFWcontextEGL;
// EGL-specific global data
//
typedef struct _GLFWlibraryEGL
{
EGLDisplay display;
EGLint major, minor;
GLFWbool prefix;
GLFWbool KHR_create_context;
GLFWbool KHR_create_context_no_error;
+3 -1
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 - www.glfw.org
// GLFW 3.3 - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2010-2016 Camilla Berglund <elmindreda@glfw.org>
//
@@ -47,6 +47,8 @@
// Define this to 1 if building as a shared library / dynamic library / DLL
#cmakedefine _GLFW_BUILD_DLL
// Define this to 1 to use Vulkan loader linked statically into application
#cmakedefine _GLFW_VULKAN_STATIC
// Define this to 1 to force use of high-performance GPU on hybrid systems
#cmakedefine _GLFW_USE_HYBRID_HPG
+82 -55
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 GLX - www.glfw.org
// GLFW 3.3 GLX - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2016 Camilla Berglund <elmindreda@glfw.org>
@@ -38,16 +38,16 @@
// Returns the specified attribute of the specified GLXFBConfig
//
static int getFBConfigAttrib(GLXFBConfig fbconfig, int attrib)
static int getGLXFBConfigAttrib(GLXFBConfig fbconfig, int attrib)
{
int value;
glXGetFBConfigAttrib(_glfw.x11.display, fbconfig, attrib, &value);
return value;
}
// Return a list of available and usable framebuffer configs
// Return the GLXFBConfig most closely matching the specified hints
//
static GLFWbool chooseFBConfig(const _GLFWfbconfig* desired, GLXFBConfig* result)
static GLFWbool chooseGLXFBConfig(const _GLFWfbconfig* desired, GLXFBConfig* result)
{
GLXFBConfig* nativeConfigs;
_GLFWfbconfig* usableConfigs;
@@ -79,41 +79,41 @@ static GLFWbool chooseFBConfig(const _GLFWfbconfig* desired, GLXFBConfig* result
_GLFWfbconfig* u = usableConfigs + usableCount;
// Only consider RGBA GLXFBConfigs
if (!(getFBConfigAttrib(n, GLX_RENDER_TYPE) & GLX_RGBA_BIT))
if (!(getGLXFBConfigAttrib(n, GLX_RENDER_TYPE) & GLX_RGBA_BIT))
continue;
// Only consider window GLXFBConfigs
if (!(getFBConfigAttrib(n, GLX_DRAWABLE_TYPE) & GLX_WINDOW_BIT))
if (!(getGLXFBConfigAttrib(n, GLX_DRAWABLE_TYPE) & GLX_WINDOW_BIT))
{
if (trustWindowBit)
continue;
}
u->redBits = getFBConfigAttrib(n, GLX_RED_SIZE);
u->greenBits = getFBConfigAttrib(n, GLX_GREEN_SIZE);
u->blueBits = getFBConfigAttrib(n, GLX_BLUE_SIZE);
u->redBits = getGLXFBConfigAttrib(n, GLX_RED_SIZE);
u->greenBits = getGLXFBConfigAttrib(n, GLX_GREEN_SIZE);
u->blueBits = getGLXFBConfigAttrib(n, GLX_BLUE_SIZE);
u->alphaBits = getFBConfigAttrib(n, GLX_ALPHA_SIZE);
u->depthBits = getFBConfigAttrib(n, GLX_DEPTH_SIZE);
u->stencilBits = getFBConfigAttrib(n, GLX_STENCIL_SIZE);
u->alphaBits = getGLXFBConfigAttrib(n, GLX_ALPHA_SIZE);
u->depthBits = getGLXFBConfigAttrib(n, GLX_DEPTH_SIZE);
u->stencilBits = getGLXFBConfigAttrib(n, GLX_STENCIL_SIZE);
u->accumRedBits = getFBConfigAttrib(n, GLX_ACCUM_RED_SIZE);
u->accumGreenBits = getFBConfigAttrib(n, GLX_ACCUM_GREEN_SIZE);
u->accumBlueBits = getFBConfigAttrib(n, GLX_ACCUM_BLUE_SIZE);
u->accumAlphaBits = getFBConfigAttrib(n, GLX_ACCUM_ALPHA_SIZE);
u->accumRedBits = getGLXFBConfigAttrib(n, GLX_ACCUM_RED_SIZE);
u->accumGreenBits = getGLXFBConfigAttrib(n, GLX_ACCUM_GREEN_SIZE);
u->accumBlueBits = getGLXFBConfigAttrib(n, GLX_ACCUM_BLUE_SIZE);
u->accumAlphaBits = getGLXFBConfigAttrib(n, GLX_ACCUM_ALPHA_SIZE);
u->auxBuffers = getFBConfigAttrib(n, GLX_AUX_BUFFERS);
u->auxBuffers = getGLXFBConfigAttrib(n, GLX_AUX_BUFFERS);
if (getFBConfigAttrib(n, GLX_STEREO))
if (getGLXFBConfigAttrib(n, GLX_STEREO))
u->stereo = GLFW_TRUE;
if (getFBConfigAttrib(n, GLX_DOUBLEBUFFER))
if (getGLXFBConfigAttrib(n, GLX_DOUBLEBUFFER))
u->doublebuffer = GLFW_TRUE;
if (_glfw.glx.ARB_multisample)
u->samples = getFBConfigAttrib(n, GLX_SAMPLES);
u->samples = getGLXFBConfigAttrib(n, GLX_SAMPLES);
if (_glfw.glx.ARB_framebuffer_sRGB || _glfw.glx.EXT_framebuffer_sRGB)
u->sRGB = getFBConfigAttrib(n, GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB);
u->sRGB = getGLXFBConfigAttrib(n, GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB);
u->handle = (uintptr_t) n;
usableCount++;
@@ -131,9 +131,9 @@ static GLFWbool chooseFBConfig(const _GLFWfbconfig* desired, GLXFBConfig* result
// Create the OpenGL context using legacy API
//
static GLXContext createLegacyContext(_GLFWwindow* window,
GLXFBConfig fbconfig,
GLXContext share)
static GLXContext createLegacyContextGLX(_GLFWwindow* window,
GLXFBConfig fbconfig,
GLXContext share)
{
return glXCreateNewContext(_glfw.x11.display,
fbconfig,
@@ -142,7 +142,7 @@ static GLXContext createLegacyContext(_GLFWwindow* window,
True);
}
static void makeContextCurrent(_GLFWwindow* window)
static void makeContextCurrentGLX(_GLFWwindow* window)
{
if (window)
{
@@ -168,12 +168,12 @@ static void makeContextCurrent(_GLFWwindow* window)
_glfwPlatformSetCurrentContext(window);
}
static void swapBuffers(_GLFWwindow* window)
static void swapBuffersGLX(_GLFWwindow* window)
{
glXSwapBuffers(_glfw.x11.display, window->context.glx.window);
}
static void swapInterval(int interval)
static void swapIntervalGLX(int interval)
{
_GLFWwindow* window = _glfwPlatformGetCurrentContext();
@@ -192,7 +192,7 @@ static void swapInterval(int interval)
}
}
static int extensionSupported(const char* extension)
static int extensionSupportedGLX(const char* extension)
{
const char* extensions =
glXQueryExtensionsString(_glfw.x11.display, _glfw.x11.screen);
@@ -205,7 +205,7 @@ static int extensionSupported(const char* extension)
return GLFW_FALSE;
}
static GLFWglproc getProcAddress(const char* procname)
static GLFWglproc getProcAddressGLX(const char* procname)
{
if (_glfw.glx.GetProcAddress)
return _glfw.glx.GetProcAddress((const GLubyte*) procname);
@@ -217,7 +217,7 @@ static GLFWglproc getProcAddress(const char* procname)
// Destroy the OpenGL context
//
static void destroyContext(_GLFWwindow* window)
static void destroyContextGLX(_GLFWwindow* window)
{
if (window->context.glx.window)
{
@@ -253,6 +253,9 @@ GLFWbool _glfwInitGLX(void)
NULL
};
if (_glfw.glx.handle)
return GLFW_TRUE;
for (i = 0; sonames[i]; i++)
{
_glfw.glx.handle = dlopen(sonames[i], RTLD_LAZY | RTLD_GLOBAL);
@@ -297,6 +300,27 @@ GLFWbool _glfwInitGLX(void)
_glfw.glx.GetVisualFromFBConfig =
dlsym(_glfw.glx.handle, "glXGetVisualFromFBConfig");
if (!_glfw.glx.GetFBConfigs ||
!_glfw.glx.GetFBConfigAttrib ||
!_glfw.glx.GetClientString ||
!_glfw.glx.QueryExtension ||
!_glfw.glx.QueryVersion ||
!_glfw.glx.DestroyContext ||
!_glfw.glx.MakeCurrent ||
!_glfw.glx.SwapBuffers ||
!_glfw.glx.QueryExtensionsString ||
!_glfw.glx.CreateNewContext ||
!_glfw.glx.CreateWindow ||
!_glfw.glx.DestroyWindow ||
!_glfw.glx.GetProcAddress ||
!_glfw.glx.GetProcAddressARB ||
!_glfw.glx.GetVisualFromFBConfig)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"GLX: Failed to load required entry points");
return GLFW_FALSE;
}
if (!glXQueryExtension(_glfw.x11.display,
&_glfw.glx.errorBase,
&_glfw.glx.eventBase))
@@ -319,61 +343,61 @@ GLFWbool _glfwInitGLX(void)
return GLFW_FALSE;
}
if (extensionSupported("GLX_EXT_swap_control"))
if (extensionSupportedGLX("GLX_EXT_swap_control"))
{
_glfw.glx.SwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC)
getProcAddress("glXSwapIntervalEXT");
getProcAddressGLX("glXSwapIntervalEXT");
if (_glfw.glx.SwapIntervalEXT)
_glfw.glx.EXT_swap_control = GLFW_TRUE;
}
if (extensionSupported("GLX_SGI_swap_control"))
if (extensionSupportedGLX("GLX_SGI_swap_control"))
{
_glfw.glx.SwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC)
getProcAddress("glXSwapIntervalSGI");
getProcAddressGLX("glXSwapIntervalSGI");
if (_glfw.glx.SwapIntervalSGI)
_glfw.glx.SGI_swap_control = GLFW_TRUE;
}
if (extensionSupported("GLX_MESA_swap_control"))
if (extensionSupportedGLX("GLX_MESA_swap_control"))
{
_glfw.glx.SwapIntervalMESA = (PFNGLXSWAPINTERVALMESAPROC)
getProcAddress("glXSwapIntervalMESA");
getProcAddressGLX("glXSwapIntervalMESA");
if (_glfw.glx.SwapIntervalMESA)
_glfw.glx.MESA_swap_control = GLFW_TRUE;
}
if (extensionSupported("GLX_ARB_multisample"))
if (extensionSupportedGLX("GLX_ARB_multisample"))
_glfw.glx.ARB_multisample = GLFW_TRUE;
if (extensionSupported("GLX_ARB_framebuffer_sRGB"))
if (extensionSupportedGLX("GLX_ARB_framebuffer_sRGB"))
_glfw.glx.ARB_framebuffer_sRGB = GLFW_TRUE;
if (extensionSupported("GLX_EXT_framebuffer_sRGB"))
if (extensionSupportedGLX("GLX_EXT_framebuffer_sRGB"))
_glfw.glx.EXT_framebuffer_sRGB = GLFW_TRUE;
if (extensionSupported("GLX_ARB_create_context"))
if (extensionSupportedGLX("GLX_ARB_create_context"))
{
_glfw.glx.CreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)
getProcAddress("glXCreateContextAttribsARB");
getProcAddressGLX("glXCreateContextAttribsARB");
if (_glfw.glx.CreateContextAttribsARB)
_glfw.glx.ARB_create_context = GLFW_TRUE;
}
if (extensionSupported("GLX_ARB_create_context_robustness"))
if (extensionSupportedGLX("GLX_ARB_create_context_robustness"))
_glfw.glx.ARB_create_context_robustness = GLFW_TRUE;
if (extensionSupported("GLX_ARB_create_context_profile"))
if (extensionSupportedGLX("GLX_ARB_create_context_profile"))
_glfw.glx.ARB_create_context_profile = GLFW_TRUE;
if (extensionSupported("GLX_EXT_create_context_es2_profile"))
if (extensionSupportedGLX("GLX_EXT_create_context_es2_profile"))
_glfw.glx.EXT_create_context_es2_profile = GLFW_TRUE;
if (extensionSupported("GLX_ARB_context_flush_control"))
if (extensionSupportedGLX("GLX_ARB_context_flush_control"))
_glfw.glx.ARB_context_flush_control = GLFW_TRUE;
return GLFW_TRUE;
@@ -413,7 +437,7 @@ GLFWbool _glfwCreateContextGLX(_GLFWwindow* window,
if (ctxconfig->share)
share = ctxconfig->share->context.glx.handle;
if (!chooseFBConfig(fbconfig, &native))
if (!chooseGLXFBConfig(fbconfig, &native))
{
_glfwInputError(GLFW_FORMAT_UNAVAILABLE,
"GLX: Failed to find a suitable GLXFBConfig");
@@ -549,12 +573,15 @@ GLFWbool _glfwCreateContextGLX(_GLFWwindow* window,
ctxconfig->forward == GLFW_FALSE)
{
window->context.glx.handle =
createLegacyContext(window, native, share);
createLegacyContextGLX(window, native, share);
}
}
}
else
window->context.glx.handle = createLegacyContext(window, native, share);
{
window->context.glx.handle =
createLegacyContextGLX(window, native, share);
}
_glfwReleaseErrorHandlerX11();
@@ -572,12 +599,12 @@ GLFWbool _glfwCreateContextGLX(_GLFWwindow* window,
return GLFW_FALSE;
}
window->context.makeCurrent = makeContextCurrent;
window->context.swapBuffers = swapBuffers;
window->context.swapInterval = swapInterval;
window->context.extensionSupported = extensionSupported;
window->context.getProcAddress = getProcAddress;
window->context.destroy = destroyContext;
window->context.makeCurrent = makeContextCurrentGLX;
window->context.swapBuffers = swapBuffersGLX;
window->context.swapInterval = swapIntervalGLX;
window->context.extensionSupported = extensionSupportedGLX;
window->context.getProcAddress = getProcAddressGLX;
window->context.destroy = destroyContextGLX;
return GLFW_TRUE;
}
@@ -593,7 +620,7 @@ GLFWbool _glfwChooseVisualGLX(const _GLFWctxconfig* ctxconfig,
GLXFBConfig native;
XVisualInfo* result;
if (!chooseFBConfig(fbconfig, &native))
if (!chooseGLXFBConfig(fbconfig, &native))
{
_glfwInputError(GLFW_FORMAT_UNAVAILABLE,
"GLX: Failed to find a suitable GLXFBConfig");
+2 -3
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 GLX - www.glfw.org
// GLFW 3.3 GLX - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2016 Camilla Berglund <elmindreda@glfw.org>
@@ -84,7 +84,7 @@ typedef void (*PFNGLXSWAPBUFFERSPROC)(Display*,GLXDrawable);
typedef const char* (*PFNGLXQUERYEXTENSIONSSTRINGPROC)(Display*,int);
typedef GLXFBConfig* (*PFNGLXGETFBCONFIGSPROC)(Display*,int,int*);
typedef GLXContext (*PFNGLXCREATENEWCONTEXTPROC)(Display*,GLXFBConfig,int,GLXContext,Bool);
typedef __GLXextproc (* PFNGLXGETPROCADDRESSPROC) (const GLubyte *procName);
typedef __GLXextproc (* PFNGLXGETPROCADDRESSPROC)(const GLubyte *procName);
typedef int (*PFNGLXSWAPINTERVALMESAPROC)(int);
typedef int (*PFNGLXSWAPINTERVALSGIPROC)(int);
typedef void (*PFNGLXSWAPINTERVALEXTPROC)(Display*,GLXDrawable,int);
@@ -121,7 +121,6 @@ typedef struct _GLFWcontextGLX
} _GLFWcontextGLX;
// GLX-specific global data
//
typedef struct _GLFWlibraryGLX
+3 -5
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 - www.glfw.org
// GLFW 3.3 - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2016 Camilla Berglund <elmindreda@glfw.org>
@@ -65,9 +65,9 @@ static const char* getErrorString(int error)
case GLFW_OUT_OF_MEMORY:
return "Out of memory";
case GLFW_API_UNAVAILABLE:
return "The requested client API is unavailable";
return "The requested API is unavailable";
case GLFW_VERSION_UNAVAILABLE:
return "The requested client API version is unavailable";
return "The requested API version is unavailable";
case GLFW_PLATFORM_ERROR:
return "A platform-specific error occurred";
case GLFW_FORMAT_UNAVAILABLE:
@@ -130,8 +130,6 @@ GLFWAPI int glfwInit(void)
return GLFW_FALSE;
}
_glfwInitVulkan();
_glfw.monitors = _glfwPlatformGetMonitors(&_glfw.monitorCount);
_glfwInitialized = GLFW_TRUE;
+4 -4
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 - www.glfw.org
// GLFW 3.3 - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2016 Camilla Berglund <elmindreda@glfw.org>
@@ -332,11 +332,11 @@ GLFWAPI void glfwSetCursorPos(GLFWwindow* handle, double xpos, double ypos)
_GLFW_REQUIRE_INIT();
if (xpos != xpos || xpos < DBL_MIN || xpos > DBL_MAX ||
ypos != ypos || ypos < DBL_MIN || ypos > DBL_MAX)
if (xpos != xpos || xpos < -DBL_MAX || xpos > DBL_MAX ||
ypos != ypos || ypos < -DBL_MAX || ypos > DBL_MAX)
{
_glfwInputError(GLFW_INVALID_VALUE,
"Invalid cursor position %fx%f",
"Invalid cursor position %f %f",
xpos, ypos);
return;
}
+14 -12
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 - www.glfw.org
// GLFW 3.3 - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2016 Camilla Berglund <elmindreda@glfw.org>
@@ -40,6 +40,7 @@
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
@@ -149,11 +150,16 @@ typedef struct VkExtensionProperties
} 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*);
#define vkEnumerateInstanceExtensionProperties _glfw.vk.EnumerateInstanceExtensionProperties
#define vkGetInstanceProcAddr _glfw.vk.GetInstanceProcAddr
#if defined(_GLFW_VULKAN_STATIC)
PFN_vkVoidFunction vkGetInstanceProcAddr(VkInstance,const char*);
VkResult vkEnumerateInstanceExtensionProperties(const char*,uint32_t*,VkExtensionProperties*);
#else
typedef PFN_vkVoidFunction (APIENTRY * PFN_vkGetInstanceProcAddr)(VkInstance,const char*);
typedef VkResult (APIENTRY * PFN_vkEnumerateInstanceExtensionProperties)(const char*,uint32_t*,VkExtensionProperties*);
#define vkEnumerateInstanceExtensionProperties _glfw.vk.EnumerateInstanceExtensionProperties
#define vkGetInstanceProcAddr _glfw.vk.GetInstanceProcAddr
#endif
#if defined(_GLFW_COCOA)
#include "cocoa_platform.h"
@@ -256,7 +262,6 @@ struct _GLFWwndconfig
GLFWbool maximized;
};
/*! @brief Context configuration.
*
* Parameters relating to the creation of the context but not directly related
@@ -278,7 +283,6 @@ struct _GLFWctxconfig
_GLFWwindow* share;
};
/*! @brief Framebuffer configuration.
*
* This describes buffers and their sizes. It also contains
@@ -307,7 +311,6 @@ struct _GLFWfbconfig
uintptr_t handle;
};
/*! @brief Context structure.
*/
struct _GLFWcontext
@@ -337,7 +340,6 @@ struct _GLFWcontext
_GLFW_EGL_CONTEXT_STATE;
};
/*! @brief Window and context structure.
*/
struct _GLFWwindow
@@ -391,7 +393,6 @@ struct _GLFWwindow
_GLFW_PLATFORM_WINDOW_STATE;
};
/*! @brief Monitor structure.
*/
struct _GLFWmonitor
@@ -415,7 +416,6 @@ struct _GLFWmonitor
_GLFW_PLATFORM_MONITOR_STATE;
};
/*! @brief Cursor structure
*/
struct _GLFWcursor
@@ -451,8 +451,10 @@ struct _GLFWlibrary
void* handle;
char** extensions;
uint32_t extensionCount;
#if !defined(_GLFW_VULKAN_STATIC)
PFN_vkEnumerateInstanceExtensionProperties EnumerateInstanceExtensionProperties;
PFN_vkGetInstanceProcAddr GetInstanceProcAddr;
#endif
GLFWbool KHR_surface;
GLFWbool KHR_win32_surface;
GLFWbool KHR_xlib_surface;
@@ -1040,7 +1042,7 @@ GLFWbool _glfwIsPrintable(int key);
/*! @ingroup utility
*/
void _glfwInitVulkan(void);
GLFWbool _glfwInitVulkan(void);
/*! @ingroup utility
*/
+3 -3
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 Linux - www.glfw.org
// GLFW 3.3 Linux - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2016 Camilla Berglund <elmindreda@glfw.org>
@@ -49,7 +49,7 @@
static GLFWbool openJoystickDevice(const char* path)
{
char axisCount, buttonCount;
char name[256];
char name[256] = "";
int joy, fd, version;
_GLFWjoystickLinux* js;
@@ -153,7 +153,7 @@ static GLFWbool pollJoystickEvents(_GLFWjoystickLinux* js)
return js->present;
}
// Lexically compare joysticks, used by quicksort
// Lexically compare joysticks by name; used by qsort
//
#if defined(__linux__)
static int compareJoysticks(const void* fp, const void* sp)
+1 -2
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 Linux - www.glfw.org
// GLFW 3.3 Linux - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com>
//
@@ -46,7 +46,6 @@ typedef struct _GLFWjoystickLinux
char* path;
} _GLFWjoystickLinux;
// Linux-specific joystick API data
//
typedef struct _GLFWjoylistLinux
+1 -4
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 Mir - www.glfw.org
// GLFW 3.3 Mir - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2014-2015 Brandon Schaefer <brandon.schaefer@canonical.com>
//
@@ -183,9 +183,6 @@ int _glfwPlatformInit(void)
if (!_glfwInitThreadLocalStoragePOSIX())
return GLFW_FALSE;
if (!_glfwInitEGL())
return GLFW_FALSE;
if (!_glfwInitJoysticksLinux())
return GLFW_FALSE;
+1 -1
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 Mir - www.glfw.org
// GLFW 3.3 Mir - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2014-2015 Brandon Schaefer <brandon.schaefer@canonical.com>
//
+1 -4
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 Mir - www.glfw.org
// GLFW 3.3 Mir - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2014-2015 Brandon Schaefer <brandon.schaefer@canonical.com>
//
@@ -87,7 +87,6 @@ typedef struct _GLFWwindowMir
} _GLFWwindowMir;
// Mir-specific per-monitor data
//
typedef struct _GLFWmonitorMir
@@ -99,7 +98,6 @@ typedef struct _GLFWmonitorMir
} _GLFWmonitorMir;
// Mir-specific global data
//
typedef struct _GLFWlibraryMir
@@ -116,7 +114,6 @@ typedef struct _GLFWlibraryMir
} _GLFWlibraryMir;
// Mir-specific per-cursor data
// TODO: Only system cursors are implemented in Mir atm. Need to wait for support.
//
+4 -2
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 Mir - www.glfw.org
// GLFW 3.3 Mir - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2014-2015 Brandon Schaefer <brandon.schaefer@canonical.com>
//
@@ -379,6 +379,8 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
if (ctxconfig->client != GLFW_NO_API)
{
if (!_glfwInitEGL())
return GLFW_FALSE;
if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))
return GLFW_FALSE;
}
@@ -394,7 +396,7 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
window->mir.surface = NULL;
}
if (window->context.client != GLFW_NO_API)
if (window->context.destroy)
window->context.destroy(window);
}
+1 -1
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 - www.glfw.org
// GLFW 3.3 - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2016 Camilla Berglund <elmindreda@glfw.org>
+1 -2
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 OS X - www.glfw.org
// GLFW 3.3 OS X - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2009-2016 Camilla Berglund <elmindreda@glfw.org>
//
@@ -40,7 +40,6 @@ typedef struct _GLFWcontextNSGL
} _GLFWcontextNSGL;
// NSGL-specific global data
//
typedef struct _GLFWlibraryNSGL
+16 -13
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 OS X - www.glfw.org
// GLFW 3.3 OS X - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2009-2016 Camilla Berglund <elmindreda@glfw.org>
//
@@ -27,7 +27,7 @@
#include "internal.h"
static void makeContextCurrent(_GLFWwindow* window)
static void makeContextCurrentNSGL(_GLFWwindow* window)
{
if (window)
[window->context.nsgl.object makeCurrentContext];
@@ -37,13 +37,13 @@ static void makeContextCurrent(_GLFWwindow* window)
_glfwPlatformSetCurrentContext(window);
}
static void swapBuffers(_GLFWwindow* window)
static void swapBuffersNSGL(_GLFWwindow* window)
{
// ARP appears to be unnecessary, but this is future-proof
[window->context.nsgl.object flushBuffer];
}
static void swapInterval(int interval)
static void swapIntervalNSGL(int interval)
{
_GLFWwindow* window = _glfwPlatformGetCurrentContext();
@@ -52,13 +52,13 @@ static void swapInterval(int interval)
forParameter:NSOpenGLCPSwapInterval];
}
static int extensionSupported(const char* extension)
static int extensionSupportedNSGL(const char* extension)
{
// There are no NSGL extensions
return GLFW_FALSE;
}
static GLFWglproc getProcAddress(const char* procname)
static GLFWglproc getProcAddressNSGL(const char* procname)
{
CFStringRef symbolName = CFStringCreateWithCString(kCFAllocatorDefault,
procname,
@@ -74,7 +74,7 @@ static GLFWglproc getProcAddress(const char* procname)
// Destroy the OpenGL context
//
static void destroyContext(_GLFWwindow* window)
static void destroyContextNSGL(_GLFWwindow* window)
{
[window->context.nsgl.pixelFormat release];
window->context.nsgl.pixelFormat = nil;
@@ -92,6 +92,9 @@ static void destroyContext(_GLFWwindow* window)
//
GLFWbool _glfwInitNSGL(void)
{
if (_glfw.nsgl.framework)
return GLFW_TRUE;
_glfw.nsgl.framework =
CFBundleGetBundleWithIdentifier(CFSTR("com.apple.opengl"));
if (_glfw.nsgl.framework == NULL)
@@ -274,12 +277,12 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
[window->context.nsgl.object setView:window->ns.view];
window->context.makeCurrent = makeContextCurrent;
window->context.swapBuffers = swapBuffers;
window->context.swapInterval = swapInterval;
window->context.extensionSupported = extensionSupported;
window->context.getProcAddress = getProcAddress;
window->context.destroy = destroyContext;
window->context.makeCurrent = makeContextCurrentNSGL;
window->context.swapBuffers = swapBuffersNSGL;
window->context.swapInterval = swapIntervalNSGL;
window->context.extensionSupported = extensionSupportedNSGL;
window->context.getProcAddress = getProcAddressNSGL;
window->context.destroy = destroyContextNSGL;
return GLFW_TRUE;
}
+1 -1
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 POSIX - www.glfw.org
// GLFW 3.3 POSIX - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2016 Camilla Berglund <elmindreda@glfw.org>
+1 -1
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 POSIX - www.glfw.org
// GLFW 3.3 POSIX - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2016 Camilla Berglund <elmindreda@glfw.org>
+1 -1
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 POSIX - www.glfw.org
// GLFW 3.3 POSIX - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2016 Camilla Berglund <elmindreda@glfw.org>
+1 -1
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 POSIX - www.glfw.org
// GLFW 3.3 POSIX - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2016 Camilla Berglund <elmindreda@glfw.org>
+36 -21
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 - www.glfw.org
// GLFW 3.3 - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2016 Camilla Berglund <elmindreda@glfw.org>
@@ -36,20 +36,25 @@
////// GLFW internal API //////
//////////////////////////////////////////////////////////////////////////
void _glfwInitVulkan(void)
GLFWbool _glfwInitVulkan(void)
{
VkResult err;
VkExtensionProperties* ep;
uint32_t i, count;
#if !defined(_GLFW_VULKAN_STATIC)
#if defined(_GLFW_WIN32)
const char* name = "vulkan-1.dll";
#else
const char* name = "libvulkan.so.1";
#endif
if (_glfw.vk.available)
return GLFW_TRUE;
_glfw.vk.handle = _glfw_dlopen(name);
if (!_glfw.vk.handle)
return;
return GLFW_FALSE;
_glfw.vk.GetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)
_glfw_dlsym(_glfw.vk.handle, "vkGetInstanceProcAddr");
@@ -57,7 +62,9 @@ void _glfwInitVulkan(void)
{
_glfwInputError(GLFW_API_UNAVAILABLE,
"Vulkan: Loader does not export vkGetInstanceProcAddr");
return;
_glfwTerminateVulkan();
return GLFW_FALSE;
}
_glfw.vk.EnumerateInstanceExtensionProperties = (PFN_vkEnumerateInstanceExtensionProperties)
@@ -66,8 +73,11 @@ void _glfwInitVulkan(void)
{
_glfwInputError(GLFW_API_UNAVAILABLE,
"Vulkan: Failed to retrieve vkEnumerateInstanceExtensionProperties");
return;
_glfwTerminateVulkan();
return GLFW_FALSE;
}
#endif // _GLFW_VULKAN_STATIC
err = vkEnumerateInstanceExtensionProperties(NULL, &count, NULL);
if (err)
@@ -75,7 +85,9 @@ void _glfwInitVulkan(void)
_glfwInputError(GLFW_PLATFORM_ERROR,
"Vulkan: Failed to query instance extension count: %s",
_glfwGetVulkanResultString(err));
return;
_glfwTerminateVulkan();
return GLFW_FALSE;
}
ep = calloc(count, sizeof(VkExtensionProperties));
@@ -88,7 +100,8 @@ void _glfwInitVulkan(void)
_glfwGetVulkanResultString(err));
free(ep);
return;
_glfwTerminateVulkan();
return GLFW_FALSE;
}
for (i = 0; i < count; i++)
@@ -111,11 +124,13 @@ void _glfwInitVulkan(void)
_glfw.vk.available = GLFW_TRUE;
if (!_glfw.vk.KHR_surface)
return;
if (_glfw.vk.KHR_surface)
{
_glfw.vk.extensions =
_glfwPlatformGetRequiredInstanceExtensions(&_glfw.vk.extensionCount);
}
_glfw.vk.extensions =
_glfwPlatformGetRequiredInstanceExtensions(&_glfw.vk.extensionCount);
return GLFW_TRUE;
}
void _glfwTerminateVulkan(void)
@@ -193,7 +208,7 @@ const char* _glfwGetVulkanResultString(VkResult result)
GLFWAPI int glfwVulkanSupported(void)
{
_GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
return _glfw.vk.available;
return _glfwInitVulkan();
}
GLFWAPI const char** glfwGetRequiredInstanceExtensions(uint32_t* count)
@@ -202,9 +217,9 @@ GLFWAPI const char** glfwGetRequiredInstanceExtensions(uint32_t* count)
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
if (!_glfw.vk.available)
if (!_glfwInitVulkan())
{
_glfwInputError(GLFW_API_UNAVAILABLE, "Vulkan: Loader not found");
_glfwInputError(GLFW_API_UNAVAILABLE, "Vulkan: API not available");
return NULL;
}
@@ -219,9 +234,9 @@ GLFWAPI GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance,
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
if (!_glfw.vk.available)
if (!_glfwInitVulkan())
{
_glfwInputError(GLFW_API_UNAVAILABLE, "Vulkan: Loader not found");
_glfwInputError(GLFW_API_UNAVAILABLE, "Vulkan: API not available");
return NULL;
}
@@ -238,9 +253,9 @@ GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance,
{
_GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
if (!_glfw.vk.available)
if (!_glfwInitVulkan())
{
_glfwInputError(GLFW_API_UNAVAILABLE, "Vulkan: Loader not found");
_glfwInputError(GLFW_API_UNAVAILABLE, "Vulkan: API not available");
return GLFW_FALSE;
}
@@ -263,15 +278,15 @@ GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance,
{
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
assert(surface != NULL);
*surface = VK_NULL_HANDLE;
_GLFW_REQUIRE_INIT_OR_RETURN(VK_ERROR_INITIALIZATION_FAILED);
if (!_glfw.vk.available)
if (!_glfwInitVulkan())
{
_glfwInputError(GLFW_API_UNAVAILABLE, "Vulkan: Loader not found");
_glfwInputError(GLFW_API_UNAVAILABLE, "Vulkan: API not available");
return VK_ERROR_INITIALIZATION_FAILED;
}
+163 -150
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 WGL - www.glfw.org
// GLFW 3.3 WGL - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2016 Camilla Berglund <elmindreda@glfw.org>
@@ -55,19 +55,17 @@ static int getPixelFormatAttrib(_GLFWwindow* window, int pixelFormat, int attrib
// Return a list of available and usable framebuffer configs
//
static GLFWbool choosePixelFormat(_GLFWwindow* window,
const _GLFWfbconfig* desired,
int* result)
static int choosePixelFormat(_GLFWwindow* window, const _GLFWfbconfig* desired)
{
_GLFWfbconfig* usableConfigs;
const _GLFWfbconfig* closest;
int i, nativeCount, usableCount;
int i, pixelFormat, nativeCount, usableCount;
if (_glfw.wgl.ARB_pixel_format)
{
nativeCount = getPixelFormatAttrib(window,
1,
WGL_NUMBER_PIXEL_FORMATS_ARB);
1,
WGL_NUMBER_PIXEL_FORMATS_ARB);
}
else
{
@@ -197,7 +195,7 @@ static GLFWbool choosePixelFormat(_GLFWwindow* window,
"WGL: The driver does not appear to support OpenGL");
free(usableConfigs);
return GLFW_FALSE;
return 0;
}
closest = _glfwChooseFBConfig(desired, usableConfigs, usableCount);
@@ -207,13 +205,13 @@ static GLFWbool choosePixelFormat(_GLFWwindow* window,
"WGL: Failed to find a suitable pixel format");
free(usableConfigs);
return GLFW_FALSE;
return 0;
}
*result = (int) closest->handle;
pixelFormat = (int) closest->handle;
free(usableConfigs);
return GLFW_TRUE;
return pixelFormat;
}
// Returns whether desktop compositing is enabled
@@ -231,7 +229,7 @@ static GLFWbool isCompositionEnabled(void)
return enabled;
}
static void makeContextCurrent(_GLFWwindow* window)
static void makeContextCurrentWGL(_GLFWwindow* window)
{
if (window)
{
@@ -256,7 +254,7 @@ static void makeContextCurrent(_GLFWwindow* window)
}
}
static void swapBuffers(_GLFWwindow* window)
static void swapBuffersWGL(_GLFWwindow* window)
{
// HACK: Use DwmFlush when desktop composition is enabled
if (isCompositionEnabled() && !window->monitor)
@@ -269,7 +267,7 @@ static void swapBuffers(_GLFWwindow* window)
SwapBuffers(window->context.wgl.dc);
}
static void swapInterval(int interval)
static void swapIntervalWGL(int interval)
{
_GLFWwindow* window = _glfwPlatformGetCurrentContext();
@@ -284,12 +282,10 @@ static void swapInterval(int interval)
_glfw.wgl.SwapIntervalEXT(interval);
}
static int extensionSupported(const char* extension)
static int extensionSupportedWGL(const char* extension)
{
const char* extensions;
_GLFWwindow* window = _glfwPlatformGetCurrentContext();
if (_glfw.wgl.GetExtensionsStringEXT)
{
extensions = _glfw.wgl.GetExtensionsStringEXT();
@@ -302,7 +298,7 @@ static int extensionSupported(const char* extension)
if (_glfw.wgl.GetExtensionsStringARB)
{
extensions = _glfw.wgl.GetExtensionsStringARB(window->context.wgl.dc);
extensions = _glfw.wgl.GetExtensionsStringARB(wglGetCurrentDC());
if (extensions)
{
if (_glfwStringInExtensionString(extension, extensions))
@@ -313,7 +309,7 @@ static int extensionSupported(const char* extension)
return GLFW_FALSE;
}
static GLFWglproc getProcAddress(const char* procname)
static GLFWglproc getProcAddressWGL(const char* procname)
{
const GLFWglproc proc = (GLFWglproc) wglGetProcAddress(procname);
if (proc)
@@ -324,7 +320,7 @@ static GLFWglproc getProcAddress(const char* procname)
// Destroy the OpenGL context
//
static void destroyContext(_GLFWwindow* window)
static void destroyContextWGL(_GLFWwindow* window)
{
if (window->context.wgl.handle)
{
@@ -335,51 +331,88 @@ static void destroyContext(_GLFWwindow* window)
// Initialize WGL-specific extensions
//
static void loadExtensions(void)
static void loadWGLExtensions(void)
{
// Functions for WGL_EXT_extension_string
// NOTE: These are needed by extensionSupported
PIXELFORMATDESCRIPTOR pfd;
HGLRC rc;
HDC dc = GetDC(_glfw.win32.helperWindowHandle);;
_glfw.wgl.extensionsLoaded = GLFW_TRUE;
// NOTE: A dummy context has to be created for opengl32.dll to load the
// OpenGL ICD, from which we can then query WGL extensions
// NOTE: This code will accept the Microsoft GDI ICD; accelerated context
// creation failure occurs during manual pixel format enumeration
ZeroMemory(&pfd, sizeof(pfd));
pfd.nSize = sizeof(pfd);
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 24;
if (!SetPixelFormat(dc, ChoosePixelFormat(dc, &pfd), &pfd))
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"WGL: Failed to set pixel format for dummy context");
return;
}
rc = wglCreateContext(dc);
if (!rc)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"WGL: Failed to create dummy context");
return;
}
if (!wglMakeCurrent(dc, rc))
{
wglDeleteContext(rc);
_glfwInputError(GLFW_PLATFORM_ERROR,
"WGL: Failed to make dummy context current");
return;
}
// NOTE: Functions must be loaded first as they're needed to retrieve the
// extension string that tells us whether the functions are supported
_glfw.wgl.GetExtensionsStringEXT = (PFNWGLGETEXTENSIONSSTRINGEXTPROC)
wglGetProcAddress("wglGetExtensionsStringEXT");
_glfw.wgl.GetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)
wglGetProcAddress("wglGetExtensionsStringARB");
// Functions for WGL_ARB_create_context
_glfw.wgl.CreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)
wglGetProcAddress("wglCreateContextAttribsARB");
// Functions for WGL_EXT_swap_control
_glfw.wgl.SwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)
wglGetProcAddress("wglSwapIntervalEXT");
// Functions for WGL_ARB_pixel_format
_glfw.wgl.GetPixelFormatAttribivARB = (PFNWGLGETPIXELFORMATATTRIBIVARBPROC)
wglGetProcAddress("wglGetPixelFormatAttribivARB");
// This needs to include every extension used below except for
// WGL_ARB_extensions_string and WGL_EXT_extensions_string
// NOTE: WGL_ARB_extensions_string and WGL_EXT_extensions_string are not
// checked below as we are already using them
_glfw.wgl.ARB_multisample =
extensionSupported("WGL_ARB_multisample");
extensionSupportedWGL("WGL_ARB_multisample");
_glfw.wgl.ARB_framebuffer_sRGB =
extensionSupported("WGL_ARB_framebuffer_sRGB");
extensionSupportedWGL("WGL_ARB_framebuffer_sRGB");
_glfw.wgl.EXT_framebuffer_sRGB =
extensionSupported("WGL_EXT_framebuffer_sRGB");
extensionSupportedWGL("WGL_EXT_framebuffer_sRGB");
_glfw.wgl.ARB_create_context =
extensionSupported("WGL_ARB_create_context");
extensionSupportedWGL("WGL_ARB_create_context");
_glfw.wgl.ARB_create_context_profile =
extensionSupported("WGL_ARB_create_context_profile");
extensionSupportedWGL("WGL_ARB_create_context_profile");
_glfw.wgl.EXT_create_context_es2_profile =
extensionSupported("WGL_EXT_create_context_es2_profile");
extensionSupportedWGL("WGL_EXT_create_context_es2_profile");
_glfw.wgl.ARB_create_context_robustness =
extensionSupported("WGL_ARB_create_context_robustness");
extensionSupportedWGL("WGL_ARB_create_context_robustness");
_glfw.wgl.EXT_swap_control =
extensionSupported("WGL_EXT_swap_control");
extensionSupportedWGL("WGL_EXT_swap_control");
_glfw.wgl.ARB_pixel_format =
extensionSupported("WGL_ARB_pixel_format");
extensionSupportedWGL("WGL_ARB_pixel_format");
_glfw.wgl.ARB_context_flush_control =
extensionSupported("WGL_ARB_context_flush_control");
extensionSupportedWGL("WGL_ARB_context_flush_control");
_glfw.wgl.extensionsLoaded = GLFW_TRUE;
wglMakeCurrent(dc, NULL);
wglDeleteContext(rc);
}
@@ -391,6 +424,9 @@ static void loadExtensions(void)
//
GLFWbool _glfwInitWGL(void)
{
if (_glfw.wgl.instance)
return GLFW_TRUE;
_glfw.wgl.instance = LoadLibraryA("opengl32.dll");
if (!_glfw.wgl.instance)
{
@@ -404,6 +440,8 @@ GLFWbool _glfwInitWGL(void)
GetProcAddress(_glfw.wgl.instance, "wglDeleteContext");
_glfw.wgl.GetProcAddress = (WGLGETPROCADDRESS_T)
GetProcAddress(_glfw.wgl.instance, "wglGetProcAddress");
_glfw.wgl.GetCurrentDC = (WGLGETCURRENTDC_T)
GetProcAddress(_glfw.wgl.instance, "wglGetCurrentDC");
_glfw.wgl.MakeCurrent = (WGLMAKECURRENT_T)
GetProcAddress(_glfw.wgl.instance, "wglMakeCurrent");
_glfw.wgl.ShareLists = (WGLSHARELISTS_T)
@@ -434,12 +472,12 @@ GLFWbool _glfwCreateContextWGL(_GLFWwindow* window,
const _GLFWfbconfig* fbconfig)
{
int attribs[40];
int pixelFormat = 0;
int pixelFormat;
PIXELFORMATDESCRIPTOR pfd;
HGLRC share = NULL;
if (ctxconfig->client == GLFW_NO_API)
return GLFW_TRUE;
if (!_glfw.wgl.extensionsLoaded)
loadWGLExtensions();
if (ctxconfig->share)
share = ctxconfig->share->context.wgl.handle;
@@ -452,7 +490,8 @@ GLFWbool _glfwCreateContextWGL(_GLFWwindow* window,
return GLFW_FALSE;
}
if (!choosePixelFormat(window, fbconfig, &pixelFormat))
pixelFormat = choosePixelFormat(window, fbconfig);
if (!pixelFormat)
return GLFW_FALSE;
if (!DescribePixelFormat(window->context.wgl.dc,
@@ -470,6 +509,40 @@ GLFWbool _glfwCreateContextWGL(_GLFWwindow* window,
return GLFW_FALSE;
}
if (ctxconfig->client == GLFW_OPENGL_API)
{
if (ctxconfig->forward)
{
if (!_glfw.wgl.ARB_create_context)
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"WGL: A forward compatible OpenGL context requested but WGL_ARB_create_context is unavailable");
return GLFW_FALSE;
}
}
if (ctxconfig->profile)
{
if (!_glfw.wgl.ARB_create_context_profile)
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"WGL: OpenGL profile requested but WGL_ARB_create_context_profile is unavailable");
return GLFW_FALSE;
}
}
}
else
{
if (!_glfw.wgl.ARB_create_context ||
!_glfw.wgl.ARB_create_context_profile ||
!_glfw.wgl.EXT_create_context_es2_profile)
{
_glfwInputError(GLFW_API_UNAVAILABLE,
"WGL: OpenGL ES requested but WGL_ARB_create_context_es2_profile is unavailable");
return GLFW_FALSE;
}
}
if (_glfw.wgl.ARB_create_context)
{
int index = 0, mask = 0, flags = 0;
@@ -550,8 +623,44 @@ GLFWbool _glfwCreateContextWGL(_GLFWwindow* window,
share, attribs);
if (!window->context.wgl.handle)
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"WGL: Failed to create OpenGL context");
const DWORD error = GetLastError();
if (error == (0xc0070000 | ERROR_INVALID_VERSION_ARB))
{
if (ctxconfig->client == GLFW_OPENGL_API)
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"WGL: Driver does not support OpenGL version %i.%i",
ctxconfig->major,
ctxconfig->minor);
}
else
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"WGL: Driver does not support OpenGL ES version %i.%i",
ctxconfig->major,
ctxconfig->minor);
}
}
else if (error == (0xc0070000 | ERROR_INVALID_PROFILE_ARB))
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"WGL: Driver does not support the requested OpenGL profile");
}
else
{
if (ctxconfig->client == GLFW_OPENGL_API)
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"WGL: Failed to create OpenGL context");
}
else
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"WGL: Failed to create OpenGL ES context");
}
}
return GLFW_FALSE;
}
}
@@ -576,114 +685,18 @@ GLFWbool _glfwCreateContextWGL(_GLFWwindow* window,
}
}
window->context.makeCurrent = makeContextCurrent;
window->context.swapBuffers = swapBuffers;
window->context.swapInterval = swapInterval;
window->context.extensionSupported = extensionSupported;
window->context.getProcAddress = getProcAddress;
window->context.destroy = destroyContext;
window->context.makeCurrent = makeContextCurrentWGL;
window->context.swapBuffers = swapBuffersWGL;
window->context.swapInterval = swapIntervalWGL;
window->context.extensionSupported = extensionSupportedWGL;
window->context.getProcAddress = getProcAddressWGL;
window->context.destroy = destroyContextWGL;
return GLFW_TRUE;
}
#undef setWGLattrib
// Analyzes the specified context for possible recreation
//
int _glfwAnalyzeContextWGL(_GLFWwindow* window,
const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig)
{
GLFWbool required = GLFW_FALSE;
if (_glfw.wgl.extensionsLoaded)
return _GLFW_RECREATION_NOT_NEEDED;
makeContextCurrent(window);
loadExtensions();
if (ctxconfig->client == GLFW_OPENGL_API)
{
if (ctxconfig->forward)
{
if (!_glfw.wgl.ARB_create_context)
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"WGL: A forward compatible OpenGL context requested but WGL_ARB_create_context is unavailable");
return _GLFW_RECREATION_IMPOSSIBLE;
}
required = GLFW_TRUE;
}
if (ctxconfig->profile)
{
if (!_glfw.wgl.ARB_create_context_profile)
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"WGL: OpenGL profile requested but WGL_ARB_create_context_profile is unavailable");
return _GLFW_RECREATION_IMPOSSIBLE;
}
required = GLFW_TRUE;
}
if (ctxconfig->release)
{
if (_glfw.wgl.ARB_context_flush_control)
required = GLFW_TRUE;
}
}
else
{
if (!_glfw.wgl.ARB_create_context ||
!_glfw.wgl.ARB_create_context_profile ||
!_glfw.wgl.EXT_create_context_es2_profile)
{
_glfwInputError(GLFW_API_UNAVAILABLE,
"WGL: OpenGL ES requested but WGL_ARB_create_context_es2_profile is unavailable");
return _GLFW_RECREATION_IMPOSSIBLE;
}
required = GLFW_TRUE;
}
if (ctxconfig->major != 1 || ctxconfig->minor != 0)
{
if (_glfw.wgl.ARB_create_context)
required = GLFW_TRUE;
}
if (ctxconfig->debug)
{
if (_glfw.wgl.ARB_create_context)
required = GLFW_TRUE;
}
if (fbconfig->samples > 0)
{
// MSAA is not a hard constraint, so do nothing if it's not supported
if (_glfw.wgl.ARB_multisample && _glfw.wgl.ARB_pixel_format)
required = GLFW_TRUE;
}
if (fbconfig->sRGB)
{
// sRGB is not a hard constraint, so do nothing if it's not supported
if ((_glfw.wgl.ARB_framebuffer_sRGB ||
_glfw.wgl.EXT_framebuffer_sRGB) &&
_glfw.wgl.ARB_pixel_format)
{
required = GLFW_TRUE;
}
}
if (required)
return _GLFW_RECREATION_REQUIRED;
return _GLFW_RECREATION_NOT_NEEDED;
}
//////////////////////////////////////////////////////////////////////////
////// GLFW native API //////
+7 -5
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 WGL - www.glfw.org
// GLFW 3.3 WGL - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2016 Camilla Berglund <elmindreda@glfw.org>
@@ -73,6 +73,9 @@
#define WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0
#define WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098
#define ERROR_INVALID_VERSION_ARB 0x2095
#define ERROR_INVALID_PROFILE_ARB 0x2096
typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC)(int);
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC)(HDC,int,int,UINT,const int*,int*);
typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC)(void);
@@ -82,6 +85,7 @@ typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC,HGLRC,const int*)
typedef HGLRC (WINAPI * WGLCREATECONTEXT_T)(HDC);
typedef BOOL (WINAPI * WGLDELETECONTEXT_T)(HGLRC);
typedef PROC (WINAPI * WGLGETPROCADDRESS_T)(LPCSTR);
typedef HDC (WINAPI * WGLGETCURRENTDC_T)(void);
typedef BOOL (WINAPI * WGLMAKECURRENT_T)(HDC,HGLRC);
typedef BOOL (WINAPI * WGLSHARELISTS_T)(HGLRC,HGLRC);
@@ -89,6 +93,7 @@ typedef BOOL (WINAPI * WGLSHARELISTS_T)(HGLRC,HGLRC);
#define wglCreateContext _glfw.wgl.CreateContext
#define wglDeleteContext _glfw.wgl.DeleteContext
#define wglGetProcAddress _glfw.wgl.GetProcAddress
#define wglGetCurrentDC _glfw.wgl.GetCurrentDC
#define wglMakeCurrent _glfw.wgl.MakeCurrent
#define wglShareLists _glfw.wgl.ShareLists
@@ -110,7 +115,6 @@ typedef struct _GLFWcontextWGL
} _GLFWcontextWGL;
// WGL-specific global data
//
typedef struct _GLFWlibraryWGL
@@ -119,6 +123,7 @@ typedef struct _GLFWlibraryWGL
WGLCREATECONTEXT_T CreateContext;
WGLDELETECONTEXT_T DeleteContext;
WGLGETPROCADDRESS_T GetProcAddress;
WGLGETCURRENTDC_T GetCurrentDC;
WGLMAKECURRENT_T MakeCurrent;
WGLSHARELISTS_T ShareLists;
@@ -148,8 +153,5 @@ void _glfwTerminateWGL(void);
GLFWbool _glfwCreateContextWGL(_GLFWwindow* window,
const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig);
int _glfwAnalyzeContextWGL(_GLFWwindow* window,
const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig);
#endif // _glfw3_wgl_context_h_
+6 -6
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 Win32 - www.glfw.org
// GLFW 3.3 Win32 - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2016 Camilla Berglund <elmindreda@glfw.org>
@@ -319,6 +319,10 @@ static HWND createHelperWindow(void)
return NULL;
}
// HACK: The first call to ShowWindow is ignored if the parent process
// passed along a STARTUPINFO, so clear that flag with a no-op call
ShowWindow(window, SW_HIDE);
// Register for HID device notifications
{
DEV_BROADCAST_DEVICEINTERFACE_W dbi;
@@ -373,7 +377,7 @@ char* _glfwCreateUTF8FromWideStringWin32(const WCHAR* source)
if (!length)
return NULL;
target = calloc(length, sizeof(char));
target = calloc(length, 1);
if (!WideCharToMultiByte(CP_UTF8, 0, source, -1, target, length, NULL, NULL))
{
@@ -421,10 +425,6 @@ int _glfwPlatformInit(void)
_glfwPlatformPollEvents();
if (!_glfwInitWGL())
return GLFW_FALSE;
_glfwInitEGL();
_glfwInitTimerWin32();
_glfwInitJoysticksWin32();
+3 -3
View File
@@ -176,7 +176,7 @@ static int compareJoystickObjects(const void* first, const void* second)
//
static GLFWbool supportsXInput(const GUID* guid)
{
UINT i, count;
UINT i, count = 0;
RAWINPUTDEVICELIST* ridl;
GLFWbool result = GLFW_FALSE;
@@ -185,7 +185,7 @@ static GLFWbool supportsXInput(const GUID* guid)
ridl = calloc(count, sizeof(RAWINPUTDEVICELIST));
if (GetRawInputDeviceList(ridl, &count, sizeof(RAWINPUTDEVICELIST)) == -1)
if (GetRawInputDeviceList(ridl, &count, sizeof(RAWINPUTDEVICELIST)) == (UINT) -1)
{
free(ridl);
return GLFW_FALSE;
@@ -211,7 +211,7 @@ static GLFWbool supportsXInput(const GUID* guid)
continue;
}
if (MAKELONG(rdi.hid.dwVendorId, rdi.hid.dwProductId) != guid->Data1)
if (MAKELONG(rdi.hid.dwVendorId, rdi.hid.dwProductId) != (LONG) guid->Data1)
continue;
memset(name, 0, sizeof(name));
+2 -2
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 Win32 - www.glfw.org
// GLFW 3.3 Win32 - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2006-2016 Camilla Berglund <elmindreda@glfw.org>
//
@@ -30,7 +30,7 @@
#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE \
_GLFWjoystickWin32 win32_js[GLFW_JOYSTICK_LAST + 1]
// Spoo
// Joystick element (axis, button or slider)
//
typedef struct _GLFWjoyobjectWin32
{
+1 -1
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 Win32 - www.glfw.org
// GLFW 3.3 Win32 - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2016 Camilla Berglund <elmindreda@glfw.org>
+1 -6
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 Win32 - www.glfw.org
// GLFW 3.3 Win32 - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2016 Camilla Berglund <elmindreda@glfw.org>
@@ -241,7 +241,6 @@ typedef struct _GLFWwindowWin32
} _GLFWwindowWin32;
// Win32-specific global data
//
typedef struct _GLFWlibraryWin32
@@ -293,7 +292,6 @@ typedef struct _GLFWlibraryWin32
} _GLFWlibraryWin32;
// Win32-specific per-monitor data
//
typedef struct _GLFWmonitorWin32
@@ -308,7 +306,6 @@ typedef struct _GLFWmonitorWin32
} _GLFWmonitorWin32;
// Win32-specific per-cursor data
//
typedef struct _GLFWcursorWin32
@@ -317,7 +314,6 @@ typedef struct _GLFWcursorWin32
} _GLFWcursorWin32;
// Win32-specific global timer data
//
typedef struct _GLFWtimeWin32
@@ -327,7 +323,6 @@ typedef struct _GLFWtimeWin32
} _GLFWtimeWin32;
// Win32-specific global TLS data
//
typedef struct _GLFWtlsWin32
+1 -1
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 Win32 - www.glfw.org
// GLFW 3.3 Win32 - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2016 Camilla Berglund <elmindreda@glfw.org>
+1 -1
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 Win32 - www.glfw.org
// GLFW 3.3 Win32 - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2016 Camilla Berglund <elmindreda@glfw.org>
+55 -87
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 Win32 - www.glfw.org
// GLFW 3.3 Win32 - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2016 Camilla Berglund <elmindreda@glfw.org>
@@ -850,9 +850,10 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
return DefWindowProcW(hWnd, uMsg, wParam, lParam);
}
// Creates the GLFW window and rendering context
// Creates the GLFW window
//
static int createWindow(_GLFWwindow* window, const _GLFWwndconfig* wndconfig)
static int createNativeWindow(_GLFWwindow* window,
const _GLFWwndconfig* wndconfig)
{
int xpos, ypos, fullWidth, fullHeight;
WCHAR* wideTitle;
@@ -928,21 +929,6 @@ static int createWindow(_GLFWwindow* window, const _GLFWwndconfig* wndconfig)
return GLFW_TRUE;
}
// Destroys the GLFW window and rendering context
//
static void destroyWindow(_GLFWwindow* window)
{
if (_glfw.win32.disabledCursorWindow == window)
_glfw.win32.disabledCursorWindow = NULL;
if (window->win32.handle)
{
RemovePropW(window->win32.handle, L"GLFW");
DestroyWindow(window->win32.handle);
window->win32.handle = NULL;
}
}
//////////////////////////////////////////////////////////////////////////
////// GLFW internal API //////
@@ -1001,60 +987,22 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig)
{
int status;
if (!createWindow(window, wndconfig))
if (!createNativeWindow(window, wndconfig))
return GLFW_FALSE;
if (ctxconfig->client != GLFW_NO_API)
{
if (ctxconfig->source == GLFW_NATIVE_CONTEXT_API)
{
if (!_glfwInitWGL())
return GLFW_FALSE;
if (!_glfwCreateContextWGL(window, ctxconfig, fbconfig))
return GLFW_FALSE;
status = _glfwAnalyzeContextWGL(window, ctxconfig, fbconfig);
if (status == _GLFW_RECREATION_IMPOSSIBLE)
return GLFW_FALSE;
if (status == _GLFW_RECREATION_REQUIRED)
{
// Some window hints require us to re-create the context using WGL
// extensions retrieved through the current context, as we cannot
// check for WGL extensions or retrieve WGL entry points before we
// have a current context (actually until we have implicitly loaded
// the vendor ICD)
// Yes, this is strange, and yes, this is the proper way on WGL
// As Windows only allows you to set the pixel format once for
// a window, we need to destroy the current window and create a new
// one to be able to use the new pixel format
// Technically, it may be possible to keep the old window around if
// we're just creating an OpenGL 3.0+ context with the same pixel
// format, but it's not worth the added code complexity
// First we clear the current context (the one we just created)
// This is usually done by glfwDestroyWindow, but as we're not doing
// full GLFW window destruction, it's duplicated here
window->context.makeCurrent(NULL);
// Next destroy the Win32 window and WGL context (without resetting
// or destroying the GLFW window object)
window->context.destroy(window);
destroyWindow(window);
// ...and then create them again, this time with better APIs
if (!createWindow(window, wndconfig))
return GLFW_FALSE;
if (!_glfwCreateContextWGL(window, ctxconfig, fbconfig))
return GLFW_FALSE;
}
}
else
{
if (!_glfwInitEGL())
return GLFW_FALSE;
if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))
return GLFW_FALSE;
}
@@ -1078,10 +1026,18 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
if (window->monitor)
releaseMonitor(window);
if (window->context.client != GLFW_NO_API)
if (window->context.destroy)
window->context.destroy(window);
destroyWindow(window);
if (_glfw.win32.disabledCursorWindow == window)
_glfw.win32.disabledCursorWindow = NULL;
if (window->win32.handle)
{
RemovePropW(window->win32.handle, L"GLFW");
DestroyWindow(window->win32.handle);
window->win32.handle = NULL;
}
if (window->win32.bigIcon)
DestroyIcon(window->win32.bigIcon);
@@ -1594,52 +1550,55 @@ void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)
void _glfwPlatformSetClipboardString(_GLFWwindow* window, const char* string)
{
WCHAR* wideString;
HANDLE stringHandle;
size_t wideSize;
int characterCount;
HANDLE object;
WCHAR* buffer;
wideString = _glfwCreateWideStringFromUTF8Win32(string);
if (!wideString)
characterCount = MultiByteToWideChar(CP_UTF8, 0, string, -1, NULL, 0);
if (!characterCount)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Win32: Failed to convert string to UTF-16");
"Win32: Failed to convert clipboard string to UTF-16");
return;
}
wideSize = (wcslen(wideString) + 1) * sizeof(WCHAR);
stringHandle = GlobalAlloc(GMEM_MOVEABLE, wideSize);
if (!stringHandle)
object = GlobalAlloc(GMEM_MOVEABLE, characterCount * sizeof(WCHAR));
if (!object)
{
free(wideString);
_glfwInputError(GLFW_PLATFORM_ERROR,
"Win32: Failed to allocate global handle for clipboard");
return;
}
memcpy(GlobalLock(stringHandle), wideString, wideSize);
GlobalUnlock(stringHandle);
buffer = GlobalLock(object);
if (!buffer)
{
GlobalFree(object);
_glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Failed to lock global handle");
return;
}
MultiByteToWideChar(CP_UTF8, 0, string, -1, buffer, characterCount);
GlobalUnlock(object);
if (!OpenClipboard(_glfw.win32.helperWindowHandle))
{
GlobalFree(stringHandle);
free(wideString);
GlobalFree(object);
_glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Failed to open clipboard");
return;
}
EmptyClipboard();
SetClipboardData(CF_UNICODETEXT, stringHandle);
SetClipboardData(CF_UNICODETEXT, object);
CloseClipboard();
free(wideString);
}
const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
{
HANDLE stringHandle;
HANDLE object;
WCHAR* buffer;
if (!OpenClipboard(_glfw.win32.helperWindowHandle))
{
@@ -1647,8 +1606,8 @@ const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
return NULL;
}
stringHandle = GetClipboardData(CF_UNICODETEXT);
if (!stringHandle)
object = GetClipboardData(CF_UNICODETEXT);
if (!object)
{
CloseClipboard();
@@ -1657,11 +1616,20 @@ const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
return NULL;
}
buffer = GlobalLock(object);
if (!buffer)
{
CloseClipboard();
_glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Failed to lock global handle");
return NULL;
}
free(_glfw.win32.clipboardString);
_glfw.win32.clipboardString =
_glfwCreateUTF8FromWideStringWin32(GlobalLock(stringHandle));
_glfwCreateUTF8FromWideStringWin32(buffer);
GlobalUnlock(stringHandle);
GlobalUnlock(object);
CloseClipboard();
if (!_glfw.win32.clipboardString)
+5 -2
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 - www.glfw.org
// GLFW 3.3 - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2016 Camilla Berglund <elmindreda@glfw.org>
@@ -151,7 +151,8 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
if (ctxconfig.share)
{
if (ctxconfig.share->context.client == GLFW_NO_API)
if (ctxconfig.client == GLFW_NO_API ||
ctxconfig.share->context.client == GLFW_NO_API)
{
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
return NULL;
@@ -627,6 +628,8 @@ GLFWAPI void glfwRestoreWindow(GLFWwindow* handle)
GLFWAPI void glfwMaximizeWindow(GLFWwindow* handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
_GLFW_REQUIRE_INIT();
_glfwPlatformMaximizeWindow(window);
}
+1 -4
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 Wayland - www.glfw.org
// GLFW 3.3 Wayland - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com>
//
@@ -600,9 +600,6 @@ int _glfwPlatformInit(void)
if (!_glfwInitThreadLocalStoragePOSIX())
return GLFW_FALSE;
if (!_glfwInitEGL())
return GLFW_FALSE;
if (!_glfwInitJoysticksLinux())
return GLFW_FALSE;
+2 -2
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 Wayland - www.glfw.org
// GLFW 3.3 Wayland - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com>
//
@@ -120,7 +120,7 @@ void _glfwAddOutputWayland(uint32_t name, uint32_t version)
struct wl_output *output;
char name_str[80];
memset(name_str, 0, 80 * sizeof(char));
memset(name_str, 0, sizeof(name_str));
snprintf(name_str, 79, "wl_output@%u", name);
if (version < 2)
+1 -5
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 Wayland - www.glfw.org
// GLFW 3.3 Wayland - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com>
//
@@ -74,7 +74,6 @@ typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR
//
typedef struct _GLFWvidmodeWayland _GLFWvidmodeWayland;
// Wayland-specific per-window data
//
typedef struct _GLFWwindowWayland
@@ -105,7 +104,6 @@ typedef struct _GLFWwindowWayland
} pointerLock;
} _GLFWwindowWayland;
// Wayland-specific global data
//
typedef struct _GLFWlibraryWayland
@@ -149,7 +147,6 @@ typedef struct _GLFWlibraryWayland
} _GLFWlibraryWayland;
// Wayland-specific per-monitor data
//
typedef struct _GLFWmonitorWayland
@@ -166,7 +163,6 @@ typedef struct _GLFWmonitorWayland
int scale;
} _GLFWmonitorWayland;
// Wayland-specific per-cursor data
//
typedef struct _GLFWcursorWayland
+4 -2
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 Wayland - www.glfw.org
// GLFW 3.3 Wayland - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com>
//
@@ -393,6 +393,8 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
if (ctxconfig->client != GLFW_NO_API)
{
if (!_glfwInitEGL())
return GLFW_FALSE;
if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))
return GLFW_FALSE;
}
@@ -435,7 +437,7 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
_glfwInputWindowFocus(window, GLFW_FALSE);
}
if (window->context.client != GLFW_NO_API)
if (window->context.destroy)
window->context.destroy(window);
if (window->wl.native)
+3 -8
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 X11 - www.glfw.org
// GLFW 3.3 X11 - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2016 Camilla Berglund <elmindreda@glfw.org>
@@ -72,9 +72,8 @@ static int translateKeyCode(int scancode)
default: break;
}
// Now try primary keysym for function keys (non-printable keys). These
// should not be layout dependent (i.e. US layout and international
// layouts should give the same result).
// Now try primary keysym for function keys (non-printable keys)
// These should not depend on the current keyboard layout
keySym = XkbKeycodeToKeysym(_glfw.x11.display, scancode, 0, 0);
}
else
@@ -766,13 +765,9 @@ int _glfwPlatformInit(void)
if (!_glfwInitThreadLocalStoragePOSIX())
return GLFW_FALSE;
if (!_glfwInitGLX())
return GLFW_FALSE;
if (!_glfwInitJoysticksLinux())
return GLFW_FALSE;
_glfwInitEGL();
_glfwInitTimerPOSIX();
return GLFW_TRUE;
+1 -1
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 X11 - www.glfw.org
// GLFW 3.3 X11 - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2016 Camilla Berglund <elmindreda@glfw.org>
+5 -8
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 X11 - www.glfw.org
// GLFW 3.3 X11 - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2016 Camilla Berglund <elmindreda@glfw.org>
@@ -123,14 +123,11 @@ typedef struct _GLFWwindowX11
int warpCursorPosX, warpCursorPosY;
// The information from the last KeyPress event
struct {
unsigned int keycode;
Time time;
} last;
unsigned int lastKeyCode;
Time lastKeyTime;
} _GLFWwindowX11;
// X11-specific global data
//
typedef struct _GLFWlibraryX11
@@ -159,6 +156,8 @@ typedef struct _GLFWlibraryX11
double restoreCursorPosX, restoreCursorPosY;
// The window whose disabled cursor mode is active
_GLFWwindow* disabledCursorWindow;
// The last received event time
int lastEventTime;
// Window manager atoms
Atom WM_PROTOCOLS;
@@ -259,7 +258,6 @@ typedef struct _GLFWlibraryX11
} _GLFWlibraryX11;
// X11-specific per-monitor data
//
typedef struct _GLFWmonitorX11
@@ -274,7 +272,6 @@ typedef struct _GLFWmonitorX11
} _GLFWmonitorX11;
// X11-specific per-cursor data
//
typedef struct _GLFWcursorX11
+133 -96
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 X11 - www.glfw.org
// GLFW 3.3 X11 - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2016 Camilla Berglund <elmindreda@glfw.org>
@@ -49,15 +49,15 @@
#define Button7 7
// Wait for data to arrive
// Wait for data to arrive using select
// This avoids blocking other threads via the per-display Xlib lock that also
// covers GLX functions
//
void selectDisplayConnection(struct timeval* timeout)
static GLFWbool waitForEvent(double* timeout)
{
fd_set fds;
int result, count;
const int fd = ConnectionNumber(_glfw.x11.display);
count = fd + 1;
int count = fd + 1;
FD_ZERO(&fds);
FD_SET(fd, &fds);
@@ -67,18 +67,49 @@ void selectDisplayConnection(struct timeval* timeout)
if (fd < _glfw.linux_js.inotify)
count = _glfw.linux_js.inotify + 1;
#endif
// NOTE: We use select instead of an X function like XNextEvent, as the
// wait inside those are guarded by the mutex protecting the display
// struct, locking out other threads from using X (including GLX)
// NOTE: Only retry on EINTR if there is no timeout, as select is not
// required to update it for the time elapsed
// TODO: Update timeout value manually
do
for (;;)
{
result = select(count, &fds, NULL, NULL, timeout);
if (timeout)
{
const long seconds = (long) *timeout;
const long microseconds = (long) ((*timeout - seconds) * 1e6);
struct timeval tv = { seconds, microseconds };
const uint64_t base = _glfwPlatformGetTimerValue();
const int result = select(count, &fds, NULL, NULL, &tv);
const int error = errno;
*timeout -= (_glfwPlatformGetTimerValue() - base) /
(double) _glfwPlatformGetTimerFrequency();
if (result > 0)
return GLFW_TRUE;
if ((result == -1 && error == EINTR) || *timeout <= 0.0)
return GLFW_FALSE;
}
else if (select(count, &fds, NULL, NULL, NULL) != -1 || errno != EINTR)
return GLFW_TRUE;
}
while (result == -1 && errno == EINTR && timeout == NULL);
}
// Waits until a VisibilityNotify event arrives for the specified window or the
// timeout period elapses (ICCCM section 4.2.2)
//
static GLFWbool waitForVisibilityNotify(_GLFWwindow* window)
{
XEvent dummy;
double timeout = 0.1;
while (!XCheckTypedWindowEvent(_glfw.x11.display,
window->x11.handle,
VisibilityNotify,
&dummy))
{
if (!waitForEvent(&timeout))
return GLFW_FALSE;
}
return GLFW_TRUE;
}
// Returns whether the window is iconified
@@ -105,6 +136,15 @@ static int getWindowState(_GLFWwindow* window)
// Returns whether the event is a selection event
//
static Bool isSelectionEvent(Display* display, XEvent* event, XPointer pointer)
{
return event->type == SelectionRequest ||
event->type == SelectionNotify ||
event->type == SelectionClear;
}
// Returns whether it is a _NET_FRAME_EXTENTS event for the specified window
//
static Bool isFrameExtentsEvent(Display* display, XEvent* event, XPointer pointer)
{
_GLFWwindow* window = (_GLFWwindow*) pointer;
@@ -218,14 +258,18 @@ static void updateNormalHints(_GLFWwindow* window, int width, int height)
if (window->resizable)
{
if (window->minwidth != GLFW_DONT_CARE &&
window->minheight != GLFW_DONT_CARE &&
window->maxwidth != GLFW_DONT_CARE &&
window->minheight != GLFW_DONT_CARE)
{
hints->flags |= PMinSize;
hints->min_width = window->minwidth;
hints->min_height = window->minheight;
}
if (window->maxwidth != GLFW_DONT_CARE &&
window->maxheight != GLFW_DONT_CARE)
{
hints->flags |= (PMinSize | PMaxSize);
hints->min_width = window->minwidth;
hints->min_height = window->minheight;
hints->max_width = window->maxwidth;
hints->flags |= PMaxSize;
hints->max_width = window->maxwidth;
hints->max_height = window->maxheight;
}
@@ -245,6 +289,9 @@ static void updateNormalHints(_GLFWwindow* window, int width, int height)
}
}
hints->flags |= PWinGravity;
hints->win_gravity = StaticGravity;
XSetWMNormalHints(_glfw.x11.display, window->x11.handle, hints);
XFree(hints);
}
@@ -416,9 +463,9 @@ static void updateCursorImage(_GLFWwindow* window)
// Create the X11 window (and its colormap)
//
static GLFWbool createWindow(_GLFWwindow* window,
const _GLFWwndconfig* wndconfig,
Visual* visual, int depth)
static GLFWbool createNativeWindow(_GLFWwindow* window,
const _GLFWwndconfig* wndconfig,
Visual* visual, int depth)
{
// Create a colormap based on the visual used by the current context
window->x11.colormap = XCreateColormap(_glfw.x11.display,
@@ -608,15 +655,6 @@ static GLFWbool createWindow(_GLFWwindow* window,
return GLFW_TRUE;
}
// Returns whether the event is a selection event
//
static Bool isSelectionEvent(Display* display, XEvent* event, XPointer pointer)
{
return event->type == SelectionRequest ||
event->type == SelectionNotify ||
event->type == SelectionClear;
}
// Set the specified property to the selection converted to the requested target
//
static Atom writeTargetToProperty(const XSelectionRequestEvent* request)
@@ -781,7 +819,7 @@ static void pushSelectionToManager(_GLFWwindow* window)
_glfw.x11.SAVE_TARGETS,
None,
window->x11.handle,
CurrentTime);
_glfw.x11.lastEventTime);
for (;;)
{
@@ -815,7 +853,7 @@ static void pushSelectionToManager(_GLFWwindow* window)
}
}
selectDisplayConnection(NULL);
waitForEvent(NULL);
}
}
@@ -948,6 +986,8 @@ static void processEvent(XEvent *event)
{
case KeyPress:
{
_glfw.x11.lastEventTime = event->xkey.time;
const int key = translateKey(keycode);
const int mods = translateState(event->xkey.state);
const int plain = !(mods & (GLFW_MOD_CONTROL | GLFW_MOD_ALT));
@@ -957,15 +997,15 @@ static void processEvent(XEvent *event)
// HACK: Ignore duplicate key press events generated by ibus
// Corresponding release events are filtered out by the
// GLFW key repeat logic
if (window->x11.last.keycode != keycode ||
window->x11.last.time != event->xkey.time)
if (window->x11.lastKeyCode != keycode ||
window->x11.lastKeyTime != event->xkey.time)
{
if (keycode)
_glfwInputKey(window, key, keycode, GLFW_PRESS, mods);
}
window->x11.last.keycode = keycode;
window->x11.last.time = event->xkey.time;
window->x11.lastKeyCode = keycode;
window->x11.lastKeyTime = event->xkey.time;
if (!filtered)
{
@@ -1043,6 +1083,8 @@ static void processEvent(XEvent *event)
case KeyRelease:
{
_glfw.x11.lastEventTime = event->xkey.time;
const int key = translateKey(keycode);
const int mods = translateState(event->xkey.state);
@@ -1084,6 +1126,8 @@ static void processEvent(XEvent *event)
case ButtonPress:
{
_glfw.x11.lastEventTime = event->xbutton.time;
const int mods = translateState(event->xbutton.state);
if (event->xbutton.button == Button1)
@@ -1118,6 +1162,8 @@ static void processEvent(XEvent *event)
case ButtonRelease:
{
_glfw.x11.lastEventTime = event->xbutton.time;
const int mods = translateState(event->xbutton.state);
if (event->xbutton.button == Button1)
@@ -1156,6 +1202,8 @@ static void processEvent(XEvent *event)
case EnterNotify:
{
_glfw.x11.lastEventTime = event->xcrossing.time;
// HACK: This is a workaround for WMs (KWM, Fluxbox) that otherwise
// ignore the defined cursor for hidden cursor mode
if (window->cursorMode == GLFW_CURSOR_HIDDEN)
@@ -1167,12 +1215,15 @@ static void processEvent(XEvent *event)
case LeaveNotify:
{
_glfw.x11.lastEventTime = event->xcrossing.time;
_glfwInputCursorEnter(window, GLFW_FALSE);
return;
}
case MotionNotify:
{
_glfw.x11.lastEventTime = event->xmotion.time;
const int x = event->xmotion.x;
const int y = event->xmotion.y;
@@ -1285,7 +1336,8 @@ static void processEvent(XEvent *event)
_glfw.x11.XdndSelection,
_glfw.x11.UTF8_STRING,
_glfw.x11.XdndSelection,
window->x11.handle, CurrentTime);
window->x11.handle,
_glfw.x11.lastEventTime);
}
else if (event->xclient.message_type == _glfw.x11.XdndPosition)
{
@@ -1321,6 +1373,8 @@ static void processEvent(XEvent *event)
case SelectionNotify:
{
_glfw.x11.lastEventTime = event->xselection.time;
if (event->xselection.property)
{
// The converted data from the drag operation has arrived
@@ -1416,6 +1470,8 @@ static void processEvent(XEvent *event)
case PropertyNotify:
{
_glfw.x11.lastEventTime = event->xproperty.time;
if (event->xproperty.atom == _glfw.x11.WM_STATE &&
event->xproperty.state == PropertyNewValue)
{
@@ -1441,12 +1497,14 @@ static void processEvent(XEvent *event)
case SelectionClear:
{
_glfw.x11.lastEventTime = event->xselectionclear.time;
handleSelectionClear(event);
return;
}
case SelectionRequest:
{
_glfw.x11.lastEventTime = event->xselectionrequest.time;
handleSelectionRequest(event);
return;
}
@@ -1514,17 +1572,21 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
{
if (ctxconfig->source == GLFW_NATIVE_CONTEXT_API)
{
if (!_glfwInitGLX())
return GLFW_FALSE;
if (!_glfwChooseVisualGLX(ctxconfig, fbconfig, &visual, &depth))
return GLFW_FALSE;
}
else
{
if (!_glfwInitEGL())
return GLFW_FALSE;
if (!_glfwChooseVisualEGL(ctxconfig, fbconfig, &visual, &depth))
return GLFW_FALSE;
}
}
if (!createWindow(window, wndconfig, visual, depth))
if (!createNativeWindow(window, wndconfig, visual, depth))
return GLFW_FALSE;
if (ctxconfig->client != GLFW_NO_API)
@@ -1569,7 +1631,7 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
window->x11.ic = NULL;
}
if (window->context.client != GLFW_NO_API)
if (window->context.destroy)
window->context.destroy(window);
if (window->x11.handle)
@@ -1673,21 +1735,11 @@ void _glfwPlatformSetWindowIcon(_GLFWwindow* window,
void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
{
Window child;
Window dummy;
int x, y;
XTranslateCoordinates(_glfw.x11.display, window->x11.handle, _glfw.x11.root,
0, 0, &x, &y, &child);
if (child)
{
int left, top;
XTranslateCoordinates(_glfw.x11.display, window->x11.handle, child,
0, 0, &left, &top, &child);
x -= left;
y -= top;
}
0, 0, &x, &y, &dummy);
if (xpos)
*xpos = x;
@@ -1786,19 +1838,16 @@ void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
if (!_glfwPlatformWindowVisible(window) &&
_glfw.x11.NET_REQUEST_FRAME_EXTENTS)
{
uint64_t base;
XEvent event;
double timeout = 0.5;
// Ensure _NET_FRAME_EXTENTS is set, allowing glfwGetWindowFrameSize to
// function before the window is mapped
sendEventToWM(window, _glfw.x11.NET_REQUEST_FRAME_EXTENTS,
0, 0, 0, 0, 0);
base = _glfwPlatformGetTimerValue();
// HACK: Poll with timeout for the required reply instead of blocking
// This is done because some window managers (at least Unity,
// Fluxbox and Xfwm) failed to send the required reply
// HACK: Use a timeout because earlier versions of some window managers
// (at least Unity, Fluxbox and Xfwm) failed to send the reply
// They have been fixed but broken versions are still in the wild
// If you are affected by this and your window manager is NOT
// listed above, PLEASE report it to their and our issue trackers
@@ -1807,21 +1856,12 @@ void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
isFrameExtentsEvent,
(XPointer) window))
{
double remaining;
struct timeval timeout;
remaining = 0.5 - (_glfwPlatformGetTimerValue() - base) /
(double) _glfwPlatformGetTimerFrequency();
if (remaining <= 0.0)
if (!waitForEvent(&timeout))
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"X11: The window manager has a broken _NET_REQUEST_FRAME_EXTENTS implementation; please report this issue");
return;
}
timeout.tv_sec = 0;
timeout.tv_usec = (long) (remaining * 1e6);
selectDisplayConnection(&timeout);
}
}
@@ -1871,8 +1911,11 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window)
}
if (_glfwPlatformWindowIconified(window))
{
XMapWindow(_glfw.x11.display, window->x11.handle);
else
waitForVisibilityNotify(window);
}
else if (_glfwPlatformWindowVisible(window))
{
if (_glfw.x11.NET_WM_STATE &&
_glfw.x11.NET_WM_STATE_MAXIMIZED_VERT &&
@@ -1908,8 +1951,11 @@ void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
void _glfwPlatformShowWindow(_GLFWwindow* window)
{
if (_glfwPlatformWindowVisible(window))
return;
XMapWindow(_glfw.x11.display, window->x11.handle);
XFlush(_glfw.x11.display);
waitForVisibilityNotify(window);
}
void _glfwPlatformHideWindow(_GLFWwindow* window)
@@ -1926,7 +1972,7 @@ void _glfwPlatformFocusWindow(_GLFWwindow* window)
{
XRaiseWindow(_glfw.x11.display, window->x11.handle);
XSetInputFocus(_glfw.x11.display, window->x11.handle,
RevertToParent, CurrentTime);
RevertToParent, _glfw.x11.lastEventTime);
}
XFlush(_glfw.x11.display);
@@ -1964,7 +2010,8 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
if (window->monitor)
{
XMapRaised(_glfw.x11.display, window->x11.handle);
acquireMonitor(window);
if (waitForVisibilityNotify(window))
acquireMonitor(window);
}
else
{
@@ -2042,28 +2089,17 @@ void _glfwPlatformPollEvents(void)
void _glfwPlatformWaitEvents(void)
{
while (!XPending(_glfw.x11.display))
selectDisplayConnection(NULL);
waitForEvent(NULL);
_glfwPlatformPollEvents();
}
void _glfwPlatformWaitEventsTimeout(double timeout)
{
const double deadline = timeout + _glfwPlatformGetTimerValue() /
(double) _glfwPlatformGetTimerFrequency();
while (!XPending(_glfw.x11.display))
{
const double remaining = deadline - _glfwPlatformGetTimerValue() /
(double) _glfwPlatformGetTimerFrequency();
if (remaining <= 0.0)
return;
const long seconds = (long) remaining;
const long microseconds = (long) ((remaining - seconds) * 1e6);
struct timeval tv = { seconds, microseconds };
selectDisplayConnection(&tv);
if (!waitForEvent(&timeout))
break;
}
_glfwPlatformPollEvents();
@@ -2124,12 +2160,13 @@ void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
XGrabPointer(_glfw.x11.display, window->x11.handle, True,
ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
GrabModeAsync, GrabModeAsync,
window->x11.handle, _glfw.x11.cursor, CurrentTime);
window->x11.handle, _glfw.x11.cursor,
_glfw.x11.lastEventTime);
}
else if (_glfw.x11.disabledCursorWindow == window)
{
_glfw.x11.disabledCursorWindow = NULL;
XUngrabPointer(_glfw.x11.display, CurrentTime);
XUngrabPointer(_glfw.x11.display, _glfw.x11.lastEventTime);
_glfwPlatformSetCursorPos(window,
_glfw.x11.restoreCursorPosX,
_glfw.x11.restoreCursorPosY);
@@ -2214,7 +2251,8 @@ void _glfwPlatformSetClipboardString(_GLFWwindow* window, const char* string)
XSetSelectionOwner(_glfw.x11.display,
_glfw.x11.CLIPBOARD,
window->x11.handle, CurrentTime);
window->x11.handle,
_glfw.x11.lastEventTime);
if (XGetSelectionOwner(_glfw.x11.display, _glfw.x11.CLIPBOARD) !=
window->x11.handle)
@@ -2252,12 +2290,11 @@ const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
_glfw.x11.CLIPBOARD,
formats[i],
_glfw.x11.GLFW_SELECTION,
window->x11.handle, CurrentTime);
window->x11.handle,
_glfw.x11.lastEventTime);
// XCheckTypedEvent is used instead of XIfEvent in order not to lock
// other threads out from the display during the entire wait period
while (!XCheckTypedEvent(_glfw.x11.display, SelectionNotify, &event))
selectDisplayConnection(NULL);
waitForEvent(NULL);
if (event.xselection.property == None)
continue;
+1 -1
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 X11 - www.glfw.org
// GLFW 3.3 X11 - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2016 Camilla Berglund <elmindreda@glfw.org>
+1 -1
View File
@@ -1,5 +1,5 @@
//========================================================================
// GLFW 3.2 Linux - www.glfw.org
// GLFW 3.3 Linux - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com>
//
+3 -1
View File
@@ -48,7 +48,9 @@ set(CONSOLE_BINARIES clipboard events msaa gamma glfwinfo
if (VULKAN_FOUND)
add_executable(vulkan WIN32 vulkan.c ${ICON})
target_include_directories(vulkan PRIVATE "${VULKAN_INCLUDE_DIR}")
target_link_libraries(vulkan "${VULKAN_LIBRARY}")
if (NOT GLFW_VULKAN_STATIC)
target_link_libraries(vulkan "${VULKAN_LIBRARY}")
endif()
list(APPEND WINDOWS_BINARIES vulkan)
endif()
+3
View File
@@ -43,6 +43,9 @@ static GLfloat gamma_value = 1.0f;
static void usage(void)
{
printf("Usage: gamma [-h] [-f]\n");
printf("Options:\n");
printf(" -f create full screen window\n");
printf(" -h show this help\n");
}
static void set_gamma(GLFWwindow* window, float value)
+2 -3
View File
@@ -357,7 +357,7 @@ static void print_version(void)
int main(int argc, char** argv)
{
int ch, client, context, major, minor, revision, profile;
int ch, client, major, minor, revision, profile;
GLint redbits, greenbits, bluebits, alphabits, depthbits, stencilbits;
int list_extensions = GLFW_FALSE, list_layers = GLFW_FALSE;
GLenum error;
@@ -412,7 +412,7 @@ int main(int argc, char** argv)
if (!glfwInit())
exit(EXIT_FAILURE);
while ((ch = getopt_long(argc, argv, "a:b:dfhlm:n:p:s:v", options, NULL)) != -1)
while ((ch = getopt_long(argc, argv, "a:b:c:dfhlm:n:p:s:v", options, NULL)) != -1)
{
switch (ch)
{
@@ -636,7 +636,6 @@ int main(int argc, char** argv)
// Report client API version
client = glfwGetWindowAttrib(window, GLFW_CLIENT_API);
context = glfwGetWindowAttrib(window, GLFW_CONTEXT_CREATION_API);
major = glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MAJOR);
minor = glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MINOR);
revision = glfwGetWindowAttrib(window, GLFW_CONTEXT_REVISION);
+1 -1
View File
@@ -43,7 +43,7 @@ static double frame_rate;
static void usage(void)
{
printf("Usage: iconify [-h] [-f]\n");
printf("Usage: tearing [-h] [-f]\n");
printf("Options:\n");
printf(" -f create full screen window\n");
printf(" -h show this help\n");
+97 -97
View File
@@ -1,97 +1,97 @@
//========================================================================
// Event wait timeout test
// Copyright (c) Camilla Berglund <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.
//
//========================================================================
//
// This test is intended to verify that waiting for events with timeout works
//
//========================================================================
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
static void error_callback(int error, const char* description)
{
fprintf(stderr, "Error: %s\n", description);
}
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
glfwSetWindowShouldClose(window, GLFW_TRUE);
}
static float nrand(void)
{
return (float) rand() / (float) RAND_MAX;
}
int main(void)
{
GLFWwindow* window;
srand((unsigned int) time(NULL));
glfwSetErrorCallback(error_callback);
if (!glfwInit())
exit(EXIT_FAILURE);
window = glfwCreateWindow(640, 480, "Event Wait Timeout Test", NULL, NULL);
if (!window)
{
glfwTerminate();
exit(EXIT_FAILURE);
}
glfwMakeContextCurrent(window);
gladLoadGLLoader((GLADloadproc) glfwGetProcAddress);
glfwSetKeyCallback(window, key_callback);
while (!glfwWindowShouldClose(window))
{
int width, height;
float r = nrand(), g = nrand(), b = nrand();
float l = (float) sqrt(r * r + g * g + b * b);
glfwGetFramebufferSize(window, &width, &height);
glViewport(0, 0, width, height);
glClearColor(r / l, g / l, b / l, 1.f);
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(window);
glfwWaitEventsTimeout(1.0);
}
glfwDestroyWindow(window);
glfwTerminate();
exit(EXIT_SUCCESS);
}
//========================================================================
// Event wait timeout test
// Copyright (c) Camilla Berglund <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.
//
//========================================================================
//
// This test is intended to verify that waiting for events with timeout works
//
//========================================================================
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
static void error_callback(int error, const char* description)
{
fprintf(stderr, "Error: %s\n", description);
}
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
glfwSetWindowShouldClose(window, GLFW_TRUE);
}
static float nrand(void)
{
return (float) rand() / (float) RAND_MAX;
}
int main(void)
{
GLFWwindow* window;
srand((unsigned int) time(NULL));
glfwSetErrorCallback(error_callback);
if (!glfwInit())
exit(EXIT_FAILURE);
window = glfwCreateWindow(640, 480, "Event Wait Timeout Test", NULL, NULL);
if (!window)
{
glfwTerminate();
exit(EXIT_FAILURE);
}
glfwMakeContextCurrent(window);
gladLoadGLLoader((GLADloadproc) glfwGetProcAddress);
glfwSetKeyCallback(window, key_callback);
while (!glfwWindowShouldClose(window))
{
int width, height;
float r = nrand(), g = nrand(), b = nrand();
float l = (float) sqrt(r * r + g * g + b * b);
glfwGetFramebufferSize(window, &width, &height);
glViewport(0, 0, width, height);
glClearColor(r / l, g / l, b / l, 1.f);
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(window);
glfwWaitEventsTimeout(1.0);
}
glfwDestroyWindow(window);
glfwTerminate();
exit(EXIT_SUCCESS);
}