Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
liujiuri
engine
提交
a68209fe
E
engine
项目概览
liujiuri
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a68209fe
编写于
3月 25, 2016
作者:
A
Adam Barth
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2549 from abarth/glfw_32
Update to GLFW 3.2
上级
cd57083d
dfaf9182
变更
65
展开全部
隐藏空白更改
内联
并排
Showing
65 changed file
with
7735 addition
and
3567 deletion
+7735
-3567
sky/services/pointer/pointer.mojom
sky/services/pointer/pointer.mojom
+2
-0
sky/shell/BUILD.gn
sky/shell/BUILD.gn
+2
-0
sky/shell/platform/glfw/message_pump_glfw.cc
sky/shell/platform/glfw/message_pump_glfw.cc
+87
-0
sky/shell/platform/glfw/message_pump_glfw.h
sky/shell/platform/glfw/message_pump_glfw.h
+39
-0
sky/shell/platform/glfw/window_impl.cc
sky/shell/platform/glfw/window_impl.cc
+75
-1
sky/shell/platform/glfw/window_impl.h
sky/shell/platform/glfw/window_impl.h
+3
-0
sky/shell/platform/linux/main_linux.cc
sky/shell/platform/linux/main_linux.cc
+39
-14
third_party/glfw/BUILD.gn
third_party/glfw/BUILD.gn
+1
-0
third_party/glfw/README.flutter
third_party/glfw/README.flutter
+2
-2
third_party/glfw/include/GLFW/glfw3.h
third_party/glfw/include/GLFW/glfw3.h
+1362
-521
third_party/glfw/include/GLFW/glfw3native.h
third_party/glfw/include/GLFW/glfw3native.h
+171
-71
third_party/glfw/src/CMakeLists.txt
third_party/glfw/src/CMakeLists.txt
+58
-27
third_party/glfw/src/cocoa_init.m
third_party/glfw/src/cocoa_init.m
+43
-12
third_party/glfw/src/cocoa_joystick.h
third_party/glfw/src/cocoa_joystick.h
+15
-16
third_party/glfw/src/cocoa_joystick.m
third_party/glfw/src/cocoa_joystick.m
+88
-91
third_party/glfw/src/cocoa_monitor.m
third_party/glfw/src/cocoa_monitor.m
+13
-13
third_party/glfw/src/cocoa_platform.h
third_party/glfw/src/cocoa_platform.h
+24
-15
third_party/glfw/src/cocoa_time.c
third_party/glfw/src/cocoa_time.c
+7
-18
third_party/glfw/src/cocoa_window.m
third_party/glfw/src/cocoa_window.m
+477
-189
third_party/glfw/src/context.c
third_party/glfw/src/context.c
+94
-58
third_party/glfw/src/egl_context.c
third_party/glfw/src/egl_context.c
+205
-188
third_party/glfw/src/egl_context.h
third_party/glfw/src/egl_context.h
+115
-46
third_party/glfw/src/glfw3Config.cmake.in
third_party/glfw/src/glfw3Config.cmake.in
+1
-15
third_party/glfw/src/glfw_config.h.in
third_party/glfw/src/glfw_config.h.in
+1
-10
third_party/glfw/src/glx_context.c
third_party/glfw/src/glx_context.c
+175
-104
third_party/glfw/src/glx_context.h
third_party/glfw/src/glx_context.h
+95
-46
third_party/glfw/src/init.c
third_party/glfw/src/init.c
+17
-9
third_party/glfw/src/input.c
third_party/glfw/src/input.c
+76
-13
third_party/glfw/src/internal.h
third_party/glfw/src/internal.h
+288
-102
third_party/glfw/src/linux_joystick.c
third_party/glfw/src/linux_joystick.c
+79
-76
third_party/glfw/src/linux_joystick.h
third_party/glfw/src/linux_joystick.h
+22
-18
third_party/glfw/src/mir_init.c
third_party/glfw/src/mir_init.c
+147
-13
third_party/glfw/src/mir_monitor.c
third_party/glfw/src/mir_monitor.c
+14
-2
third_party/glfw/src/mir_platform.h
third_party/glfw/src/mir_platform.h
+26
-5
third_party/glfw/src/mir_window.c
third_party/glfw/src/mir_window.c
+189
-146
third_party/glfw/src/monitor.c
third_party/glfw/src/monitor.c
+44
-23
third_party/glfw/src/nsgl_context.h
third_party/glfw/src/nsgl_context.h
+9
-9
third_party/glfw/src/nsgl_context.m
third_party/glfw/src/nsgl_context.m
+41
-48
third_party/glfw/src/posix_time.c
third_party/glfw/src/posix_time.c
+23
-35
third_party/glfw/src/posix_time.h
third_party/glfw/src/posix_time.h
+4
-5
third_party/glfw/src/posix_tls.c
third_party/glfw/src/posix_tls.c
+13
-11
third_party/glfw/src/posix_tls.h
third_party/glfw/src/posix_tls.h
+4
-4
third_party/glfw/src/vulkan.c
third_party/glfw/src/vulkan.c
+287
-0
third_party/glfw/src/wgl_context.c
third_party/glfw/src/wgl_context.c
+188
-162
third_party/glfw/src/wgl_context.h
third_party/glfw/src/wgl_context.h
+97
-47
third_party/glfw/src/win32_init.c
third_party/glfw/src/win32_init.c
+99
-54
third_party/glfw/src/win32_joystick.c
third_party/glfw/src/win32_joystick.c
+11
-11
third_party/glfw/src/win32_joystick.h
third_party/glfw/src/win32_joystick.h
+10
-10
third_party/glfw/src/win32_monitor.c
third_party/glfw/src/win32_monitor.c
+116
-72
third_party/glfw/src/win32_platform.h
third_party/glfw/src/win32_platform.h
+84
-22
third_party/glfw/src/win32_time.c
third_party/glfw/src/win32_time.c
+18
-30
third_party/glfw/src/win32_tls.c
third_party/glfw/src/win32_tls.c
+11
-11
third_party/glfw/src/win32_tls.h
third_party/glfw/src/win32_tls.h
+0
-48
third_party/glfw/src/win32_window.c
third_party/glfw/src/win32_window.c
+703
-327
third_party/glfw/src/window.c
third_party/glfw/src/window.c
+247
-78
third_party/glfw/src/wl_init.c
third_party/glfw/src/wl_init.c
+174
-150
third_party/glfw/src/wl_monitor.c
third_party/glfw/src/wl_monitor.c
+22
-5
third_party/glfw/src/wl_platform.h
third_party/glfw/src/wl_platform.h
+49
-8
third_party/glfw/src/wl_window.c
third_party/glfw/src/wl_window.c
+451
-45
third_party/glfw/src/x11_init.c
third_party/glfw/src/x11_init.c
+113
-87
third_party/glfw/src/x11_monitor.c
third_party/glfw/src/x11_monitor.c
+9
-9
third_party/glfw/src/x11_platform.h
third_party/glfw/src/x11_platform.h
+70
-36
third_party/glfw/src/x11_window.c
third_party/glfw/src/x11_window.c
+766
-359
third_party/glfw/src/xkb_unicode.c
third_party/glfw/src/xkb_unicode.c
+19
-19
third_party/glfw/src/xkb_unicode.h
third_party/glfw/src/xkb_unicode.h
+1
-1
未找到文件。
sky/services/pointer/pointer.mojom
浏览文件 @
a68209fe
...
...
@@ -5,6 +5,8 @@
[DartPackage="sky_services"]
module pointer;
// See https://github.com/flutter/engine/blob/master/sky/specs/pointer.md
enum PointerType {
DOWN,
UP,
...
...
sky/shell/BUILD.gn
浏览文件 @
a68209fe
...
...
@@ -417,6 +417,8 @@ if (is_android) {
sources += [
"//sky/shell/platform/glfw/init_glfw.cc",
"//sky/shell/platform/glfw/init_glfw.h",
"//sky/shell/platform/glfw/message_pump_glfw.cc",
"//sky/shell/platform/glfw/message_pump_glfw.h",
"//sky/shell/platform/glfw/platform_view_glfw.cc",
"//sky/shell/platform/glfw/platform_view_glfw.h",
"//sky/shell/platform/glfw/window_impl.cc",
...
...
sky/shell/platform/glfw/message_pump_glfw.cc
0 → 100644
浏览文件 @
a68209fe
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "sky/shell/platform/glfw/message_pump_glfw.h"
#include <GLFW/glfw3.h>
#include "base/auto_reset.h"
#include "base/logging.h"
#include "base/time/time.h"
namespace
sky
{
namespace
shell
{
MessagePumpGLFW
::
MessagePumpGLFW
()
:
in_run_
(
false
),
should_quit_
(
false
)
{
}
MessagePumpGLFW
::~
MessagePumpGLFW
()
{
}
// static
scoped_ptr
<
base
::
MessagePump
>
MessagePumpGLFW
::
Create
()
{
return
scoped_ptr
<
MessagePump
>
(
new
MessagePumpGLFW
());
}
void
MessagePumpGLFW
::
Run
(
Delegate
*
delegate
)
{
base
::
AutoReset
<
bool
>
auto_reset_keep_running
(
&
should_quit_
,
false
);
base
::
AutoReset
<
bool
>
auto_reset_in_run
(
&
in_run_
,
true
);
for
(;;)
{
bool
did_work
=
delegate
->
DoWork
();
if
(
should_quit_
)
break
;
did_work
|=
delegate
->
DoDelayedWork
(
&
delayed_work_time_
);
if
(
should_quit_
)
break
;
if
(
did_work
)
continue
;
did_work
=
delegate
->
DoIdleWork
();
if
(
should_quit_
)
break
;
if
(
did_work
)
continue
;
if
(
delayed_work_time_
.
is_null
())
{
glfwPollEvents
();
}
else
{
base
::
TimeDelta
delay
=
delayed_work_time_
-
base
::
TimeTicks
::
Now
();
if
(
delay
>
base
::
TimeDelta
())
{
glfwWaitEventsTimeout
(
delay
.
InSecondsF
());
}
else
{
// It looks like delayed_work_time_ indicates a time in the past, so we
// need to call DoDelayedWork now.
delayed_work_time_
=
base
::
TimeTicks
();
}
}
if
(
should_quit_
)
break
;
}
}
void
MessagePumpGLFW
::
Quit
()
{
DCHECK
(
in_run_
)
<<
"Quit was called outside of Run!"
;
should_quit_
=
true
;
ScheduleWork
();
}
void
MessagePumpGLFW
::
ScheduleWork
()
{
glfwPostEmptyEvent
();
}
void
MessagePumpGLFW
::
ScheduleDelayedWork
(
const
base
::
TimeTicks
&
delayed_work_time
)
{
// We know that we can't be blocked on Wait right now since this method can
// only be called on the same thread as Run, so we only need to update our
// record of how long to sleep when we do sleep.
delayed_work_time_
=
delayed_work_time
;
}
}
// namespace shell
}
// namespace sky
sky/shell/platform/glfw/message_pump_glfw.h
0 → 100644
浏览文件 @
a68209fe
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SKY_SHELL_PLATFORM_GLFW_MESSAGE_PUMP_GLFW_H_
#define SKY_SHELL_PLATFORM_GLFW_MESSAGE_PUMP_GLFW_H_
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_pump.h"
#include "base/time/time.h"
namespace
sky
{
namespace
shell
{
class
MessagePumpGLFW
:
public
base
::
MessagePump
{
public:
MessagePumpGLFW
();
~
MessagePumpGLFW
()
override
;
static
scoped_ptr
<
base
::
MessagePump
>
Create
();
// MessagePump methods:
void
Run
(
Delegate
*
delegate
)
override
;
void
Quit
()
override
;
void
ScheduleWork
()
override
;
void
ScheduleDelayedWork
(
const
base
::
TimeTicks
&
delayed_work_time
)
override
;
private:
bool
in_run_
;
bool
should_quit_
;
base
::
TimeTicks
delayed_work_time_
;
DISALLOW_COPY_AND_ASSIGN
(
MessagePumpGLFW
);
};
}
// namespace shell
}
// namespace sky
#endif // SKY_SHELL_PLATFORM_GLFW_MESSAGE_PUMP_GLFW_H_
sky/shell/platform/glfw/window_impl.cc
浏览文件 @
a68209fe
...
...
@@ -21,11 +21,20 @@ void OnWindowSizeChanged(GLFWwindow* window, int width, int height) {
ToImpl
(
window
)
->
UpdateViewportMetrics
(
width
,
height
);
}
void
OnMouseButtonChanged
(
GLFWwindow
*
window
,
int
button
,
int
action
,
int
mods
)
{
ToImpl
(
window
)
->
DispatchMouseButtonEvent
(
button
,
action
,
mods
);
}
void
OnCursorPosChanged
(
GLFWwindow
*
window
,
double
x
,
double
y
)
{
ToImpl
(
window
)
->
DispatchMouseMoveEvent
(
x
,
y
);
}
}
// namespace
WindowImpl
::
WindowImpl
(
GLFWwindow
*
window
)
:
window_
(
window
),
shell_view_
(
new
ShellView
(
Shell
::
Shared
()))
{
shell_view_
(
new
ShellView
(
Shell
::
Shared
())),
buttons_
(
0
)
{
glfwSetWindowUserPointer
(
window_
,
this
);
auto
platform_view
=
static_cast
<
sky
::
shell
::
PlatformViewGLFW
*>
(
shell_view_
->
view
());
...
...
@@ -38,6 +47,7 @@ WindowImpl::WindowImpl(GLFWwindow* window)
UpdateViewportMetrics
(
width
,
height
);
glfwSetWindowSizeCallback
(
window_
,
OnWindowSizeChanged
);
glfwSetMouseButtonCallback
(
window_
,
OnMouseButtonChanged
);
}
WindowImpl
::~
WindowImpl
()
{
...
...
@@ -61,5 +71,69 @@ void WindowImpl::UpdateViewportMetrics(int width, int height) {
engine_
->
OnViewportMetricsChanged
(
metrics
.
Pass
());
}
void
WindowImpl
::
DispatchMouseButtonEvent
(
int
button
,
int
action
,
int
mods
)
{
pointer
::
PointerType
type
;
if
(
action
==
GLFW_PRESS
)
{
if
(
!
buttons_
)
{
type
=
pointer
::
PointerType
::
DOWN
;
glfwSetCursorPosCallback
(
window_
,
OnCursorPosChanged
);
}
else
{
type
=
pointer
::
PointerType
::
MOVE
;
}
// GLFW's button order matches what we want:
// https://github.com/flutter/engine/blob/master/sky/specs/pointer.md
// http://www.glfw.org/docs/3.2/group__buttons.html
buttons_
|=
1
<<
button
;
}
else
if
(
action
==
GLFW_RELEASE
)
{
buttons_
&=
~
(
1
<<
button
);
if
(
!
buttons_
)
{
type
=
pointer
::
PointerType
::
UP
;
glfwSetCursorPosCallback
(
window_
,
nullptr
);
}
else
{
type
=
pointer
::
PointerType
::
MOVE
;
}
}
else
{
DLOG
(
INFO
)
<<
"Unknown mouse action: "
<<
action
;
return
;
}
double
x
=
0.
f
,
y
=
0.
f
;
glfwGetCursorPos
(
window_
,
&
x
,
&
y
);
base
::
TimeDelta
time_stamp
=
base
::
TimeTicks
::
Now
()
-
base
::
TimeTicks
();
auto
pointer_data
=
pointer
::
Pointer
::
New
();
pointer_data
->
time_stamp
=
time_stamp
.
InMicroseconds
();
pointer_data
->
type
=
type
;
pointer_data
->
kind
=
pointer
::
PointerKind
::
MOUSE
;
pointer_data
->
x
=
x
;
pointer_data
->
y
=
y
;
pointer_data
->
buttons
=
buttons_
;
pointer_data
->
pressure
=
1.0
;
pointer_data
->
pressure_max
=
1.0
;
auto
pointer_packet
=
pointer
::
PointerPacket
::
New
();
pointer_packet
->
pointers
.
push_back
(
pointer_data
.
Pass
());
engine_
->
OnPointerPacket
(
pointer_packet
.
Pass
());
}
void
WindowImpl
::
DispatchMouseMoveEvent
(
double
x
,
double
y
)
{
base
::
TimeDelta
time_stamp
=
base
::
TimeTicks
::
Now
()
-
base
::
TimeTicks
();
auto
pointer_data
=
pointer
::
Pointer
::
New
();
pointer_data
->
time_stamp
=
time_stamp
.
InMicroseconds
();
pointer_data
->
type
=
pointer
::
PointerType
::
MOVE
;
pointer_data
->
kind
=
pointer
::
PointerKind
::
MOUSE
;
pointer_data
->
x
=
x
;
pointer_data
->
y
=
y
;
pointer_data
->
buttons
=
buttons_
;
pointer_data
->
pressure
=
1.0
;
pointer_data
->
pressure_max
=
1.0
;
auto
pointer_packet
=
pointer
::
PointerPacket
::
New
();
pointer_packet
->
pointers
.
push_back
(
pointer_data
.
Pass
());
engine_
->
OnPointerPacket
(
pointer_packet
.
Pass
());
}
}
// namespace shell
}
// namespace sky
sky/shell/platform/glfw/window_impl.h
浏览文件 @
a68209fe
...
...
@@ -24,11 +24,14 @@ class WindowImpl {
const
std
::
string
&
bundle_path
);
void
UpdateViewportMetrics
(
int
width
,
int
height
);
void
DispatchMouseButtonEvent
(
int
button
,
int
action
,
int
mods
);
void
DispatchMouseMoveEvent
(
double
x
,
double
y
);
private:
GLFWwindow
*
window_
;
std
::
unique_ptr
<
ShellView
>
shell_view_
;
sky
::
SkyEnginePtr
engine_
;
int
buttons_
;
DISALLOW_COPY_AND_ASSIGN
(
WindowImpl
);
};
...
...
sky/shell/platform/linux/main_linux.cc
浏览文件 @
a68209fe
...
...
@@ -16,8 +16,43 @@
#if defined(USE_GLFW)
#include "sky/shell/platform/glfw/init_glfw.h"
#include "sky/shell/platform/glfw/message_pump_glfw.h"
#endif
namespace
{
int
RunNonInteractive
()
{
base
::
MessageLoop
message_loop
;
mojo
::
embedder
::
Init
(
mojo
::
embedder
::
CreateSimplePlatformSupport
());
sky
::
shell
::
Shell
::
InitStandalone
();
if
(
!
sky
::
shell
::
InitForTesting
())
{
sky
::
shell
::
switches
::
PrintUsage
(
"sky_shell"
);
return
1
;
}
message_loop
.
Run
();
return
0
;
}
#if defined(USE_GLFW)
int
RunInteractive
()
{
base
::
MessageLoop
message_loop
(
sky
::
shell
::
MessagePumpGLFW
::
Create
());
mojo
::
embedder
::
Init
(
mojo
::
embedder
::
CreateSimplePlatformSupport
());
sky
::
shell
::
Shell
::
InitStandalone
();
if
(
!
sky
::
shell
::
InitInteractive
())
return
1
;
message_loop
.
Run
();
return
0
;
}
#endif // defined(USE_GLFW)
}
// namespace
int
main
(
int
argc
,
const
char
*
argv
[])
{
base
::
AtExitManager
exit_manager
;
base
::
CommandLine
::
Init
(
argc
,
argv
);
...
...
@@ -29,21 +64,11 @@ int main(int argc, const char* argv[]) {
return
0
;
}
base
::
MessageLoop
message_loop
;
mojo
::
embedder
::
Init
(
mojo
::
embedder
::
CreateSimplePlatformSupport
());
sky
::
shell
::
Shell
::
InitStandalone
();
bool
running
=
false
;
#if defined(USE_GLFW)
if
(
!
command_line
.
HasSwitch
(
sky
::
shell
::
switches
::
kNonInteractive
))
running
=
sky
::
shell
::
InitInteractive
();
if
(
command_line
.
HasSwitch
(
sky
::
shell
::
switches
::
kNonInteractive
))
return
RunNonInteractive
();
return
RunInteractive
();
#endif
if
(
!
running
&&
!
sky
::
shell
::
InitForTesting
())
{
sky
::
shell
::
switches
::
PrintUsage
(
"sky_shell"
);
return
1
;
}
message_loop
.
Run
();
return
0
;
return
RunNonInteractive
();
}
third_party/glfw/BUILD.gn
浏览文件 @
a68209fe
...
...
@@ -21,6 +21,7 @@ source_set("glfw") {
"src/posix_time.h",
"src/posix_tls.c",
"src/posix_tls.h",
"src/vulkan.c",
"src/window.c",
"src/x11_init.c",
"src/x11_monitor.c",
...
...
third_party/glfw/README.flutter
浏览文件 @
a68209fe
glfw 3.
1.
2
glfw 3.2
==========
Imported from https://github.com/glfw/glfw.git@3
0306e54705c3adae9fe082c816a3be71963485c
Imported from https://github.com/glfw/glfw.git@3
503cba5d9df2976fa94eeaf852e15f987a00fa0
third_party/glfw/include/GLFW/glfw3.h
浏览文件 @
a68209fe
此差异已折叠。
点击以展开。
third_party/glfw/include/GLFW/glfw3native.h
浏览文件 @
a68209fe
/*************************************************************************
* GLFW 3.
1
- www.glfw.org
* GLFW 3.
2
- www.glfw.org
* A library for OpenGL, window and input
*------------------------------------------------------------------------
* Copyright (c) 2002-2006 Marcus Geelnard
...
...
@@ -38,20 +38,30 @@ extern "C" {
* Doxygen documentation
*************************************************************************/
/*! @file glfw3native.h
* @brief The header of the native access functions.
*
* This is the header file of the native access functions. See @ref native for
* more information.
*/
/*! @defgroup native Native access
*
* **By using the native access functions you assert that you know what you're
* doing and how to fix problems caused by using them. If you don't, you
* shouldn't be using them.**
*
* Before the inclusion of @ref glfw3native.h, you must define exactly one
* window system API macro and exactly one context creation API macro. Failure
* to do this will cause a compile-time error.
* Before the inclusion of @ref glfw3native.h, you may define exactly one
* window system API macro and zero or more context creation API macros.
*
* The chosen backends must match those the library was compiled for. Failure
* to do this will cause a link-time error.
*
* The available window API macros are:
* * `GLFW_EXPOSE_NATIVE_WIN32`
* * `GLFW_EXPOSE_NATIVE_COCOA`
* * `GLFW_EXPOSE_NATIVE_X11`
* * `GLFW_EXPOSE_NATIVE_WAYLAND`
* * `GLFW_EXPOSE_NATIVE_MIR`
*
* The available context API macros are:
* * `GLFW_EXPOSE_NATIVE_WGL`
...
...
@@ -86,20 +96,23 @@ extern "C" {
#elif defined(GLFW_EXPOSE_NATIVE_X11)
#include <X11/Xlib.h>
#include <X11/extensions/Xrandr.h>
#else
#error "No window API selected"
#elif defined(GLFW_EXPOSE_NATIVE_WAYLAND)
#include <wayland-client.h>
#elif defined(GLFW_EXPOSE_NATIVE_MIR)
#include <mir_toolkit/mir_client_library.h>
#endif
#if defined(GLFW_EXPOSE_NATIVE_WGL)
/* WGL is declared by windows.h */
#elif defined(GLFW_EXPOSE_NATIVE_NSGL)
#endif
#if defined(GLFW_EXPOSE_NATIVE_NSGL)
/* NSGL is declared by Cocoa.h */
#elif defined(GLFW_EXPOSE_NATIVE_GLX)
#endif
#if defined(GLFW_EXPOSE_NATIVE_GLX)
#include <GL/glx.h>
#elif defined(GLFW_EXPOSE_NATIVE_EGL)
#endif
#if defined(GLFW_EXPOSE_NATIVE_EGL)
#include <EGL/egl.h>
#else
#error "No context API selected"
#endif
...
...
@@ -114,11 +127,10 @@ extern "C" {
* of the specified monitor, or `NULL` if an [error](@ref error_handling)
* occurred.
*
* @
par Thread Safety
*
This function may be called from any thread. Access is not
synchronized.
* @
thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @par History
* Added in GLFW 3.1.
* @since Added in version 3.1.
*
* @ingroup native
*/
...
...
@@ -130,11 +142,10 @@ GLFWAPI const char* glfwGetWin32Adapter(GLFWmonitor* monitor);
* `\\.\DISPLAY1\Monitor0`) of the specified monitor, or `NULL` if an
* [error](@ref error_handling) occurred.
*
* @
par Thread Safety
*
This function may be called from any thread. Access is not
synchronized.
* @
thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @par History
* Added in GLFW 3.1.
* @since Added in version 3.1.
*
* @ingroup native
*/
...
...
@@ -145,11 +156,10 @@ GLFWAPI const char* glfwGetWin32Monitor(GLFWmonitor* monitor);
* @return The `HWND` of the specified window, or `NULL` if an
* [error](@ref error_handling) occurred.
*
* @
par Thread Safety
*
This function may be called from any thread. Access is not
synchronized.
* @
thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @par History
* Added in GLFW 3.0.
* @since Added in version 3.0.
*
* @ingroup native
*/
...
...
@@ -162,11 +172,10 @@ GLFWAPI HWND glfwGetWin32Window(GLFWwindow* window);
* @return The `HGLRC` of the specified window, or `NULL` if an
* [error](@ref error_handling) occurred.
*
* @
par Thread Safety
*
This function may be called from any thread. Access is not
synchronized.
* @
thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @par History
* Added in GLFW 3.0.
* @since Added in version 3.0.
*
* @ingroup native
*/
...
...
@@ -179,11 +188,10 @@ GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* window);
* @return The `CGDirectDisplayID` of the specified monitor, or
* `kCGNullDirectDisplay` if an [error](@ref error_handling) occurred.
*
* @
par Thread Safety
*
This function may be called from any thread. Access is not
synchronized.
* @
thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @par History
* Added in GLFW 3.1.
* @since Added in version 3.1.
*
* @ingroup native
*/
...
...
@@ -194,11 +202,10 @@ GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* monitor);
* @return The `NSWindow` of the specified window, or `nil` if an
* [error](@ref error_handling) occurred.
*
* @
par Thread Safety
*
This function may be called from any thread. Access is not
synchronized.
* @
thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @par History
* Added in GLFW 3.0.
* @since Added in version 3.0.
*
* @ingroup native
*/
...
...
@@ -211,11 +218,10 @@ GLFWAPI id glfwGetCocoaWindow(GLFWwindow* window);
* @return The `NSOpenGLContext` of the specified window, or `nil` if an
* [error](@ref error_handling) occurred.
*
* @
par Thread Safety
*
This function may be called from any thread. Access is not
synchronized.
* @
thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @par History
* Added in GLFW 3.0.
* @since Added in version 3.0.
*
* @ingroup native
*/
...
...
@@ -228,11 +234,10 @@ GLFWAPI id glfwGetNSGLContext(GLFWwindow* window);
* @return The `Display` used by GLFW, or `NULL` if an
* [error](@ref error_handling) occurred.
*
* @
par Thread Safety
*
This function may be called from any thread. Access is not
synchronized.
* @
thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @par History
* Added in GLFW 3.0.
* @since Added in version 3.0.
*
* @ingroup native
*/
...
...
@@ -243,11 +248,10 @@ GLFWAPI Display* glfwGetX11Display(void);
* @return The `RRCrtc` of the specified monitor, or `None` if an
* [error](@ref error_handling) occurred.
*
* @
par Thread Safety
*
This function may be called from any thread. Access is not
synchronized.
* @
thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @par History
* Added in GLFW 3.1.
* @since Added in version 3.1.
*
* @ingroup native
*/
...
...
@@ -258,11 +262,10 @@ GLFWAPI RRCrtc glfwGetX11Adapter(GLFWmonitor* monitor);
* @return The `RROutput` of the specified monitor, or `None` if an
* [error](@ref error_handling) occurred.
*
* @
par Thread Safety
*
This function may be called from any thread. Access is not
synchronized.
* @
thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @par History
* Added in GLFW 3.1.
* @since Added in version 3.1.
*
* @ingroup native
*/
...
...
@@ -273,11 +276,10 @@ GLFWAPI RROutput glfwGetX11Monitor(GLFWmonitor* monitor);
* @return The `Window` of the specified window, or `None` if an
* [error](@ref error_handling) occurred.
*
* @
par Thread Safety
*
This function may be called from any thread. Access is not
synchronized.
* @
thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @par History
* Added in GLFW 3.0.
* @since Added in version 3.0.
*
* @ingroup native
*/
...
...
@@ -290,15 +292,116 @@ GLFWAPI Window glfwGetX11Window(GLFWwindow* window);
* @return The `GLXContext` of the specified window, or `NULL` if an
* [error](@ref error_handling) occurred.
*
* @
par Thread Safety
*
This function may be called from any thread. Access is not
synchronized.
* @
thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @par History
* Added in GLFW 3.0.
* @since Added in version 3.0.
*
* @ingroup native
*/
GLFWAPI
GLXContext
glfwGetGLXContext
(
GLFWwindow
*
window
);
/*! @brief Returns the `GLXWindow` of the specified window.
*
* @return The `GLXWindow` of the specified window, or `None` if an
* [error](@ref error_handling) occurred.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.2.
*
* @ingroup native
*/
GLFWAPI
GLXWindow
glfwGetGLXWindow
(
GLFWwindow
*
window
);
#endif
#if defined(GLFW_EXPOSE_NATIVE_WAYLAND)
/*! @brief Returns the `struct wl_display*` used by GLFW.
*
* @return The `struct wl_display*` used by GLFW, or `NULL` if an
* [error](@ref error_handling) occurred.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.2.
*
* @ingroup native
*/
GLFWAPI
struct
wl_display
*
glfwGetWaylandDisplay
(
void
);
/*! @brief Returns the `struct wl_output*` of the specified monitor.
*
* @return The `struct wl_output*` of the specified monitor, or `NULL` if an
* [error](@ref error_handling) occurred.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.2.
*
* @ingroup native
*/
GLFWAPI
struct
wl_output
*
glfwGetWaylandMonitor
(
GLFWmonitor
*
monitor
);
/*! @brief Returns the main `struct wl_surface*` of the specified window.
*
* @return The main `struct wl_surface*` of the specified window, or `NULL` if
* an [error](@ref error_handling) occurred.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.2.
*
* @ingroup native
*/
GLFWAPI
struct
wl_surface
*
glfwGetWaylandWindow
(
GLFWwindow
*
window
);
#endif
#if defined(GLFW_EXPOSE_NATIVE_MIR)
/*! @brief Returns the `MirConnection*` used by GLFW.
*
* @return The `MirConnection*` used by GLFW, or `NULL` if an
* [error](@ref error_handling) occurred.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.2.
*
* @ingroup native
*/
GLFWAPI
MirConnection
*
glfwGetMirDisplay
(
void
);
/*! @brief Returns the Mir output ID of the specified monitor.
*
* @return The Mir output ID of the specified monitor, or zero if an
* [error](@ref error_handling) occurred.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.2.
*
* @ingroup native
*/
GLFWAPI
int
glfwGetMirMonitor
(
GLFWmonitor
*
monitor
);
/*! @brief Returns the `MirSurface*` of the specified window.
*
* @return The `MirSurface*` of the specified window, or `NULL` if an
* [error](@ref error_handling) occurred.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.2.
*
* @ingroup native
*/
GLFWAPI
MirSurface
*
glfwGetMirWindow
(
GLFWwindow
*
window
);
#endif
#if defined(GLFW_EXPOSE_NATIVE_EGL)
...
...
@@ -307,11 +410,10 @@ GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* window);
* @return The `EGLDisplay` used by GLFW, or `EGL_NO_DISPLAY` if an
* [error](@ref error_handling) occurred.
*
* @
par Thread Safety
*
This function may be called from any thread. Access is not
synchronized.
* @
thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @par History
* Added in GLFW 3.0.
* @since Added in version 3.0.
*
* @ingroup native
*/
...
...
@@ -322,11 +424,10 @@ GLFWAPI EGLDisplay glfwGetEGLDisplay(void);
* @return The `EGLContext` of the specified window, or `EGL_NO_CONTEXT` if an
* [error](@ref error_handling) occurred.
*
* @
par Thread Safety
*
This function may be called from any thread. Access is not
synchronized.
* @
thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @par History
* Added in GLFW 3.0.
* @since Added in version 3.0.
*
* @ingroup native
*/
...
...
@@ -337,11 +438,10 @@ GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* window);
* @return The `EGLSurface` of the specified window, or `EGL_NO_SURFACE` if an
* [error](@ref error_handling) occurred.
*
* @
par Thread Safety
*
This function may be called from any thread. Access is not
synchronized.
* @
thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @par History
* Added in GLFW 3.0.
* @since Added in version 3.0.
*
* @ingroup native
*/
...
...
third_party/glfw/src/CMakeLists.txt
浏览文件 @
a68209fe
include_directories
(
"
${
GLFW_SOURCE_DIR
}
/src"
"
${
GLFW_BINARY_DIR
}
/src"
${
glfw_INCLUDE_DIRS
}
)
add_definitions
(
-D_GLFW_USE_CONFIG_H
)
set
(
common_HEADERS internal.h
"
${
GLFW_BINARY_DIR
}
/src/glfw_config.h"
"
${
GLFW_SOURCE_DIR
}
/include/GLFW/glfw3.h"
"
${
GLFW_SOURCE_DIR
}
/include/GLFW/glfw3native.h"
)
set
(
common_SOURCES context.c init.c input.c monitor.c window.c
)
set
(
common_SOURCES context.c init.c input.c monitor.c
vulkan.c
window.c
)
if
(
_GLFW_COCOA
)
set
(
glfw_HEADERS
${
common_HEADERS
}
cocoa_platform.h
iokit
_joystick.h
set
(
glfw_HEADERS
${
common_HEADERS
}
cocoa_platform.h
cocoa
_joystick.h
posix_tls.h
)
set
(
glfw_SOURCES
${
common_SOURCES
}
cocoa_init.m cocoa_
monitor
.m
cocoa_
window.m iokit_joystick.m mach
_time.c posix_tls.c
)
set
(
glfw_SOURCES
${
common_SOURCES
}
cocoa_init.m cocoa_
joystick
.m
cocoa_
monitor.m cocoa_window.m cocoa
_time.c posix_tls.c
)
elseif
(
_GLFW_WIN32
)
set
(
glfw_HEADERS
${
common_HEADERS
}
win32_platform.h win32_tls.h
winmm_joystick.h
)
set
(
glfw_SOURCES
${
common_SOURCES
}
win32_init.c win32_monitor.c win32_time.c
win32_tls.c win32_window.c winmm_joystick.c
)
set
(
glfw_HEADERS
${
common_HEADERS
}
win32_platform.h win32_joystick.h
)
set
(
glfw_SOURCES
${
common_SOURCES
}
win32_init.c win32_joystick.c
win32_monitor.c win32_time.c win32_tls.c win32_window.c
)
elseif
(
_GLFW_X11
)
set
(
glfw_HEADERS
${
common_HEADERS
}
x11_platform.h xkb_unicode.h
linux_joystick.h posix_time.h posix_tls.h
)
...
...
@@ -31,6 +24,15 @@ elseif (_GLFW_WAYLAND)
posix_time.h posix_tls.h xkb_unicode.h
)
set
(
glfw_SOURCES
${
common_SOURCES
}
wl_init.c wl_monitor.c wl_window.c
linux_joystick.c posix_time.c posix_tls.c xkb_unicode.c
)
ecm_add_wayland_client_protocol
(
glfw_SOURCES
PROTOCOL
${
WAYLAND_PROTOCOLS_PKGDATADIR
}
/unstable/relative-pointer/relative-pointer-unstable-v1.xml
BASENAME relative-pointer-unstable-v1
)
ecm_add_wayland_client_protocol
(
glfw_SOURCES
PROTOCOL
${
WAYLAND_PROTOCOLS_PKGDATADIR
}
/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml
BASENAME pointer-constraints-unstable-v1
)
elseif
(
_GLFW_MIR
)
set
(
glfw_HEADERS
${
common_HEADERS
}
mir_platform.h linux_joystick.h
posix_time.h posix_tls.h xkb_unicode.h
)
...
...
@@ -59,35 +61,64 @@ endif()
add_library
(
glfw
${
glfw_SOURCES
}
${
glfw_HEADERS
}
)
set_target_properties
(
glfw PROPERTIES
OUTPUT_NAME
"
${
GLFW_LIB_NAME
}
"
OUTPUT_NAME
${
GLFW_LIB_NAME
}
VERSION
${
GLFW_VERSION
}
SOVERSION
${
GLFW_VERSION_MAJOR
}
POSITION_INDEPENDENT_CODE ON
FOLDER
"GLFW3"
)
target_compile_definitions
(
glfw PRIVATE -D_GLFW_USE_CONFIG_H
)
target_include_directories
(
glfw PUBLIC
$<BUILD_INTERFACE:
${
GLFW_SOURCE_DIR
}
/include>
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>
)
target_include_directories
(
glfw PRIVATE
"
${
GLFW_SOURCE_DIR
}
/src"
"
${
GLFW_BINARY_DIR
}
/src"
${
glfw_INCLUDE_DIRS
}
)
# HACK: When building on MinGW, WINVER and UNICODE need to be defined before
# the inclusion of stddef.h (by glfw3.h), which is itself included before
# win32_platform.h. We define them here until a saner solution can be found
# NOTE: MinGW-w64 and Visual C++ do /not/ need this hack.
target_compile_definitions
(
glfw PRIVATE
"$<$<BOOL:
${
MINGW
}
>:UNICODE;WINVER=0x0501>"
)
# Enable a reasonable set of warnings (no, -Wextra is not reasonable)
target_compile_options
(
glfw PRIVATE
"$<$<C_COMPILER_ID:Clang>:-Wall>"
"$<$<C_COMPILER_ID:GNU>:-Wall>"
)
if
(
BUILD_SHARED_LIBS
)
if
(
WIN32
)
# The GLFW DLL needs a special compile-time macro and import library name
set_target_properties
(
glfw PROPERTIES PREFIX
""
IMPORT_PREFIX
""
)
if
(
MINGW
)
# Remove the lib prefix on the DLL (but not the import library
set_target_properties
(
glfw PROPERTIES PREFIX
""
)
# Add a suffix to the import library to avoid naming conflicts
set_target_properties
(
glfw PROPERTIES IMPORT_SUFFIX
"dll.a"
)
else
()
# Add a suffix to the import library to avoid naming conflicts
set_target_properties
(
glfw PROPERTIES IMPORT_SUFFIX
"dll.lib"
)
endif
()
elseif
(
APPLE
)
# Append -fno-common to the compile flags to work around a bug in
# Apple's GCC
get_target_property
(
glfw_CFLAGS glfw COMPILE_FLAGS
)
if
(
NOT glfw_CFLAGS
)
set
(
glfw_CFLAGS
""
)
endif
()
# Add -fno-common to work around a bug in Apple's GCC
target_compile_options
(
glfw PRIVATE
"-fno-common"
)
set_target_properties
(
glfw PROPERTIES
COMPILE_FLAGS
"
${
glfw_CFLAGS
}
-fno-common"
INSTALL_NAME_DIR
"
${
CMAKE_INSTALL_PREFIX
}
/lib
${
LIB_SUFFIX
}
"
)
INSTALL_NAME_DIR
"lib
${
LIB_SUFFIX
}
"
)
elseif
(
UNIX
)
# Hide symbols not explicitly tagged for export from the shared library
target_compile_options
(
glfw PRIVATE
"-fvisibility=hidden"
)
endif
()
target_link_libraries
(
glfw
${
glfw_LIBRARIES
}
)
target_compile_definitions
(
glfw INTERFACE -DGLFW_DLL
)
target_link_libraries
(
glfw PRIVATE
${
glfw_LIBRARIES
}
)
else
()
target_link_libraries
(
glfw INTERFACE
${
glfw_LIBRARIES
}
)
endif
()
if
(
MSVC
)
target_compile_definitions
(
glfw PRIVATE _CRT_SECURE_NO_WARNINGS
)
endif
()
if
(
GLFW_INSTALL
)
...
...
third_party/glfw/src/cocoa_init.m
浏览文件 @
a68209fe
//========================================================================
// GLFW 3.
1
OS X - www.glfw.org
// GLFW 3.
2
OS X - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2009-2010 Camilla Berglund
<elmindreda
@
elmindreda.org
>
//
...
...
@@ -72,7 +72,10 @@ static void changeToResourcesDirectory(void)
//
static void createKeyTables(void)
{
int scancode;
memset(_glfw.ns.publicKeys, -1, sizeof(_glfw.ns.publicKeys));
memset(_glfw.ns.nativeKeys, -1, sizeof(_glfw.ns.nativeKeys));
_glfw.ns.publicKeys[0x1D] = GLFW_KEY_0;
_glfw.ns.publicKeys[0x12] = GLFW_KEY_1;
...
...
@@ -188,6 +191,13 @@ static void createKeyTables(void)
_glfw.ns.publicKeys[0x51] = GLFW_KEY_KP_EQUAL;
_glfw.ns.publicKeys[0x43] = GLFW_KEY_KP_MULTIPLY;
_glfw.ns.publicKeys[0x4E] = GLFW_KEY_KP_SUBTRACT;
for (scancode = 0; scancode
<
256;
scancode
++)
{
//
Store
the
reverse
translation
for
faster
key
name
lookup
if
(
_glfw.ns.publicKeys
[
scancode
]
>
= 0)
_glfw.ns.nativeKeys[_glfw.ns.publicKeys[scancode]] = scancode;
}
}
...
...
@@ -207,21 +217,41 @@ int _glfwPlatformInit(void)
_glfw.ns.eventSource = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
if (!_glfw.ns.eventSource)
return GL_FALSE;
return GL
FW
_FALSE;
CGEventSourceSetLocalEventsSuppressionInterval(_glfw.ns.eventSource, 0.0);
if (!_glfwInitContextAPI())
return GL_FALSE;
// TODO: Catch kTISNotifySelectedKeyboardInputSourceChanged and update
_glfw.ns.inputSource = TISCopyCurrentKeyboardLayoutInputSource();
if (!_glfw.ns.inputSource)
return GLFW_FALSE;
_glfwInitTimer();
_glfwInitJoysticks();
_glfw.ns.unicodeData = TISGetInputSourceProperty(_glfw.ns.inputSource,
kTISPropertyUnicodeKeyLayoutData);
if (!_glfw.ns.unicodeData)
return GLFW_FALSE;
return GL_TRUE;
if (!_glfwInitThreadLocalStoragePOSIX())
return GLFW_FALSE;
if (!_glfwInitNSGL())
return GLFW_FALSE;
_glfwInitTimerNS();
_glfwInitJoysticksNS();
return GLFW_TRUE;
}
void _glfwPlatformTerminate(void)
{
if (_glfw.ns.inputSource)
{
CFRelease(_glfw.ns.inputSource);
_glfw.ns.inputSource = NULL;
}
if (_glfw.ns.eventSource)
{
CFRelease(_glfw.ns.eventSource);
...
...
@@ -235,16 +265,17 @@ void _glfwPlatformTerminate(void)
_glfw.ns.delegate = nil;
}
[_glfw.ns.autoreleasePool release];
_glfw.ns.autoreleasePool = nil;
[_glfw.ns.cursor release];
_glfw.ns.cursor = nil;
free(_glfw.ns.clipboardString);
_glfwTerminateJoysticks();
_glfwTerminateContextAPI();
_glfwTerminateNSGL();
_glfwTerminateJoysticksNS();
_glfwTerminateThreadLocalStoragePOSIX();
[_glfw.ns.autoreleasePool release];
_glfw.ns.autoreleasePool = nil;
}
const char* _glfwPlatformGetVersionString(void)
...
...
third_party/glfw/src/
iokit
_joystick.h
→
third_party/glfw/src/
cocoa
_joystick.h
浏览文件 @
a68209fe
//========================================================================
// GLFW 3.
1 IOKit
- www.glfw.org
// GLFW 3.
2 Cocoa
- www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2006-2014 Camilla Berglund <elmindreda@elmindreda.org>
//
...
...
@@ -24,23 +24,22 @@
//
//========================================================================
#ifndef _glfw3_
iokit
_joystick_h_
#define _glfw3_
iokit
_joystick_h_
#ifndef _glfw3_
cocoa
_joystick_h_
#define _glfw3_
cocoa
_joystick_h_
#include <IOKit/IOKitLib.h>
#include <IOKit/IOCFPlugIn.h>
#include <IOKit/hid/IOHIDLib.h>
#include <IOKit/hid/IOHIDKeys.h>
#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE \
_GLFWjoystickIOKit iokit_js
#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE _GLFWjoystickNS ns_js
//
IOKit
-specific per-joystick data
//
Cocoa
-specific per-joystick data
//
typedef
struct
_GLFWjoydevice
typedef
struct
_GLFWjoydevice
NS
{
int
present
;
GLFWbool
present
;
char
name
[
256
];
IOHIDDeviceRef
deviceRef
;
...
...
@@ -51,18 +50,18 @@ typedef struct _GLFWjoydevice
float
*
axes
;
unsigned
char
*
buttons
;
}
_GLFWjoydevice
;
}
_GLFWjoydevice
NS
;
//
IOKit
-specific joystick API data
//
Cocoa
-specific joystick API data
//
typedef
struct
_GLFWjoystick
IOKit
typedef
struct
_GLFWjoystick
NS
{
_GLFWjoydevice
devices
[
GLFW_JOYSTICK_LAST
+
1
];
_GLFWjoydevice
NS
devices
[
GLFW_JOYSTICK_LAST
+
1
];
IOHIDManagerRef
managerRef
;
}
_GLFWjoystick
IOKit
;
}
_GLFWjoystick
NS
;
void
_glfwInitJoysticks
(
void
);
void
_glfwTerminateJoysticks
(
void
);
void
_glfwInitJoysticks
NS
(
void
);
void
_glfwTerminateJoysticks
NS
(
void
);
#endif // _glfw3_
iokit
_joystick_h_
#endif // _glfw3_
cocoa
_joystick_h_
third_party/glfw/src/
iokit
_joystick.m
→
third_party/glfw/src/
cocoa
_joystick.m
浏览文件 @
a68209fe
//========================================================================
// GLFW 3.
1 IOKit
- www.glfw.org
// GLFW 3.
2 Cocoa
- www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2009-2010 Camilla Berglund
<elmindreda
@
elmindreda.org
>
// Copyright (c) 2012 Torsten Walluhn
<tw
@
mad-cad.net
>
...
...
@@ -29,6 +29,7 @@
#include
<unistd.h>
#include
<ctype.h>
#include
<string.h>
#include
<mach
/
mach.h
>
#include
<mach
/
mach_error.h
>
...
...
@@ -40,7 +41,7 @@
//------------------------------------------------------------------------
// Joystick element information
//------------------------------------------------------------------------
typedef struct
typedef struct
_GLFWjoyelementNS
{
IOHIDElementRef elementRef;
...
...
@@ -50,14 +51,14 @@ typedef struct
long minReport;
long maxReport;
} _GLFWjoyelement;
} _GLFWjoyelement
NS
;
static void getElementsCFArrayHandler(const void* value, void* parameter);
// Adds an element to the specified joystick
//
static void addJoystickElement(_GLFWjoydevice* joystick,
static void addJoystickElement(_GLFWjoydevice
NS
* joystick,
IOHIDElementRef elementRef)
{
IOHIDElementType elementType;
...
...
@@ -109,7 +110,7 @@ static void addJoystickElement(_GLFWjoydevice* joystick,
if (elementsArray)
{
_GLFWjoyelement
* element = calloc(1, sizeof(_GLFWjoyelement
));
_GLFWjoyelement
NS* element = calloc(1, sizeof(_GLFWjoyelementNS
));
CFArrayAppendValue(elementsArray, element);
...
...
@@ -126,14 +127,14 @@ static void getElementsCFArrayHandler(const void* value, void* parameter)
{
if (CFGetTypeID(value) == IOHIDElementGetTypeID())
{
addJoystickElement((_GLFWjoydevice*) parameter,
addJoystickElement((_GLFWjoydevice
NS
*) parameter,
(IOHIDElementRef) value);
}
}
// Returns the value of the specified element of the specified joystick
//
static long getElementValue(_GLFWjoydevice
* joystick, _GLFWjoyelement
* element)
static long getElementValue(_GLFWjoydevice
NS* joystick, _GLFWjoyelementNS
* element)
{
IOReturn result = kIOReturnSuccess;
IOHIDValueRef valueRef;
...
...
@@ -163,7 +164,7 @@ static long getElementValue(_GLFWjoydevice* joystick, _GLFWjoyelement* element)
// Removes the specified joystick
//
static void removeJoystick(_GLFWjoydevice* joystick)
static void removeJoystick(_GLFWjoydevice
NS
* joystick)
{
int i;
...
...
@@ -188,70 +189,66 @@ static void removeJoystick(_GLFWjoydevice* joystick)
free(joystick->axes);
free(joystick->buttons);
memset(joystick, 0, sizeof(_GLFWjoydevice));
memset(joystick, 0, sizeof(_GLFWjoydevice
NS
));
}
// Polls for joystick events and updates GLFW state
//
static
void pollJoystickEvents(void
)
static
GLFWbool pollJoystickEvents(_GLFWjoydeviceNS* joystick
)
{
int joy;
for (joy = 0; joy
<
=
GLFW_JOYSTICK_LAST
;
joy
++)
{
CFIndex
i
;
int
buttonIndex =
0;
_GLFWjoydevice*
joystick =
_glfw.iokit_js.devices
+
joy
;
CFIndex i;
int buttonIndex = 0;
if
(!
joystick-
>
present)
continue
;
if (!joystick->present)
return GLFW_FALSE
;
for (i = 0; i
<
CFArrayGetCount
(
joystick-
>
buttonElements); i++)
{
_GLFWjoyelement* button = (_GLFWjoyelement
*)
CFArrayGetValueAtIndex(joystick->buttonElements, i);
for (i = 0; i
<
CFArrayGetCount
(
joystick-
>
buttonElements); i++)
{
_GLFWjoyelementNS* button = (_GLFWjoyelementNS
*)
CFArrayGetValueAtIndex(joystick->buttonElements, i);
if (getElementValue(joystick, button))
joystick->buttons[buttonIndex++] = GLFW_PRESS;
else
joystick->buttons[buttonIndex++] = GLFW_RELEASE;
}
if (getElementValue(joystick, button))
joystick->buttons[buttonIndex++] = GLFW_PRESS;
else
joystick->buttons[buttonIndex++] = GLFW_RELEASE;
}
for (i = 0; i
<
CFArrayGetCount
(
joystick-
>
axisElements); i++)
{
_GLFWjoyelement* axis = (_GLFWjoyelement
*)
CFArrayGetValueAtIndex(joystick->axisElements, i);
for (i = 0; i
<
CFArrayGetCount
(
joystick-
>
axisElements); i++)
{
_GLFWjoyelementNS* axis = (_GLFWjoyelementNS
*)
CFArrayGetValueAtIndex(joystick->axisElements, i);
long value = getElementValue(joystick, axis);
long readScale = axis->maxReport - axis->minReport;
long value = getElementValue(joystick, axis);
long readScale = axis->maxReport - axis->minReport;
if (readScale == 0)
joystick->axes[i] = value;
else
joystick->axes[i] = (2.f * (value - axis->minReport) / readScale) - 1.f;
}
if (readScale == 0)
joystick->axes[i] = value;
else
joystick->axes[i] = (2.f * (value - axis->minReport) / readScale) - 1.f;
}
for (i = 0; i
<
CFArrayGetCount
(
joystick-
>
hatElements); i++)
{
_GLFWjoyelement* hat = (_GLFWjoyelement
*)
CFArrayGetValueAtIndex(joystick->hatElements, i);
for (i = 0; i
<
CFArrayGetCount
(
joystick-
>
hatElements); i++)
{
_GLFWjoyelementNS* hat = (_GLFWjoyelementNS
*)
CFArrayGetValueAtIndex(joystick->hatElements, i);
// Bit fields of button presses for each direction, including nil
const int directions[9] = { 1, 3, 2, 6, 4, 12, 8, 9, 0 };
// Bit fields of button presses for each direction, including nil
const int directions[9] = { 1, 3, 2, 6, 4, 12, 8, 9, 0 };
long j, value = getElementValue(joystick, hat);
if (value
<
0
||
value
>
8)
value = 8;
long j, value = getElementValue(joystick, hat);
if (value
<
0
||
value
>
8)
value = 8;
for (j = 0; j
<
4;
j
++)
{
if
(
directions
[
value
]
&
(1
<<
j
))
joystick-
>
buttons[buttonIndex++] = GLFW_PRESS;
else
joystick->buttons[buttonIndex++] = GLFW_RELEASE;
}
for (j = 0; j
<
4;
j
++)
{
if
(
directions
[
value
]
&
(1
<<
j
))
joystick-
>
buttons[buttonIndex++] = GLFW_PRESS;
else
joystick->buttons[buttonIndex++] = GLFW_RELEASE;
}
}
return GLFW_TRUE;
}
// Callback for user-initiated joystick addition
...
...
@@ -261,12 +258,12 @@ static void matchCallback(void* context,
void* sender,
IOHIDDeviceRef deviceRef)
{
_GLFWjoydevice* joystick;
_GLFWjoydevice
NS
* joystick;
int joy;
for (joy = GLFW_JOYSTICK_1; joy
<
=
GLFW_JOYSTICK_LAST
;
joy
++)
{
joystick =
_glfw.
iokit
_js.devices
+
joy
;
joystick =
_glfw.
ns
_js.devices
+
joy
;
if
(!
joystick-
>
present)
continue;
...
...
@@ -277,7 +274,7 @@ static void matchCallback(void* context,
for (joy = GLFW_JOYSTICK_1; joy
<
=
GLFW_JOYSTICK_LAST
;
joy
++)
{
joystick =
_glfw.
iokit
_js.devices
+
joy
;
joystick =
_glfw.
ns
_js.devices
+
joy
;
if
(!
joystick-
>
present)
break;
...
...
@@ -286,15 +283,20 @@ static void matchCallback(void* context,
if (joy > GLFW_JOYSTICK_LAST)
return;
joystick->present = GL_TRUE;
joystick->present = GL
FW
_TRUE;
joystick->deviceRef = deviceRef;
CFStringRef name = IOHIDDeviceGetProperty(deviceRef,
CFSTR(kIOHIDProductKey));
CFStringGetCString(name,
joystick->name,
sizeof(joystick->name),
kCFStringEncodingUTF8);
if (name)
{
CFStringGetCString(name,
joystick->name,
sizeof(joystick->name),
kCFStringEncodingUTF8);
}
else
strncpy(joystick->name, "Unknown", sizeof(joystick->name));
joystick->axisElements = CFArrayCreateMutable(NULL, 0, NULL);
joystick->buttonElements = CFArrayCreateMutable(NULL, 0, NULL);
...
...
@@ -328,7 +330,7 @@ static void removeCallback(void* context,
for (joy = GLFW_JOYSTICK_1; joy
<
=
GLFW_JOYSTICK_LAST
;
joy
++)
{
_GLFWjoydevice
*
joystick =
_glfw.iokit
_js.devices
+
joy
;
_GLFWjoydevice
NS*
joystick =
_glfw.ns
_js.devices
+
joy
;
if
(
joystick-
>
deviceRef == deviceRef)
{
removeJoystick(joystick);
...
...
@@ -384,12 +386,12 @@ static CFMutableDictionaryRef createMatchingDictionary(long usagePage,
// Initialize joystick interface
//
void _glfwInitJoysticks(void)
void _glfwInitJoysticks
NS
(void)
{
CFMutableArrayRef matchingCFArrayRef;
_glfw.
iokit
_js.managerRef = IOHIDManagerCreate(kCFAllocatorDefault,
kIOHIDOptionsTypeNone);
_glfw.
ns
_js.managerRef = IOHIDManagerCreate(kCFAllocatorDefault,
kIOHIDOptionsTypeNone);
matchingCFArrayRef = CFArrayCreateMutable(kCFAllocatorDefault,
0,
...
...
@@ -422,21 +424,21 @@ void _glfwInitJoysticks(void)
CFRelease(matchingCFDictRef);
}
IOHIDManagerSetDeviceMatchingMultiple(_glfw.
iokit
_js.managerRef,
IOHIDManagerSetDeviceMatchingMultiple(_glfw.
ns
_js.managerRef,
matchingCFArrayRef);
CFRelease(matchingCFArrayRef);
}
IOHIDManagerRegisterDeviceMatchingCallback(_glfw.
iokit
_js.managerRef,
IOHIDManagerRegisterDeviceMatchingCallback(_glfw.
ns
_js.managerRef,
&
matchCallback, NULL);
IOHIDManagerRegisterDeviceRemovalCallback(_glfw.
iokit
_js.managerRef,
IOHIDManagerRegisterDeviceRemovalCallback(_glfw.
ns
_js.managerRef,
&
removeCallback, NULL);
IOHIDManagerScheduleWithRunLoop(_glfw.
iokit
_js.managerRef,
IOHIDManagerScheduleWithRunLoop(_glfw.
ns
_js.managerRef,
CFRunLoopGetMain(),
kCFRunLoopDefaultMode);
IOHIDManagerOpen(_glfw.
iokit
_js.managerRef, kIOHIDOptionsTypeNone);
IOHIDManagerOpen(_glfw.
ns
_js.managerRef, kIOHIDOptionsTypeNone);
// Execute the run loop once in order to register any initially-attached
// joysticks
...
...
@@ -445,18 +447,18 @@ void _glfwInitJoysticks(void)
// Close all opened joystick handles
//
void _glfwTerminateJoysticks(void)
void _glfwTerminateJoysticks
NS
(void)
{
int joy;
for (joy = 0; joy
<
=
GLFW_JOYSTICK_LAST
;
joy
++)
{
_GLFWjoydevice
*
joystick =
_glfw.iokit
_js.devices
+
joy
;
_GLFWjoydevice
NS*
joystick =
_glfw.ns
_js.devices
+
joy
;
removeJoystick
(
joystick
);
}
CFRelease
(
_glfw.
iokit
_js.managerRef
);
_glfw.
iokit
_js.managerRef =
NULL;
CFRelease
(
_glfw.
ns
_js.managerRef
);
_glfw.
ns
_js.managerRef =
NULL;
}
...
...
@@ -466,18 +468,14 @@ void _glfwTerminateJoysticks(void)
int
_glfwPlatformJoystickPresent
(
int
joy
)
{
pollJoystickEvents
();
return
_glfw.iokit_js.devices
[
joy
].
present
;
_GLFWjoydeviceNS*
joystick =
_glfw.ns_js.devices
+
joy
;
return
pollJoystickEvents
(
joystick
);
}
const
float*
_glfwPlatformGetJoystickAxes
(
int
joy
,
int*
count
)
{
_GLFWjoydevice*
joystick =
_glfw.iokit_js.devices
+
joy
;
pollJoystickEvents
();
if
(!
joystick-
>
present)
_GLFWjoydeviceNS*
joystick =
_glfw.ns_js.devices
+
joy
;
if
(!
pollJoystickEvents
(
joystick
))
return
NULL
;
*count =
(int)
CFArrayGetCount
(
joystick-
>
axisElements);
...
...
@@ -486,11 +484,8 @@ const float* _glfwPlatformGetJoystickAxes(int joy, int* count)
const unsigned char* _glfwPlatformGetJoystickButtons(int joy, int* count)
{
_GLFWjoydevice* joystick = _glfw.iokit_js.devices + joy;
pollJoystickEvents();
if (!joystick->present)
_GLFWjoydeviceNS* joystick = _glfw.ns_js.devices + joy;
if (!pollJoystickEvents(joystick))
return NULL;
*count = (int) CFArrayGetCount(joystick->buttonElements) +
...
...
@@ -500,8 +495,10 @@ const unsigned char* _glfwPlatformGetJoystickButtons(int joy, int* count)
const char* _glfwPlatformGetJoystickName(int joy)
{
pollJoystickEvents();
_GLFWjoydeviceNS* joystick = _glfw.ns_js.devices + joy;
if (!pollJoystickEvents(joystick))
return NULL;
return
_glfw.iokit_js.devices[joy].
name;
return
joystick->
name;
}
third_party/glfw/src/cocoa_monitor.m
浏览文件 @
a68209fe
//========================================================================
//
GLFW
3.
1
OS
X
-
www
.
glfw
.
org
//
GLFW
3.
2
OS
X
-
www
.
glfw
.
org
//------------------------------------------------------------------------
//
Copyright
(
c
)
2002
-
2006
Marcus
Geelnard
//
Copyright
(
c
)
2006
-
2010
Camilla
Berglund
<
elmindreda
@
elmindreda
.
org
>
...
...
@@ -76,28 +76,28 @@ static char* getDisplayName(CGDirectDisplayID displayID)
//
Check
whether
the
display
mode
should
be
included
in
enumeration
//
static
GL
boolean
modeIsGood
(
CGDisplayModeRef
mode
)
static
GL
FWbool
modeIsGood
(
CGDisplayModeRef
mode
)
{
uint32
_
t
flags
=
CGDisplayModeGetIOFlags
(
mode
)
;
if
(
!
(
flags
&
kDisplayModeValidFlag
)
||
!
(
flags
&
kDisplayModeSafeFlag
))
return
GL
_
FALSE
;
return
GL
FW
_
FALSE
;
if
(
flags
&
kDisplayModeInterlacedFlag
)
return
GL
_
FALSE
;
return
GL
FW
_
FALSE
;
if
(
flags
&
kDisplayModeStretchedFlag
)
return
GL
_
FALSE
;
return
GL
FW
_
FALSE
;
CFStringRef
format
=
CGDisplayModeCopyPixelEncoding
(
mode
)
;
if
(
CFStringCompare
(
format
,
CFSTR
(
IO16BitDirectPixels
)
,
0
)
&&
CFStringCompare
(
format
,
CFSTR
(
IO32BitDirectPixels
)
,
0
))
{
CFRelease
(
format
)
;
return
GL
_
FALSE
;
return
GL
FW
_
FALSE
;
}
CFRelease
(
format
)
;
return
GL
_
TRUE
;
return
GL
FW
_
TRUE
;
}
//
Convert
Core
Graphics
display
mode
to
GLFW
video
mode
...
...
@@ -166,7 +166,7 @@ static void endFadeReservation(CGDisplayFadeReservationToken token)
//
Change
the
current
video
mode
//
GL
boolean
_
glfwSetVideoMode
(
_
GLFWmonitor
*
monitor
,
const
GLFWvidmode
*
desired
)
GL
FWbool
_
glfwSetVideoModeNS
(
_
GLFWmonitor
*
monitor
,
const
GLFWvidmode
*
desired
)
{
CFArrayRef
modes
;
CFIndex
count
,
i
;
...
...
@@ -178,7 +178,7 @@ GLboolean _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* desired)
best
=
_
glfwChooseVideoMode
(
monitor
,
desired
)
;
_
glfwPlatformGetVideoMode
(
monitor
,
&
current
)
;
if
(
_
glfwCompareVideoModes
(
&
current
,
best
)
==
0
)
return
GL
_
TRUE
;
return
GL
FW
_
TRUE
;
CVDisplayLinkCreateWithCGDisplay
(
monitor
->
ns
.
displayID
,
&
link
)
;
...
...
@@ -216,15 +216,15 @@ GLboolean _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* desired)
{
_
glfwInputError
(
GLFW
_
PLATFORM
_
ERROR
,
"Cocoa: Monitor mode list changed"
)
;
return
GL
_
FALSE
;
return
GL
FW
_
FALSE
;
}
return
GL
_
TRUE
;
return
GL
FW
_
TRUE
;
}
//
Restore
the
previously
saved
(
original
)
video
mode
//
void
_
glfwRestoreVideoMode
(
_
GLFWmonitor
*
monitor
)
void
_
glfwRestoreVideoMode
NS
(
_
GLFWmonitor
*
monitor
)
{
if
(
monitor
->
ns
.
previousMode
)
{
...
...
@@ -283,7 +283,7 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
return
monitors
;
}
GL
boolean
_
glfwPlatformIsSameMonitor
(
_
GLFWmonitor
*
first
,
_
GLFWmonitor
*
second
)
GL
FWbool
_
glfwPlatformIsSameMonitor
(
_
GLFWmonitor
*
first
,
_
GLFWmonitor
*
second
)
{
//
HACK
:
Compare
unit
numbers
instead
of
display
IDs
to
work
around
display
//
replacement
on
machines
with
automatic
graphics
switching
...
...
third_party/glfw/src/cocoa_platform.h
浏览文件 @
a68209fe
//========================================================================
// GLFW 3.
1
OS X - www.glfw.org
// GLFW 3.
2
OS X - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2009-2010 Camilla Berglund <elmindreda@elmindreda.org>
//
...
...
@@ -28,16 +28,19 @@
#define _glfw3_cocoa_platform_h_
#include <stdint.h>
#include <dlfcn.h>
#if defined(__OBJC__)
#import <Carbon/Carbon.h>
#import <Cocoa/Cocoa.h>
#else
#include <Carbon/Carbon.h>
#include <ApplicationServices/ApplicationServices.h>
typedef
void
*
id
;
#endif
#include "posix_tls.h"
#include "
iokit
_joystick.h"
#include "
cocoa
_joystick.h"
#if defined(_GLFW_NSGL)
#include "nsgl_context.h"
...
...
@@ -45,6 +48,10 @@ typedef void* id;
#error "The Cocoa backend depends on NSGL platform support"
#endif
#define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL)
#define _glfw_dlclose(handle) dlclose(handle)
#define _glfw_dlsym(handle, name) dlsym(handle, name)
#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNS ns
#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryNS ns
#define _GLFW_PLATFORM_LIBRARY_TIME_STATE _GLFWtimeNS ns_time
...
...
@@ -59,7 +66,6 @@ typedef struct _GLFWwindowNS
id
object
;
id
delegate
;
id
view
;
unsigned
int
modifierFlags
;
// The total sum of the distances the cursor has been warped
// since the last cursor motion event was processed
...
...
@@ -73,13 +79,17 @@ typedef struct _GLFWwindowNS
//
typedef
struct
_GLFWlibraryNS
{
CGEventSourceRef
eventSource
;
id
delegate
;
id
autoreleasePool
;
id
cursor
;
short
int
publicKeys
[
256
];
char
*
clipboardString
;
CGEventSourceRef
eventSource
;
id
delegate
;
id
autoreleasePool
;
id
cursor
;
TISInputSourceRef
inputSource
;
id
unicodeData
;
char
keyName
[
64
];
short
int
publicKeys
[
256
];
short
int
nativeKeys
[
GLFW_KEY_LAST
+
1
];
char
*
clipboardString
;
}
_GLFWlibraryNS
;
...
...
@@ -108,15 +118,14 @@ typedef struct _GLFWcursorNS
//
typedef
struct
_GLFWtimeNS
{
double
base
;
double
resolution
;
GLFWuint64
frequency
;
}
_GLFWtimeNS
;
void
_glfwInitTimer
(
void
);
void
_glfwInitTimer
NS
(
void
);
GL
boolean
_glfwSetVideoMode
(
_GLFWmonitor
*
monitor
,
const
GLFWvidmode
*
desired
);
void
_glfwRestoreVideoMode
(
_GLFWmonitor
*
monitor
);
GL
FWbool
_glfwSetVideoModeNS
(
_GLFWmonitor
*
monitor
,
const
GLFWvidmode
*
desired
);
void
_glfwRestoreVideoMode
NS
(
_GLFWmonitor
*
monitor
);
#endif // _glfw3_cocoa_platform_h_
third_party/glfw/src/
mach
_time.c
→
third_party/glfw/src/
cocoa
_time.c
浏览文件 @
a68209fe
//========================================================================
// GLFW 3.
1
OS X - www.glfw.org
// GLFW 3.
2
OS X - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2009-2010 Camilla Berglund <elmindreda@elmindreda.org>
//
...
...
@@ -29,27 +29,18 @@
#include <mach/mach_time.h>
// Return raw time
//
static
uint64_t
getRawTime
(
void
)
{
return
mach_absolute_time
();
}
//////////////////////////////////////////////////////////////////////////
////// GLFW internal API //////
//////////////////////////////////////////////////////////////////////////
// Initialise timer
//
void
_glfwInitTimer
(
void
)
void
_glfwInitTimer
NS
(
void
)
{
mach_timebase_info_data_t
info
;
mach_timebase_info
(
&
info
);
_glfw
.
ns_time
.
resolution
=
(
double
)
info
.
numer
/
(
info
.
denom
*
1.0e9
);
_glfw
.
ns_time
.
base
=
getRawTime
();
_glfw
.
ns_time
.
frequency
=
(
info
.
denom
*
1e9
)
/
info
.
numer
;
}
...
...
@@ -57,15 +48,13 @@ void _glfwInitTimer(void)
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
double
_glfwPlatformGetTim
e
(
void
)
GLFWuint64
_glfwPlatformGetTimerValu
e
(
void
)
{
return
(
double
)
(
getRawTime
()
-
_glfw
.
ns_time
.
base
)
*
_glfw
.
ns_time
.
resolution
;
return
mach_absolute_time
();
}
void
_glfwPlatformSetTime
(
double
time
)
GLFWuint64
_glfwPlatformGetTimerFrequency
(
void
)
{
_glfw
.
ns_time
.
base
=
getRawTime
()
-
(
uint64_t
)
(
time
/
_glfw
.
ns_time
.
resolution
);
return
_glfw
.
ns_time
.
frequency
;
}
third_party/glfw/src/cocoa_window.m
浏览文件 @
a68209fe
此差异已折叠。
点击以展开。
third_party/glfw/src/context.c
浏览文件 @
a68209fe
此差异已折叠。
点击以展开。
third_party/glfw/src/egl_context.c
浏览文件 @
a68209fe
此差异已折叠。
点击以展开。
third_party/glfw/src/egl_context.h
浏览文件 @
a68209fe
//========================================================================
// GLFW 3.
1
EGL - www.glfw.org
// GLFW 3.
2
EGL - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
...
...
@@ -28,23 +28,92 @@
#ifndef _glfw3_egl_context_h_
#define _glfw3_egl_context_h_
#if defined(_GLFW_WIN32)
#define _glfw_dlopen(name) LoadLibraryA(name)
#define _glfw_dlclose(handle) FreeLibrary((HMODULE) handle)
#define _glfw_dlsym(handle, name) GetProcAddress((HMODULE) handle, name)
#if defined(_GLFW_USE_EGLPLATFORM_H)
#include <EGL/eglplatform.h>
#elif defined(_GLFW_WIN32)
#define EGLAPIENTRY __stdcall
typedef
HDC
EGLNativeDisplayType
;
typedef
HWND
EGLNativeWindowType
;
#elif defined(_GLFW_X11)
#define EGLAPIENTRY
typedef
Display
*
EGLNativeDisplayType
;
typedef
Window
EGLNativeWindowType
;
#elif defined(_GLFW_WAYLAND)
#define EGLAPIENTRY
typedef
struct
wl_display
*
EGLNativeDisplayType
;
typedef
struct
wl_egl_window
*
EGLNativeWindowType
;
#elif defined(_GLFW_MIR)
#define EGLAPIENTRY
typedef
MirEGLNativeDisplayType
EGLNativeDisplayType
;
typedef
MirEGLNativeWindowType
EGLNativeWindowType
;
#else
#include <dlfcn.h>
#define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL)
#define _glfw_dlclose(handle) dlclose(handle)
#define _glfw_dlsym(handle, name) dlsym(handle, name)
#error "No supported EGL platform selected"
#endif
#include <EGL/egl.h>
// This path may need to be changed if you build GLFW using your own setup
// We ship and use our own copy of eglext.h since GLFW uses fairly new
// extensions and not all operating systems come with an up-to-date version
#include "../deps/EGL/eglext.h"
#define EGL_SUCCESS 0x3000
#define EGL_NOT_INITIALIZED 0x3001
#define EGL_BAD_ACCESS 0x3002
#define EGL_BAD_ALLOC 0x3003
#define EGL_BAD_ATTRIBUTE 0x3004
#define EGL_BAD_CONFIG 0x3005
#define EGL_BAD_CONTEXT 0x3006
#define EGL_BAD_CURRENT_SURFACE 0x3007
#define EGL_BAD_DISPLAY 0x3008
#define EGL_BAD_MATCH 0x3009
#define EGL_BAD_NATIVE_PIXMAP 0x300a
#define EGL_BAD_NATIVE_WINDOW 0x300b
#define EGL_BAD_PARAMETER 0x300c
#define EGL_BAD_SURFACE 0x300d
#define EGL_CONTEXT_LOST 0x300e
#define EGL_COLOR_BUFFER_TYPE 0x303f
#define EGL_RGB_BUFFER 0x308e
#define EGL_SURFACE_TYPE 0x3033
#define EGL_WINDOW_BIT 0x0004
#define EGL_RENDERABLE_TYPE 0x3040
#define EGL_OPENGL_ES_BIT 0x0001
#define EGL_OPENGL_ES2_BIT 0x0004
#define EGL_OPENGL_BIT 0x0008
#define EGL_ALPHA_SIZE 0x3021
#define EGL_BLUE_SIZE 0x3022
#define EGL_GREEN_SIZE 0x3023
#define EGL_RED_SIZE 0x3024
#define EGL_DEPTH_SIZE 0x3025
#define EGL_STENCIL_SIZE 0x3026
#define EGL_SAMPLES 0x3031
#define EGL_OPENGL_ES_API 0x30a0
#define EGL_OPENGL_API 0x30a2
#define EGL_NONE 0x3038
#define EGL_EXTENSIONS 0x3055
#define EGL_CONTEXT_CLIENT_VERSION 0x3098
#define EGL_NATIVE_VISUAL_ID 0x302e
#define EGL_NO_SURFACE ((EGLSurface) 0)
#define EGL_NO_DISPLAY ((EGLDisplay) 0)
#define EGL_NO_CONTEXT ((EGLContext) 0)
#define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType) 0)
#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002
#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001
#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002
#define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR 0x00000001
#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR 0x31bd
#define EGL_NO_RESET_NOTIFICATION_KHR 0x31be
#define EGL_LOSE_CONTEXT_ON_RESET_KHR 0x31bf
#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR 0x00000004
#define EGL_CONTEXT_MAJOR_VERSION_KHR 0x3098
#define EGL_CONTEXT_MINOR_VERSION_KHR 0x30fb
#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30fd
#define EGL_CONTEXT_FLAGS_KHR 0x30fc
#define EGL_CONTEXT_OPENGL_NO_ERROR_KHR 0x31b3
#define EGL_GL_COLORSPACE_KHR 0x309d
#define EGL_GL_COLORSPACE_SRGB_KHR 0x3089
typedef
int
EGLint
;
typedef
unsigned
int
EGLBoolean
;
typedef
unsigned
int
EGLenum
;
typedef
void
*
EGLConfig
;
typedef
void
*
EGLContext
;
typedef
void
*
EGLDisplay
;
typedef
void
*
EGLSurface
;
// EGL function pointer typedefs
typedef
EGLBoolean
(
EGLAPIENTRY
*
PFNEGLGETCONFIGATTRIBPROC
)(
EGLDisplay
,
EGLConfig
,
EGLint
,
EGLint
*
);
...
...
@@ -63,22 +132,22 @@ typedef EGLBoolean (EGLAPIENTRY * PFNEGLSWAPBUFFERSPROC)(EGLDisplay,EGLSurface);
typedef
EGLBoolean
(
EGLAPIENTRY
*
PFNEGLSWAPINTERVALPROC
)(
EGLDisplay
,
EGLint
);
typedef
const
char
*
(
EGLAPIENTRY
*
PFNEGLQUERYSTRINGPROC
)(
EGLDisplay
,
EGLint
);
typedef
GLFWglproc
(
EGLAPIENTRY
*
PFNEGLGETPROCADDRESSPROC
)(
const
char
*
);
#define
_glfw_
eglGetConfigAttrib _glfw.egl.GetConfigAttrib
#define
_glfw_
eglGetConfigs _glfw.egl.GetConfigs
#define
_glfw_
eglGetDisplay _glfw.egl.GetDisplay
#define
_glfw_
eglGetError _glfw.egl.GetError
#define
_glfw_
eglInitialize _glfw.egl.Initialize
#define
_glfw_
eglTerminate _glfw.egl.Terminate
#define
_glfw_
eglBindAPI _glfw.egl.BindAPI
#define
_glfw_
eglCreateContext _glfw.egl.CreateContext
#define
_glfw_
eglDestroySurface _glfw.egl.DestroySurface
#define
_glfw_
eglDestroyContext _glfw.egl.DestroyContext
#define
_glfw_
eglCreateWindowSurface _glfw.egl.CreateWindowSurface
#define
_glfw_
eglMakeCurrent _glfw.egl.MakeCurrent
#define
_glfw_
eglSwapBuffers _glfw.egl.SwapBuffers
#define
_glfw_
eglSwapInterval _glfw.egl.SwapInterval
#define
_glfw_
eglQueryString _glfw.egl.QueryString
#define
_glfw_
eglGetProcAddress _glfw.egl.GetProcAddress
#define eglGetConfigAttrib _glfw.egl.GetConfigAttrib
#define eglGetConfigs _glfw.egl.GetConfigs
#define eglGetDisplay _glfw.egl.GetDisplay
#define eglGetError _glfw.egl.GetError
#define eglInitialize _glfw.egl.Initialize
#define eglTerminate _glfw.egl.Terminate
#define eglBindAPI _glfw.egl.BindAPI
#define eglCreateContext _glfw.egl.CreateContext
#define eglDestroySurface _glfw.egl.DestroySurface
#define eglDestroyContext _glfw.egl.DestroyContext
#define eglCreateWindowSurface _glfw.egl.CreateWindowSurface
#define eglMakeCurrent _glfw.egl.MakeCurrent
#define eglSwapBuffers _glfw.egl.SwapBuffers
#define eglSwapInterval _glfw.egl.SwapInterval
#define eglQueryString _glfw.egl.QueryString
#define eglGetProcAddress _glfw.egl.GetProcAddress
#define _GLFW_PLATFORM_FBCONFIG EGLConfig egl
#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextEGL egl
...
...
@@ -90,13 +159,9 @@ typedef GLFWglproc (EGLAPIENTRY * PFNEGLGETPROCADDRESSPROC)(const char*);
typedef
struct
_GLFWcontextEGL
{
EGLConfig
config
;
EGLContext
context
;
EGLContext
handle
;
EGLSurface
surface
;
#if defined(_GLFW_X11)
XVisualInfo
*
visual
;
#endif
void
*
client
;
}
_GLFWcontextEGL
;
...
...
@@ -109,7 +174,9 @@ typedef struct _GLFWlibraryEGL
EGLDisplay
display
;
EGLint
major
,
minor
;
GLboolean
KHR_create_context
;
GLFWbool
KHR_create_context
;
GLFWbool
KHR_create_context_no_error
;
GLFWbool
KHR_gl_colorspace
;
void
*
handle
;
...
...
@@ -133,14 +200,16 @@ typedef struct _GLFWlibraryEGL
}
_GLFWlibraryEGL
;
int
_glfwInitContextAPI
(
void
);
void
_glfwTerminateContextAPI
(
void
);
int
_glfwCreateContext
(
_GLFWwindow
*
window
,
const
_GLFWctxconfig
*
ctxconfig
,
const
_GLFWfbconfig
*
fbconfig
);
void
_glfwDestroyContext
(
_GLFWwindow
*
window
);
int
_glfwAnalyzeContext
(
const
_GLFWwindow
*
window
,
const
_GLFWctxconfig
*
ctxconfig
,
const
_GLFWfbconfig
*
fbconfig
);
GLFWbool
_glfwInitEGL
(
void
);
void
_glfwTerminateEGL
(
void
);
GLFWbool
_glfwCreateContextEGL
(
_GLFWwindow
*
window
,
const
_GLFWctxconfig
*
ctxconfig
,
const
_GLFWfbconfig
*
fbconfig
);
void
_glfwDestroyContextEGL
(
_GLFWwindow
*
window
);
#if defined(_GLFW_X11)
GLFWbool
_glfwChooseVisualEGL
(
const
_GLFWctxconfig
*
ctxconfig
,
const
_GLFWfbconfig
*
fbconfig
,
Visual
**
visual
,
int
*
depth
);
#endif
/*_GLFW_X11*/
#endif // _glfw3_egl_context_h_
third_party/glfw/src/glfw3Config.cmake.in
浏览文件 @
a68209fe
此差异已折叠。
点击以展开。
third_party/glfw/src/glfw_config.h.in
浏览文件 @
a68209fe
此差异已折叠。
点击以展开。
third_party/glfw/src/glx_context.c
浏览文件 @
a68209fe
此差异已折叠。
点击以展开。
third_party/glfw/src/glx_context.h
浏览文件 @
a68209fe
此差异已折叠。
点击以展开。
third_party/glfw/src/init.c
浏览文件 @
a68209fe
此差异已折叠。
点击以展开。
third_party/glfw/src/input.c
浏览文件 @
a68209fe
此差异已折叠。
点击以展开。
third_party/glfw/src/internal.h
浏览文件 @
a68209fe
此差异已折叠。
点击以展开。
third_party/glfw/src/linux_joystick.c
浏览文件 @
a68209fe
此差异已折叠。
点击以展开。
third_party/glfw/src/linux_joystick.h
浏览文件 @
a68209fe
此差异已折叠。
点击以展开。
third_party/glfw/src/mir_init.c
浏览文件 @
a68209fe
此差异已折叠。
点击以展开。
third_party/glfw/src/mir_monitor.c
浏览文件 @
a68209fe
此差异已折叠。
点击以展开。
third_party/glfw/src/mir_platform.h
浏览文件 @
a68209fe
此差异已折叠。
点击以展开。
third_party/glfw/src/mir_window.c
浏览文件 @
a68209fe
此差异已折叠。
点击以展开。
third_party/glfw/src/monitor.c
浏览文件 @
a68209fe
此差异已折叠。
点击以展开。
third_party/glfw/src/nsgl_context.h
浏览文件 @
a68209fe
此差异已折叠。
点击以展开。
third_party/glfw/src/nsgl_context.m
浏览文件 @
a68209fe
此差异已折叠。
点击以展开。
third_party/glfw/src/posix_time.c
浏览文件 @
a68209fe
此差异已折叠。
点击以展开。
third_party/glfw/src/posix_time.h
浏览文件 @
a68209fe
此差异已折叠。
点击以展开。
third_party/glfw/src/posix_tls.c
浏览文件 @
a68209fe
此差异已折叠。
点击以展开。
third_party/glfw/src/posix_tls.h
浏览文件 @
a68209fe
此差异已折叠。
点击以展开。
third_party/glfw/src/vulkan.c
0 → 100644
浏览文件 @
a68209fe
此差异已折叠。
点击以展开。
third_party/glfw/src/wgl_context.c
浏览文件 @
a68209fe
此差异已折叠。
点击以展开。
third_party/glfw/src/wgl_context.h
浏览文件 @
a68209fe
此差异已折叠。
点击以展开。
third_party/glfw/src/win32_init.c
浏览文件 @
a68209fe
此差异已折叠。
点击以展开。
third_party/glfw/src/win
mm
_joystick.c
→
third_party/glfw/src/win
32
_joystick.c
浏览文件 @
a68209fe
此差异已折叠。
点击以展开。
third_party/glfw/src/win
mm
_joystick.h
→
third_party/glfw/src/win
32
_joystick.h
浏览文件 @
a68209fe
此差异已折叠。
点击以展开。
third_party/glfw/src/win32_monitor.c
浏览文件 @
a68209fe
此差异已折叠。
点击以展开。
third_party/glfw/src/win32_platform.h
浏览文件 @
a68209fe
此差异已折叠。
点击以展开。
third_party/glfw/src/win32_time.c
浏览文件 @
a68209fe
此差异已折叠。
点击以展开。
third_party/glfw/src/win32_tls.c
浏览文件 @
a68209fe
此差异已折叠。
点击以展开。
third_party/glfw/src/win32_tls.h
已删除
100644 → 0
浏览文件 @
cd57083d
此差异已折叠。
点击以展开。
third_party/glfw/src/win32_window.c
浏览文件 @
a68209fe
此差异已折叠。
点击以展开。
third_party/glfw/src/window.c
浏览文件 @
a68209fe
此差异已折叠。
点击以展开。
third_party/glfw/src/wl_init.c
浏览文件 @
a68209fe
此差异已折叠。
点击以展开。
third_party/glfw/src/wl_monitor.c
浏览文件 @
a68209fe
此差异已折叠。
点击以展开。
third_party/glfw/src/wl_platform.h
浏览文件 @
a68209fe
此差异已折叠。
点击以展开。
third_party/glfw/src/wl_window.c
浏览文件 @
a68209fe
此差异已折叠。
点击以展开。
third_party/glfw/src/x11_init.c
浏览文件 @
a68209fe
此差异已折叠。
点击以展开。
third_party/glfw/src/x11_monitor.c
浏览文件 @
a68209fe
此差异已折叠。
点击以展开。
third_party/glfw/src/x11_platform.h
浏览文件 @
a68209fe
此差异已折叠。
点击以展开。
third_party/glfw/src/x11_window.c
浏览文件 @
a68209fe
此差异已折叠。
点击以展开。
third_party/glfw/src/xkb_unicode.c
浏览文件 @
a68209fe
此差异已折叠。
点击以展开。
third_party/glfw/src/xkb_unicode.h
浏览文件 @
a68209fe
//========================================================================
// GLFW 3.
1
Linux - www.glfw.org
// GLFW 3.
2
Linux - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com>
//
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录