mirror of
https://github.com/shadowfacts/lwjgl2-arm64.git
synced 2026-01-02 06:49:59 +01:00
Compare commits
477 commits
lwjgl2.8.1
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
08c5bb1927 | ||
|
|
2df01dd762 | ||
|
|
8bb7dfefc6 | ||
|
|
d0c96dfef2 | ||
|
|
ff352b63dd | ||
|
|
669689f288 | ||
|
|
9fd235ddf6 | ||
|
|
5d716b2b5a | ||
|
|
a5d81379f7 | ||
|
|
6650201a6d | ||
|
|
40694134ab | ||
|
|
a5c4462a3e | ||
|
|
1dbca8b623 | ||
|
|
0b83683ed1 | ||
|
|
a33e83ee38 | ||
|
|
36e7e73043 | ||
|
|
ef5149a3c3 | ||
|
|
589ce0bd5c | ||
|
|
e4b098c5e2 | ||
|
|
ae4606c53f | ||
|
|
70a8746f9a | ||
|
|
89b22fa151 | ||
|
|
831ac15619 | ||
|
|
67d29a75a0 | ||
|
|
301a37c5fe | ||
|
|
ee2a1c79a3 | ||
|
|
85e5488e4d | ||
|
|
54df7fb066 | ||
|
|
6ae9382a11 | ||
|
|
4a8e5bf4f7 | ||
|
|
e503ea631c | ||
|
|
8cdaf59905 | ||
|
|
45678633f9 | ||
|
|
e429e2699c | ||
|
|
132cecf861 | ||
|
|
751e1023f7 | ||
|
|
37ebf89df0 | ||
|
|
4d451457b4 | ||
|
|
220f55d914 | ||
|
|
ca19ebd11b | ||
|
|
b44f503882 | ||
|
|
f25e503ce0 | ||
|
|
42ccc83499 | ||
|
|
035a4d679b | ||
|
|
079a4b2e9c | ||
|
|
76867b161f | ||
|
|
1dff231df3 | ||
|
|
a570c1c085 | ||
|
|
e08c0fbf56 | ||
|
|
e4fc386372 | ||
|
|
d17c19fe01 | ||
|
|
78911cc0d4 | ||
|
|
59323ff03f | ||
|
|
774bd17ece | ||
|
|
202ce1d522 | ||
|
|
f760abeb81 | ||
|
|
f05778f073 | ||
|
|
46f602f0c6 | ||
|
|
818adb7312 | ||
|
|
e74811e5e7 | ||
|
|
30412de229 | ||
|
|
1ea14545f6 | ||
|
|
33e50400d2 | ||
|
|
5f5b39d3ca | ||
|
|
99afa57380 | ||
|
|
52933da812 | ||
|
|
518ad21d6c | ||
|
|
5d094b5763 | ||
|
|
cb759158e7 | ||
|
|
4aac231951 | ||
|
|
2b3e069d3a | ||
|
|
fcc0d679b0 | ||
|
|
e38fa15535 | ||
|
|
5cf86767bb | ||
|
|
85b7a2f5bb | ||
|
|
fd726e545f | ||
|
|
b83d29e265 | ||
|
|
50c0c30499 | ||
|
|
92f309d7ce | ||
|
|
132ff0191d | ||
|
|
c17617175b | ||
|
|
3ac0b43efd | ||
|
|
a6bb6e31d8 | ||
|
|
e6522d930d | ||
|
|
b699797a27 | ||
|
|
fc5749e42e | ||
|
|
a595fe1a5a | ||
|
|
7a81bde884 | ||
|
|
211b14c8d5 | ||
|
|
d5d9f06160 | ||
|
|
2976194124 | ||
|
|
5c7b35fa96 | ||
|
|
55bfecf514 | ||
|
|
561a80af3c | ||
|
|
5747615c41 | ||
|
|
66c987f9c2 | ||
|
|
1703b62ed5 | ||
|
|
0d70b5a8d5 | ||
|
|
e7f46b99e2 | ||
|
|
408ac906bb | ||
|
|
5c288b8d75 | ||
|
|
38a60ec533 | ||
|
|
d20d5546a3 | ||
|
|
eb2e7176b8 | ||
|
|
225bd176cb | ||
|
|
ed95cd0f27 | ||
|
|
507bdb6824 | ||
|
|
98f8bddce3 | ||
|
|
4d0aebb39d | ||
|
|
75fe62bbea | ||
|
|
675838f692 | ||
|
|
cd666c66cf | ||
|
|
ec9b14090b | ||
|
|
e90e5dc172 | ||
|
|
f97ac09641 | ||
|
|
59a9a970b9 | ||
|
|
4ff2240b57 | ||
|
|
6c4de65e20 | ||
|
|
aacd16acd1 | ||
|
|
43a6a8bfbb | ||
|
|
46cbd89430 | ||
|
|
5fb66cce46 | ||
|
|
8154abe073 | ||
|
|
dfbb8d3cbc | ||
|
|
38a3f6696c | ||
|
|
adf780c63d | ||
|
|
27d444ed74 | ||
|
|
ce43cfabd7 | ||
|
|
849511784b | ||
|
|
7cb0207eef | ||
|
|
eb85196a0c | ||
|
|
d3254e00f3 | ||
|
|
6b15398855 | ||
|
|
76e400955f | ||
|
|
248274bace | ||
|
|
4b48355093 | ||
|
|
ec09c41edc | ||
|
|
cad14be3eb | ||
|
|
bafa7a1972 | ||
|
|
1df5d25560 | ||
|
|
c324b6c215 | ||
|
|
e3974d5b74 | ||
|
|
274cd1c3c1 | ||
|
|
3caf672e42 | ||
|
|
fc023b0041 | ||
|
|
67d4e7c64d | ||
|
|
dfe0fc6bb4 | ||
|
|
dc580e2584 | ||
|
|
476dbf74a7 | ||
|
|
cc14c026ef | ||
|
|
11a6a30391 | ||
|
|
e3441a4075 | ||
|
|
0965ef8f46 | ||
|
|
83053798ca | ||
|
|
5b41d75e7d | ||
|
|
a9e492d93a | ||
|
|
e5aada8c45 | ||
|
|
fe0f7b3d26 | ||
|
|
76a977777e | ||
|
|
876157a8c4 | ||
|
|
94f16d6b1f | ||
|
|
0e1b392058 | ||
|
|
83763eb873 | ||
|
|
bc37a79798 | ||
|
|
1bbca2c7db | ||
|
|
310f0085cf | ||
|
|
bb0bbabef1 | ||
|
|
ea1ee59996 | ||
|
|
ad78b69d3a | ||
|
|
aee9bc4f84 | ||
|
|
caf21d89dc | ||
|
|
b66a3243a8 | ||
|
|
5fe5cc057d | ||
|
|
7df84ba1a2 | ||
|
|
f0aafd17a9 | ||
|
|
b1390f8035 | ||
|
|
8deac76a5b | ||
|
|
f528f38c60 | ||
|
|
5628e751bf | ||
|
|
1cceacb3cd | ||
|
|
6fd210fdb3 | ||
|
|
9a895b1dba | ||
|
|
c0b19b7743 | ||
|
|
1f81b30f66 | ||
|
|
5378a48083 | ||
|
|
0c07657edf | ||
|
|
a7c704ae2f | ||
|
|
529acd40ff | ||
|
|
f3dc48ba6e | ||
|
|
2bbd7ebe5b | ||
|
|
18285fa832 | ||
|
|
5631c5a3ba | ||
|
|
ca39cb3cdb | ||
|
|
79b5f755d7 | ||
|
|
f45f1e79d9 | ||
|
|
c9a057db73 | ||
|
|
a9c15cd1b0 | ||
|
|
523fab4417 | ||
|
|
82fc3bf6bf | ||
|
|
b83264e296 | ||
|
|
27f66983fc | ||
|
|
76f02c9187 | ||
|
|
38612a402d | ||
|
|
bc7061717e | ||
|
|
b83f27e970 | ||
|
|
c53e957833 | ||
|
|
14de6c518d | ||
|
|
7b955ee86b | ||
|
|
ead1abc2b8 | ||
|
|
58932fcdbf | ||
|
|
5738477a7b | ||
|
|
d8297e7583 | ||
|
|
d462208c4c | ||
|
|
50688c825d | ||
|
|
3509384629 | ||
|
|
96d65d716e | ||
|
|
6642ab736c | ||
|
|
8faf5f4f35 | ||
|
|
0cbe94d9e3 | ||
|
|
6cd860525f | ||
|
|
f381eb1f35 | ||
|
|
af1ae935d8 | ||
|
|
6663ee037c | ||
|
|
d28381e1cd | ||
|
|
e67d717c4e | ||
|
|
10b8d633d0 | ||
|
|
1b48b704bc | ||
|
|
817cada066 | ||
|
|
ed9ab95419 | ||
|
|
e725ca7d34 | ||
|
|
e28f8554f9 | ||
|
|
e0a52b20c3 | ||
|
|
9929d0fac9 | ||
|
|
93bfa246c6 | ||
|
|
f6c0f17c79 | ||
|
|
4e0c593644 | ||
|
|
db4eb9c5c8 | ||
|
|
409b3fea6d | ||
|
|
93a169b27b | ||
|
|
e15d172087 | ||
|
|
c57c27abaf | ||
|
|
f6a2bc8327 | ||
|
|
c328463776 | ||
|
|
bf13ed9cc3 | ||
|
|
65beebb379 | ||
|
|
2d43265d10 | ||
|
|
a5c7ec0017 | ||
|
|
4e1d539095 | ||
|
|
abeb9f389c | ||
|
|
549f07fd28 | ||
|
|
b27754089a | ||
|
|
0d25914029 | ||
|
|
1c671598aa | ||
|
|
4e023eec16 | ||
|
|
5400bb27db | ||
|
|
27cfdf646e | ||
|
|
6c090f1f61 | ||
|
|
f0219aed1a | ||
|
|
62b8d36002 | ||
|
|
6b68ff17b8 | ||
|
|
fc2889cc27 | ||
|
|
486ff0edea | ||
|
|
4735a6040f | ||
|
|
fbb490bb3a | ||
|
|
b8ba6ee6e5 | ||
|
|
fc9e4f4bda | ||
|
|
02c0e80fb6 | ||
|
|
d721194cf3 | ||
|
|
074f6f2d63 | ||
|
|
fe2f06f36e | ||
|
|
f2ad9f470d | ||
|
|
03b669fb4d | ||
|
|
0dda33cd2d | ||
|
|
d1c1fcb01e | ||
|
|
790f895220 | ||
|
|
517d6cfb3b | ||
|
|
76ba12ad38 | ||
|
|
683f488444 | ||
|
|
f13f35d250 | ||
|
|
a59964ccae | ||
|
|
d0759e9c12 | ||
|
|
a4c5be3781 | ||
|
|
fffa870418 | ||
|
|
0d6eac80f7 | ||
|
|
284f6135f3 | ||
|
|
f7c64c89dc | ||
|
|
8437f28abd | ||
|
|
5dea782de8 | ||
|
|
d235ae5bf0 | ||
|
|
21f994a039 | ||
|
|
45992fc378 | ||
|
|
70842b92aa | ||
|
|
778765c6de | ||
|
|
ce4153e883 | ||
|
|
970fc2d7d9 | ||
|
|
a576c3fb0f | ||
|
|
93d1d3ea03 | ||
|
|
ccf738dfaf | ||
|
|
2a820ed94f | ||
|
|
07499c30dd | ||
|
|
2cc6affcd1 | ||
|
|
c2081c5c1a | ||
|
|
8c4aeef4f4 | ||
|
|
11d6db5f35 | ||
|
|
83aeba5910 | ||
|
|
76238f038c | ||
|
|
31a4517205 | ||
|
|
804f09da47 | ||
|
|
415f25bf97 | ||
|
|
3cde95d9e4 | ||
|
|
b3b5e95bf4 | ||
|
|
b72cdb3064 | ||
|
|
b6a89d3bd4 | ||
|
|
129d0711c5 | ||
|
|
bc8040a1d0 | ||
|
|
52d46a8408 | ||
|
|
9d4f22034c | ||
|
|
ee69763707 | ||
|
|
ef62a8371b | ||
|
|
6eccb8b971 | ||
|
|
b5a87d818e | ||
|
|
9a968e8c41 | ||
|
|
c2159989f5 | ||
|
|
7b5d596c9b | ||
|
|
7f46fb2fbd | ||
|
|
1c4dfae74c | ||
|
|
3e3ffb23b0 | ||
|
|
3118499020 | ||
|
|
9931e5dbfc | ||
|
|
5f37b11857 | ||
|
|
38ce21abeb | ||
|
|
0ea13620de | ||
|
|
503f8780d3 | ||
|
|
41d37b1e03 | ||
|
|
f57c236373 | ||
|
|
baeda5e65b | ||
|
|
5d3cffc6af | ||
|
|
1cfdd27184 | ||
|
|
141b9c2632 | ||
|
|
4f4cb832af | ||
|
|
7bbfcadcef | ||
|
|
a749ad5c10 | ||
|
|
f7012a3020 | ||
|
|
49f92189ec | ||
|
|
7291d72274 | ||
|
|
3e96cded2b | ||
|
|
12ee2ecb3d | ||
|
|
be5655a254 | ||
|
|
9655b45e55 | ||
|
|
ce6f4b71f0 | ||
|
|
bb8045b471 | ||
|
|
4eaea5850c | ||
|
|
0c4008c885 | ||
|
|
6417afb180 | ||
|
|
94c23298c8 | ||
|
|
460b6f05dd | ||
|
|
2c811ac289 | ||
|
|
c09f5698b4 | ||
|
|
65009d8274 | ||
|
|
53c1a65255 | ||
|
|
8a39908698 | ||
|
|
ed0f117dfc | ||
|
|
efbdd35845 | ||
|
|
b59d60c4ba | ||
|
|
c58a34ee2e | ||
|
|
b824d786c4 | ||
|
|
43426ac8d8 | ||
|
|
cd011c6309 | ||
|
|
254e2937d7 | ||
|
|
bce0769065 | ||
|
|
092c224534 | ||
|
|
455b429984 | ||
|
|
9ffdd18a3f | ||
|
|
814f9a141e | ||
|
|
ad4f4c74eb | ||
|
|
e7edecf2ae | ||
|
|
220e194f0d | ||
|
|
cab3d10c46 | ||
|
|
bfd995bb05 | ||
|
|
929817a4eb | ||
|
|
b4cc6176e7 | ||
|
|
2168369bda | ||
|
|
a2edb189cb | ||
|
|
a0674aad47 | ||
|
|
39a4731583 | ||
|
|
0a26c7ea37 | ||
|
|
1f568b1224 | ||
|
|
6c0e3d0484 | ||
|
|
f74af79c19 | ||
|
|
afaf86df66 | ||
|
|
5f1efa0de3 | ||
|
|
af599805e4 | ||
|
|
22e0831d8a | ||
|
|
46922c0299 | ||
|
|
7f22935ca5 | ||
|
|
89a3558e3b | ||
|
|
15d4e8af94 | ||
|
|
f575c37815 | ||
|
|
f965ff8f83 | ||
|
|
2eea9d90b3 | ||
|
|
6f40eeb58a | ||
|
|
d2174850be | ||
|
|
18fc034c51 | ||
|
|
c581a929a9 | ||
|
|
75c1886d5e | ||
|
|
ffdcf4db13 | ||
|
|
92ba9d8ccb | ||
|
|
35e075e979 | ||
|
|
9ed2bd06aa | ||
|
|
e0c6b24536 | ||
|
|
093bfe9698 | ||
|
|
6010657389 | ||
|
|
05212349a5 | ||
|
|
8f756955b7 | ||
|
|
d099a86e50 | ||
|
|
4293976506 | ||
|
|
57ec5db726 | ||
|
|
65fddce290 | ||
|
|
e5ebf82c81 | ||
|
|
839db549a9 | ||
|
|
d813fcfaa8 | ||
|
|
57798b6727 | ||
|
|
c32fe94990 | ||
|
|
00446046f0 | ||
|
|
05d12649c8 | ||
|
|
57ff8c2e2b | ||
|
|
97c6cb1daf | ||
|
|
639d1d1457 | ||
|
|
edefe24bca | ||
|
|
d523c3bc34 | ||
|
|
39aae7ff27 | ||
|
|
0830a9674d | ||
|
|
6e76e2c06a | ||
|
|
7259a8ac0a | ||
|
|
6e6f5a4ff0 | ||
|
|
0e6d20e1e4 | ||
|
|
213aa4262d | ||
|
|
e40d8d1232 | ||
|
|
367b5fb176 | ||
|
|
b16a1e182e | ||
|
|
d446ad2da3 | ||
|
|
23adaeba93 | ||
|
|
b0dafc2a25 | ||
|
|
dc8aabb8a6 | ||
|
|
a91da9efa6 | ||
|
|
ef193f9b3d | ||
|
|
9684d6abfe | ||
|
|
7425a743c2 | ||
|
|
54ddcf2133 | ||
|
|
5c5a7b962a | ||
|
|
2f3fa670c6 | ||
|
|
78710b3b26 | ||
|
|
cc95e4c4fd | ||
|
|
e695454439 | ||
|
|
c26ba8ee58 | ||
|
|
9330766c3c | ||
|
|
2547669968 | ||
|
|
b3b9eede8c | ||
|
|
54664ef8cb | ||
|
|
ad7769f9c9 | ||
|
|
fb788c9ec1 | ||
|
|
8f0222a736 | ||
|
|
1762fa36b8 | ||
|
|
6b0e05cef6 | ||
|
|
e500d8e500 | ||
|
|
d58bcf2ee0 | ||
|
|
f15696d84a | ||
|
|
568e99a5f9 | ||
|
|
97075a7228 | ||
|
|
84cd3b562b | ||
|
|
2482d66ea1 | ||
|
|
1aae3fbe2e | ||
|
|
fb6326fec9 | ||
|
|
faefad816c | ||
|
|
297b11442a | ||
|
|
4a1755ef5a | ||
|
|
8055e0fd68 |
17
.github/CONTRIBUTING.md
vendored
Normal file
17
.github/CONTRIBUTING.md
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
## WARNING
|
||||
|
||||
This is the repository of the original LWJGL, which is no longer actively maintained. Unless you have released a product that uses LWJGL 2.x, you should probably be looking at [LWJGL 3](https://github.com/LWJGL/lwjgl3).
|
||||
|
||||
If you decide to proceed, it is very likely that:
|
||||
|
||||
- LWJGL maintainers won't be able to address your issue. Your best hope is an external contribution, which happens very rarely.
|
||||
- Your issue is not an issue in LWJGL 3.
|
||||
- Your issue has already been fixed in LWJGL 3.
|
||||
|
||||
If it is impossible for you to migrate to LWJGL 3, make sure to:
|
||||
|
||||
- Describe your issue as clearly as possible.
|
||||
- Include information about your system/environment.
|
||||
- Include a minimal code sample that reproduces the issue.
|
||||
|
||||
In any case, feature requests will almost certainly be ignored. If you need new features, you're very welcome to open an issue in the LWJGL 3 repository.
|
||||
22
.gitignore
vendored
Normal file
22
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
*.*~
|
||||
.*.sw[a-p]
|
||||
/.classpath
|
||||
/.nbattrs
|
||||
/.project
|
||||
/bin
|
||||
/dist
|
||||
/doc/javadoc
|
||||
/libs
|
||||
/src/generated
|
||||
/src/native/generated
|
||||
/src/native/common/Debug
|
||||
/src/native/common/Release
|
||||
/src/native/windows/Debug
|
||||
/src/native/windows/Release
|
||||
/temp
|
||||
/src/native/*/org_lwjgl_*.h
|
||||
/src/native/*/*/org_lwjgl_*.h
|
||||
/src/native/linux/org_lwjgl_opengl_Display.c
|
||||
|
||||
nbproject/project.xml
|
||||
/nbproject/private/
|
||||
24
README.md
Normal file
24
README.md
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
[LEGACY] LWJGL - Lightweight Java Game Library
|
||||
======
|
||||
|
||||
> **WARNING**
|
||||
>
|
||||
> This is the repository of the original LWJGL, which is no longer actively maintained. Unless you have released a product that uses LWJGL 2.x, you should probably be looking at [LWJGL 3](https://github.com/LWJGL/lwjgl3).
|
||||
|
||||
The Lightweight Java Game Library (LWJGL) is a solution aimed directly at professional and amateur Java programmers alike to enable commercial quality games to be written in Java.
|
||||
LWJGL provides developers access to high performance crossplatform libraries such as OpenGL (Open Graphics Library), OpenCL (Open Computing Language) and OpenAL (Open Audio Library) allowing for state of the art 3D games and 3D sound.
|
||||
Additionally LWJGL provides access to controllers such as Gamepads, Steering wheel and Joysticks.
|
||||
All in a simple and straight forward API.
|
||||
|
||||
Website: [http://legacy.lwjgl.org](http://legacy.lwjgl.org)
|
||||
Forum: [http://forum.lwjgl.org](http://forum.lwjgl.org)
|
||||
Bugs/Suggestions: [https://github.com/LWJGL/lwjgl/issues](https://github.com/LWJGL/lwjgl/issues)
|
||||
|
||||
Compilation
|
||||
-----------
|
||||
|
||||
LWJGL requires a JDK and Ant installed to compile, as well as your platforms native compiler to compile the JNI.
|
||||
|
||||
* ant generate-all
|
||||
* ant compile
|
||||
* ant compile_native
|
||||
330
build.xml
330
build.xml
|
|
@ -7,6 +7,7 @@
|
|||
<import file="platform_build/build-applet.xml"/>
|
||||
<import file="platform_build/build-webstart.xml"/>
|
||||
<import file="platform_build/build-maven.xml"/>
|
||||
<import file="eclipse-update/org.lwjgl.build/build-updatesite.xml"/>
|
||||
|
||||
<!-- ================================================================== -->
|
||||
<!-- Everything below this line is targets. -->
|
||||
|
|
@ -31,6 +32,8 @@
|
|||
<mkdir dir="${lwjgl.temp}/native" taskname="initialiazing temp/native folder" />
|
||||
<mkdir dir="${lwjgl.temp}/native/windows" taskname="initialiazing temp/windows folder" />
|
||||
<mkdir dir="${lwjgl.temp}/native/linux" taskname="initialiazing temp/linux folder" />
|
||||
<mkdir dir="${lwjgl.temp}/native/freebsd" taskname="initialiazing temp/freebsd folder" />
|
||||
<mkdir dir="${lwjgl.temp}/native/openbsd" taskname="initialiazing temp/openbsd folder" />
|
||||
<mkdir dir="${lwjgl.temp}/native/macosx" taskname="initialiazing temp/macosx folder" />
|
||||
<mkdir dir="${lwjgl.temp}/native/solaris" taskname="initialiazing temp/solaris folder" />
|
||||
</target>
|
||||
|
|
@ -55,7 +58,7 @@
|
|||
<!-- Creates a distribution of LWJGL -->
|
||||
<target name="release" description="Creates a distribution of LWJGL using supplied native binaries">
|
||||
<!-- Warn user -->
|
||||
<echo message="Before running the release target, please manually compile all platforms and place required files in ${lwjgl.lib}/windows, ${lwjgl.lib}/linux and ${lwjgl.lib}/macosx${line.separator}Missing files will result in a successfull built, but with incomplete release zips"/>
|
||||
<echo message="Before running the release target, please manually compile all platforms and place required files in ${lwjgl.lib}/windows, ${lwjgl.lib}/linux, ${lwjgl.lib}/freebsd and ${lwjgl.lib}/macosx${line.separator}Missing files will result in a successfull built, but with incomplete release zips"/>
|
||||
<input
|
||||
message="All data in the ${lwjgl.dist} folder will be deleted. Continue? "
|
||||
validargs="yes,no"
|
||||
|
|
@ -85,8 +88,8 @@
|
|||
<antcall target="-createjars" />
|
||||
|
||||
<antcall target="-jars_NoDEP" />
|
||||
<antcall target="javadoc" />
|
||||
<antcall target="applet-release" />
|
||||
<!-- <antcall target="javadoc" /> -->
|
||||
<!-- <antcall target="applet-release" /> -->
|
||||
|
||||
<!-- copy resources to res folder -->
|
||||
<copy todir="${lwjgl.temp}/res">
|
||||
|
|
@ -94,15 +97,15 @@
|
|||
</copy>
|
||||
|
||||
<!-- copy docs -->
|
||||
<copy todir="${lwjgl.temp}/doc">
|
||||
<fileset dir="${lwjgl.docs}">
|
||||
<patternset refid="lwjgl-docs.fileset" />
|
||||
</fileset>
|
||||
</copy>
|
||||
<!-- <copy todir="${lwjgl.temp}/doc"> -->
|
||||
<!-- <fileset dir="${lwjgl.docs}"> -->
|
||||
<!-- <patternset refid="lwjgl-docs.fileset" /> -->
|
||||
<!-- </fileset> -->
|
||||
<!-- </copy> -->
|
||||
|
||||
<!-- create distribution from files in libs/ and temp/ -->
|
||||
<antcall target="-distribution_javadoc" />
|
||||
<antcall target="-distribution_source" />
|
||||
<!-- <antcall target="-distribution_javadoc" /> -->
|
||||
<!-- <antcall target="-distribution_source" /> -->
|
||||
<antcall target="-distribute" />
|
||||
</target>
|
||||
|
||||
|
|
@ -156,6 +159,11 @@
|
|||
<fileset refid="lwjgl_util_applet.fileset" />
|
||||
<manifest>
|
||||
<attribute name="Sealed" value="true"/>
|
||||
<attribute name="Trusted-Library" value="true"/>
|
||||
<attribute name="Permissions" value="all-permissions"/>
|
||||
<attribute name="Codebase" value="*"/>
|
||||
<attribute name="Caller-Allowable-Codebase" value="*"/>
|
||||
<attribute name="Application-Library-Allowable-Codebase" value="*"/>
|
||||
</manifest>
|
||||
</jar>
|
||||
|
||||
|
|
@ -176,7 +184,7 @@
|
|||
<!-- ================================================================== -->
|
||||
<!-- Generate a list of the OpenGL extension classes -->
|
||||
<!-- ================================================================== -->
|
||||
<fileset id="opengl-template-fileset" dir="${lwjgl.src}/generated" includes="${opengl-template-pattern}"/>
|
||||
<fileset id="opengl-template-fileset" dir="${lwjgl.src}/generated/org/lwjgl/opengl" includes="${opengl-template-pattern}"/>
|
||||
<property name="opengl-template-files" refid="opengl-template-fileset"/>
|
||||
|
||||
<tempfile property="temp.file"/>
|
||||
|
|
@ -186,7 +194,7 @@
|
|||
<filterchain>
|
||||
<tokenfilter delimoutput=",">
|
||||
<stringtokenizer delims=";"/>
|
||||
<replaceregex pattern="org\${file.separator}lwjgl\${file.separator}opengl\${file.separator}(.+)[.]java"
|
||||
<replaceregex pattern="(.+)[.]java"
|
||||
replace="org/lwjgl/opengl/\1.class"/>
|
||||
</tokenfilter>
|
||||
</filterchain>
|
||||
|
|
@ -237,6 +245,16 @@
|
|||
<patternset refid="lwjgl-linux.fileset" />
|
||||
</fileset>
|
||||
</copy>
|
||||
<copy todir="${lwjgl.temp}/native/freebsd" failonerror="false">
|
||||
<fileset dir="${lwjgl.lib}/freebsd">
|
||||
<patternset refid="lwjgl-freebsd.fileset" />
|
||||
</fileset>
|
||||
</copy>
|
||||
<copy todir="${lwjgl.temp}/native/openbsd" failonerror="false">
|
||||
<fileset dir="${lwjgl.lib}/openbsd">
|
||||
<patternset refid="lwjgl-openbsd.fileset" />
|
||||
</fileset>
|
||||
</copy>
|
||||
<copy todir="${lwjgl.temp}/native/macosx">
|
||||
<fileset dir="${lwjgl.lib}/macosx">
|
||||
<patternset refid="lwjgl-macosx.fileset" />
|
||||
|
|
@ -277,79 +295,88 @@
|
|||
|
||||
<!-- Generates the native headers from source files -->
|
||||
<target name="headers" description="invokes javah on java classes" depends="compile">
|
||||
<javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/linux" force="yes">
|
||||
<class name="org.lwjgl.LinuxSysImplementation" />
|
||||
<class name="org.lwjgl.opengl.LinuxEvent" />
|
||||
<class name="org.lwjgl.opengl.LinuxMouse" />
|
||||
<class name="org.lwjgl.opengl.LinuxKeyboard" />
|
||||
<class name="org.lwjgl.opengl.LinuxDisplay" />
|
||||
<class name="org.lwjgl.opengl.LinuxPeerInfo" />
|
||||
</javah>
|
||||
<!-- <javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/linux"> -->
|
||||
<!-- <class name="org.lwjgl.LinuxSysImplementation" /> -->
|
||||
<!-- <class name="org.lwjgl.opengl.LinuxEvent" /> -->
|
||||
<!-- <class name="org.lwjgl.opengl.LinuxMouse" /> -->
|
||||
<!-- <class name="org.lwjgl.opengl.LinuxKeyboard" /> -->
|
||||
<!-- <class name="org.lwjgl.opengl.LinuxDisplay" /> -->
|
||||
<!-- <class name="org.lwjgl.opengl.LinuxPeerInfo" /> -->
|
||||
<!-- </javah> -->
|
||||
|
||||
<javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/linux/opengl" force="yes">
|
||||
<class name="org.lwjgl.opengl.LinuxPbufferPeerInfo"/>
|
||||
<class name="org.lwjgl.opengl.LinuxDisplayPeerInfo"/>
|
||||
<class name="org.lwjgl.opengl.LinuxAWTGLCanvasPeerInfo"/>
|
||||
<class name="org.lwjgl.opengl.LinuxContextImplementation"/>
|
||||
<class name="org.lwjgl.opengl.LinuxCanvasImplementation"/>
|
||||
</javah>
|
||||
<!-- <javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/linux/opengl"> -->
|
||||
<!-- <class name="org.lwjgl.opengl.LinuxPbufferPeerInfo"/> -->
|
||||
<!-- <class name="org.lwjgl.opengl.LinuxDisplayPeerInfo"/> -->
|
||||
<!-- <class name="org.lwjgl.opengl.LinuxAWTGLCanvasPeerInfo"/> -->
|
||||
<!-- <class name="org.lwjgl.opengl.LinuxContextImplementation"/> -->
|
||||
<!-- <class name="org.lwjgl.opengl.LinuxCanvasImplementation"/> -->
|
||||
<!-- </javah> -->
|
||||
|
||||
<javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/windows" force="yes">
|
||||
<class name="org.lwjgl.WindowsSysImplementation"/>
|
||||
<class name="org.lwjgl.opengl.WindowsKeyboard" />
|
||||
<class name="org.lwjgl.opengl.WindowsRegistry" />
|
||||
<class name="org.lwjgl.opengl.WindowsDisplay"/>
|
||||
<class name="org.lwjgl.opengl.WindowsDisplayPeerInfo"/>
|
||||
<class name="org.lwjgl.opengl.WindowsAWTGLCanvasPeerInfo"/>
|
||||
</javah>
|
||||
<!-- <javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/windows"> -->
|
||||
<!-- <class name="org.lwjgl.WindowsSysImplementation"/> -->
|
||||
<!-- <class name="org.lwjgl.opengl.WindowsKeyboard" /> -->
|
||||
<!-- <class name="org.lwjgl.opengl.WindowsRegistry" /> -->
|
||||
<!-- <class name="org.lwjgl.opengl.WindowsDisplay"/> -->
|
||||
<!-- <class name="org.lwjgl.opengl.WindowsDisplayPeerInfo"/> -->
|
||||
<!-- <class name="org.lwjgl.opengl.WindowsAWTGLCanvasPeerInfo"/> -->
|
||||
<!-- </javah> -->
|
||||
|
||||
<javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/windows/opengl" force="yes">
|
||||
<class name="org.lwjgl.opengl.WindowsPbufferPeerInfo"/>
|
||||
<class name="org.lwjgl.opengl.WindowsPeerInfo"/>
|
||||
<class name="org.lwjgl.opengl.WindowsContextImplementation"/>
|
||||
</javah>
|
||||
<!-- <javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/windows/opengl"> -->
|
||||
<!-- <class name="org.lwjgl.opengl.WindowsPbufferPeerInfo"/> -->
|
||||
<!-- <class name="org.lwjgl.opengl.WindowsPeerInfo"/> -->
|
||||
<!-- <class name="org.lwjgl.opengl.WindowsContextImplementation"/> -->
|
||||
<!-- </javah> -->
|
||||
|
||||
<javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/windows/opengles" force="yes">
|
||||
<class name="org.lwjgl.opengl.WindowsPeerInfo"/>
|
||||
</javah>
|
||||
<!-- <javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/windows/opengles"> -->
|
||||
<!-- <class name="org.lwjgl.opengl.WindowsPeerInfo"/> -->
|
||||
<!-- </javah> -->
|
||||
|
||||
<javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/macosx" force="yes">
|
||||
<class name="org.lwjgl.MacOSXSysImplementation" />
|
||||
<class name="org.lwjgl.opengl.MacOSXMouseEventQueue" />
|
||||
<class name="org.lwjgl.opengl.MacOSXCanvasPeerInfo" />
|
||||
<class name="org.lwjgl.opengl.MacOSXPeerInfo" />
|
||||
<class name="org.lwjgl.opengl.MacOSXPbufferPeerInfo" />
|
||||
<class name="org.lwjgl.opengl.MacOSXDisplay" />
|
||||
<class name="org.lwjgl.opengl.MacOSXContextImplementation" />
|
||||
</javah>
|
||||
<echo>lwjgl.src.headers = ${lwjgl.src.headers}</echo>
|
||||
|
||||
<javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.headers}" force="yes">
|
||||
<class name="org.lwjgl.opengl.AWTSurfaceLock" />
|
||||
<class name="org.lwjgl.DefaultSysImplementation" />
|
||||
<class name="org.lwjgl.input.Cursor" />
|
||||
<class name="org.lwjgl.input.Keyboard" />
|
||||
<class name="org.lwjgl.input.Mouse" />
|
||||
<class name="org.lwjgl.openal.AL" />
|
||||
<class name="org.lwjgl.opencl.CL" />
|
||||
<class name="org.lwjgl.opencl.CallbackUtil" />
|
||||
<class name="org.lwjgl.BufferUtils" />
|
||||
</javah>
|
||||
<javac classpath="${lwjgl.bin}" srcdir="${lwjgl.src}" nativeheaderdir="${lwjgl.src.native}/macosx">
|
||||
<compilerarg line="-h ${lwjgl.src.native}/macosx" />
|
||||
<include name="java/org/lwjgl/MacOSXSysImplementation.java" />
|
||||
<include name="java/org/lwjgl/opengl/MacOSXCanvasPeerInfo.java" />
|
||||
<include name="java/org/lwjgl/opengl/MacOSXPeerInfo.java" />
|
||||
<include name="java/org/lwjgl/opengl/MacOSXPbufferPeerInfo.java" />
|
||||
<include name="java/org/lwjgl/opengl/MacOSXDisplay.java" />
|
||||
<include name="java/org/lwjgl/opengl/MacOSXContextImplementation.java" />
|
||||
<include name="java/org/lwjgl/opengl/MacOSXNativeKeyboard.java" />
|
||||
<include name="java/org/lwjgl/opengl/MacOSXNativeMouse.java" />
|
||||
<include name="java/org/lwjgl/opengl/MacOSXMouseEventQueue.java" />
|
||||
</javac>
|
||||
|
||||
<javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.headers}/opengl" force="yes">
|
||||
<class name="org.lwjgl.opengl.GLContext"/>
|
||||
<class name="org.lwjgl.opengl.Pbuffer"/>
|
||||
<class name="org.lwjgl.opengl.CallbackUtil"/>
|
||||
<class name="org.lwjgl.opengl.NVPresentVideoUtil"/>
|
||||
<class name="org.lwjgl.opengl.NVVideoCaptureUtil"/>
|
||||
</javah>
|
||||
<javac classpath="${lwjgl.bin}" srcdir="${lwjgl.src}" nativeheaderdir="${lwjgl.src.headers}">
|
||||
<compilerarg line="-h ${lwjgl.src.headers}" />
|
||||
<include name="java/org/lwjgl/opengl/AWTSurfaceLock.java" />
|
||||
<include name="java/org/lwjgl/DefaultSysImplementation.java" />
|
||||
<include name="java/org/lwjgl/input/Cursor.java" />
|
||||
<include name="java/org/lwjgl/input/Keyboard.java" />
|
||||
<include name="java/org/lwjgl/input/Mouse.java" />
|
||||
<include name="java/org/lwjgl/openal/AL.java" />
|
||||
<include name="java/org/lwjgl/opencl/CL.java" />
|
||||
<include name="java/org/lwjgl/opencl/CallbackUtil.java" />
|
||||
<include name="java/org/lwjgl/BufferUtils.java" />
|
||||
</javac>
|
||||
|
||||
<javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.headers}/opengles" force="yes">
|
||||
<class name="org.lwjgl.opengles.EGL"/>
|
||||
<class name="org.lwjgl.opengles.EGLKHRFenceSync"/>
|
||||
<class name="org.lwjgl.opengles.EGLKHRReusableSync"/>
|
||||
<class name="org.lwjgl.opengles.EGLNVSync"/>
|
||||
<class name="org.lwjgl.opengles.GLContext"/>
|
||||
</javah>
|
||||
<javac classpath="${lwjgl.bin}" srcdir="${lwjgl.src}" nativeheaderdir="${lwjgl.src.headers}/opengl">
|
||||
<compilerarg line="-h ${lwjgl.src.headers}/opengl" />
|
||||
<include name="java/org/lwjgl/opengl/GLContext.java"/>
|
||||
<include name="java/org/lwjgl/opengl/Pbuffer.java"/>
|
||||
<include name="java/org/lwjgl/opengl/CallbackUtil.java"/>
|
||||
<include name="java/org/lwjgl/opengl/NVPresentVideoUtil.java"/>
|
||||
<include name="java/org/lwjgl/opengl/NVVideoCaptureUtil.java"/>
|
||||
</javac>
|
||||
|
||||
<javac classpath="${lwjgl.bin}" srcdir="${lwjgl.src}" nativeheaderdir="${lwjgl.src.headers}/opengles">
|
||||
<compilerarg line="-h ${lwjgl.src.headers}/opengles" />
|
||||
<include name="java/org/lwjgl/opengles/EGL.java"/>
|
||||
<include name="java/org/lwjgl/opengles/EGLKHRFenceSync.java"/>
|
||||
<include name="java/org/lwjgl/opengles/EGLKHRReusableSync.java"/>
|
||||
<include name="java/org/lwjgl/opengles/EGLNVSync.java"/>
|
||||
<include name="java/org/lwjgl/opengles/GLContext.java"/>
|
||||
<include name="java/org/lwjgl/opengles/CallbackUtil.java"/>
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<target name="touch-version">
|
||||
|
|
@ -359,56 +386,60 @@
|
|||
</target>
|
||||
|
||||
<target name="version-mismatch">
|
||||
<loadfile srcfile="${lwjgl.src}/java/org/lwjgl/WindowsSysImplementation.java" property="lwjgl.java.windows.version">
|
||||
<filterchain>
|
||||
<tokenfilter>
|
||||
<containsstring contains="JNI_VERSION ="/>
|
||||
</tokenfilter>
|
||||
</filterchain>
|
||||
</loadfile>
|
||||
<loadfile srcfile="${lwjgl.src}/java/org/lwjgl/LinuxSysImplementation.java" property="lwjgl.java.linux.version">
|
||||
<filterchain>
|
||||
<tokenfilter>
|
||||
<containsstring contains="JNI_VERSION ="/>
|
||||
</tokenfilter>
|
||||
</filterchain>
|
||||
</loadfile>
|
||||
<loadfile srcfile="${lwjgl.src}/java/org/lwjgl/MacOSXSysImplementation.java" property="lwjgl.java.macosx.version">
|
||||
<filterchain>
|
||||
<tokenfilter>
|
||||
<containsstring contains="JNI_VERSION ="/>
|
||||
</tokenfilter>
|
||||
</filterchain>
|
||||
</loadfile>
|
||||
<loadfile srcfile="${lwjgl.src.native}/windows/org_lwjgl_WindowsSysImplementation.h" property="lwjgl.native.windows.version">
|
||||
<filterchain>
|
||||
<tokenfilter>
|
||||
<containsstring contains="#define org_lwjgl_WindowsSysImplementation_JNI_VERSION"/>
|
||||
</tokenfilter>
|
||||
</filterchain>
|
||||
</loadfile>
|
||||
<loadfile srcfile="${lwjgl.src.native}/linux/org_lwjgl_LinuxSysImplementation.h" property="lwjgl.native.linux.version">
|
||||
<filterchain>
|
||||
<tokenfilter>
|
||||
<containsstring contains="#define org_lwjgl_LinuxSysImplementation_JNI_VERSION"/>
|
||||
</tokenfilter>
|
||||
</filterchain>
|
||||
</loadfile>
|
||||
<loadfile srcfile="${lwjgl.src.native}/macosx/org_lwjgl_MacOSXSysImplementation.h" property="lwjgl.native.macosx.version">
|
||||
<filterchain>
|
||||
<tokenfilter>
|
||||
<containsstring contains="#define org_lwjgl_MacOSXSysImplementation_JNI_VERSION"/>
|
||||
</tokenfilter>
|
||||
</filterchain>
|
||||
</loadfile>
|
||||
<echo>
|
||||
lwjgl.java.windows.version = ${lwjgl.java.windows.version}
|
||||
lwjgl.native.windows.version = ${lwjgl.native.windows.version}
|
||||
lwjgl.java.linux.version = ${lwjgl.java.linux.version}
|
||||
lwjgl.native.linux.version = ${lwjgl.native.linux.version}
|
||||
lwjgl.java.macosx.version = ${lwjgl.java.macosx.version}
|
||||
lwjgl.native.macosx.version = ${lwjgl.native.macosx.version}
|
||||
</echo>
|
||||
<!-- <loadfile srcfile="${lwjgl.src}/java/org/lwjgl/WindowsSysImplementation.java" property="lwjgl.java.windows.version"> -->
|
||||
<!-- <filterchain> -->
|
||||
<!-- <tokenfilter> -->
|
||||
<!-- <containsstring contains="JNI_VERSION ="/> -->
|
||||
<!-- </tokenfilter> -->
|
||||
<!-- </filterchain> -->
|
||||
<!-- </loadfile> -->
|
||||
<!-- <loadfile srcfile="${lwjgl.src}/java/org/lwjgl/LinuxSysImplementation.java" property="lwjgl.java.linux.version"> -->
|
||||
<!-- <filterchain> -->
|
||||
<!-- <tokenfilter> -->
|
||||
<!-- <containsstring contains="JNI_VERSION ="/> -->
|
||||
<!-- </tokenfilter> -->
|
||||
<!-- </filterchain> -->
|
||||
<!-- </loadfile> -->
|
||||
<!-- <loadfile srcfile="${lwjgl.src}/java/org/lwjgl/MacOSXSysImplementation.java" property="lwjgl.java.macosx.version"> -->
|
||||
<!-- <filterchain> -->
|
||||
<!-- <tokenfilter> -->
|
||||
<!-- <containsstring contains="JNI_VERSION ="/> -->
|
||||
<!-- </tokenfilter> -->
|
||||
<!-- </filterchain> -->
|
||||
<!-- </loadfile> -->
|
||||
<!-- <loadfile srcfile="${lwjgl.src.native}/windows/org_lwjgl_WindowsSysImplementation.h" property="lwjgl.native.windows.version"> -->
|
||||
<!-- <filterchain> -->
|
||||
<!-- <tokenfilter> -->
|
||||
<!-- <containsstring contains="#define org_lwjgl_WindowsSysImplementation_JNI_VERSION"/> -->
|
||||
<!-- </tokenfilter> -->
|
||||
<!-- </filterchain> -->
|
||||
<!-- </loadfile> -->
|
||||
<!-- <loadfile srcfile="${lwjgl.src.native}/linux/org_lwjgl_LinuxSysImplementation.h" property="lwjgl.native.linux.version"> -->
|
||||
<!-- <filterchain> -->
|
||||
<!-- <tokenfilter> -->
|
||||
<!-- <containsstring contains="#define org_lwjgl_LinuxSysImplementation_JNI_VERSION"/> -->
|
||||
<!-- </tokenfilter> -->
|
||||
<!-- </filterchain> -->
|
||||
<!-- </loadfile> -->
|
||||
<!-- <loadfile srcfile="${lwjgl.src.native}/macosx/org_lwjgl_MacOSXSysImplementation.h" property="lwjgl.native.macosx.version"> -->
|
||||
<!-- <filterchain> -->
|
||||
<!-- <tokenfilter> -->
|
||||
<!-- <containsstring contains="#define org_lwjgl_MacOSXSysImplementation_JNI_VERSION"/> -->
|
||||
<!-- </tokenfilter> -->
|
||||
<!-- </filterchain> -->
|
||||
<!-- </loadfile> -->
|
||||
<!-- <echo> -->
|
||||
<!-- lwjgl.java.windows.version = ${lwjgl.java.windows.version} -->
|
||||
<!-- lwjgl.native.windows.version = ${lwjgl.native.windows.version} -->
|
||||
<!-- lwjgl.java.linux.version = ${lwjgl.java.linux.version} -->
|
||||
<!-- lwjgl.native.linux.version = ${lwjgl.native.linux.version} -->
|
||||
<!-- lwjgl.java.freebsd.version = ${lwjgl.java.linux.version} -->
|
||||
<!-- lwjgl.native.freebsd.version = ${lwjgl.native.linux.version} -->
|
||||
<!-- lwjgl.java.openbsd.version = ${lwjgl.java.linux.version} -->
|
||||
<!-- lwjgl.native.openbsd.version = ${lwjgl.native.linux.version} -->
|
||||
<!-- lwjgl.java.macosx.version = ${lwjgl.java.macosx.version} -->
|
||||
<!-- lwjgl.native.macosx.version = ${lwjgl.native.macosx.version} -->
|
||||
<!-- </echo> -->
|
||||
</target>
|
||||
|
||||
<macrodef name="version-check">
|
||||
|
|
@ -437,7 +468,7 @@
|
|||
|
||||
<!-- Compiles the Java source code -->
|
||||
<target name="compile" description="Compiles the java source code" depends="-initialize">
|
||||
<javac debug="yes" destdir="${lwjgl.bin}" source="1.5" target="1.5" classpath="${lwjgl.lib}/jinput.jar:${lwjgl.lib}/AppleJavaExtensions.jar:${lwjgl.lib}/asm-debug-all.jar" taskname="core">
|
||||
<javac debug="yes" destdir="${lwjgl.bin}" source="1.7" target="1.7" classpath="${lwjgl.lib}/jinput.jar:${lwjgl.lib}/AppleJavaExtensions.jar:${lwjgl.lib}/asm-debug-all.jar" taskname="core">
|
||||
<!--<compilerarg value="-Xlint:unchecked"/>-->
|
||||
<src path="${lwjgl.src}/java/"/>
|
||||
<src path="${lwjgl.src}/generated/"/>
|
||||
|
|
@ -450,8 +481,8 @@
|
|||
<include name="org/lwjgl/util/**"/>
|
||||
<exclude name="org/lwjgl/util/generator/**"/>
|
||||
</javac>
|
||||
<javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" includes="org/lwjgl/test/**" source="1.5" target="1.5" taskname="test" />
|
||||
<javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" includes="org/lwjgl/examples/**" source="1.5" target="1.5" taskname="examples" />
|
||||
<javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" includes="org/lwjgl/test/**" source="1.7" target="1.7" taskname="test" />
|
||||
<javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" includes="org/lwjgl/examples/**" source="1.7" target="1.7" taskname="examples" />
|
||||
</target>
|
||||
|
||||
<target name="compile_native" depends="-initialize, headers, touch-version, version-mismatch" description="Compiles the native files">
|
||||
|
|
@ -465,6 +496,16 @@
|
|||
</condition>
|
||||
<antcall target="-compile_native_linux" />
|
||||
|
||||
<condition property="lwjgl.platform.freebsd">
|
||||
<os name="FreeBSD" />
|
||||
</condition>
|
||||
<antcall target="-compile_native_freebsd" />
|
||||
|
||||
<condition property="lwjgl.platform.openbsd">
|
||||
<os name="OpenBSD" />
|
||||
</condition>
|
||||
<antcall target="-compile_native_openbsd" />
|
||||
|
||||
<condition property="lwjgl.platform.solaris">
|
||||
<os name="SunOS" />
|
||||
</condition>
|
||||
|
|
@ -494,6 +535,23 @@
|
|||
<!-- headless issues <version-check platform="linux"/> -->
|
||||
</target>
|
||||
|
||||
<!-- Compiles LWJGL on FreeBSD platforms -->
|
||||
<target name="-compile_native_freebsd" if="lwjgl.platform.freebsd">
|
||||
<ant antfile="platform_build/bsd_ant/build.xml" inheritAll="false"/>
|
||||
<copy todir="${lwjgl.lib}/freebsd">
|
||||
<fileset dir="${lwjgl.bin}/lwjgl" includes="liblwjgl*.so"/>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<!-- Compiles LWJGL on OpenBSD platforms -->
|
||||
<target name="-compile_native_openbsd" if="lwjgl.platform.openbsd">
|
||||
<ant antfile="platform_build/bsd_ant/build.xml" inheritAll="false"/>
|
||||
<copy todir="${lwjgl.lib}/openbsd">
|
||||
<fileset dir="${lwjgl.bin}/lwjgl" includes="liblwjgl*.so"/>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
|
||||
<!-- Compiles LWJGL on solaris platforms -->
|
||||
<target name="-compile_native_solaris" if="lwjgl.platform.solaris">
|
||||
<!-- Reusing the linux ant task, but copy the output to solaris -->
|
||||
|
|
@ -507,8 +565,8 @@
|
|||
<!-- Compiles LWJGL on Mac platforms -->
|
||||
<target name="-compile_native_macosx" if="lwjgl.platform.macosx">
|
||||
<ant antfile="platform_build/macosx_ant/build.xml" inheritAll="false"/>
|
||||
<copy file="${lwjgl.bin}/lwjgl/liblwjgl.jnilib" todir="${lwjgl.lib}/macosx"/>
|
||||
<version-check platform="macosx"/>
|
||||
<copy file="${lwjgl.bin}/lwjgl/liblwjgl.dylib" todir="${lwjgl.lib}/macosx"/>
|
||||
<!-- <version-check platform="macosx"/> -->
|
||||
</target>
|
||||
|
||||
<target name="compile_native_es" depends="-initialize, headers, touch-version, version-mismatch" description="Compiles the native files">
|
||||
|
|
@ -625,16 +683,16 @@
|
|||
<bottom><![CDATA[<i>Copyright © 2002-2009 lwjgl.org. All Rights Reserved.</i>]]></bottom>
|
||||
</javadoc>
|
||||
</target>
|
||||
|
||||
|
||||
<!-- get and copy nightly binaries into libs folder -->
|
||||
<target name="copy-nightly-binaries" depends="-initialize" description="Copies latest successful nightly binaries into appropriate libs folder">
|
||||
<delete file="${lwjgl.temp}/lwjgl-${lwjgl.version}.zip" failonerror="false"/>
|
||||
<get src="http://www.newdawnsoftware.com/jenkins/view/LWJGL/job/LWJGL/lastSuccessfulBuild/artifact/dist/lwjgl-${lwjgl.version}.zip" dest="${lwjgl.temp}" verbose="true"/>
|
||||
<get src="http://ci.newdawnsoftware.com/job/LWJGL-git-dist/lastBuild/artifact/dist/lwjgl-${lwjgl.version}.zip" dest="${lwjgl.temp}" verbose="true"/>
|
||||
<unzip src="${lwjgl.temp}/lwjgl-${lwjgl.version}.zip" dest="${lwjgl.lib}" overwrite="true">
|
||||
<patternset>
|
||||
<include name="**/native/**/*lwjgl*"/>
|
||||
</patternset>
|
||||
<globmapper from="lwjgl-${lwjgl.version}/native/*" to="*"/>
|
||||
<globmapper from="lwjgl-${lwjgl.version}/native/*" to="*"/>
|
||||
</unzip>
|
||||
</target>
|
||||
</target>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -22,4 +22,7 @@ org.lwjgl.opengl.Window.undecorated
|
|||
Whether to create an undecorated window (no title bar)
|
||||
|
||||
org.lwjgl.input.Mouse.allowNegativeMouseCoords
|
||||
Usually mouse is clamped to 0,0 - setting this to true will cause you to get negative values if dragging outside and below or left of window
|
||||
Usually mouse is clamped to 0,0 - setting this to true will cause you to get negative values if dragging outside and below or left of window
|
||||
|
||||
org.lwjgl.opengl.Display.enableHighDPI
|
||||
Enable high DPI mode where available
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src/java"/>
|
||||
<classpathentry kind="src" path="test/java"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src/java"/>
|
||||
<classpathentry kind="src" path="test/java"/>
|
||||
<classpathentry kind="output" path="anttasks"/>
|
||||
</classpath>
|
||||
|
|
|
|||
|
|
@ -9,5 +9,6 @@ Import-Package: org.apache.tools.ant,
|
|||
org.apache.tools.ant.types,
|
||||
org.apache.tools.ant.types.selectors,
|
||||
org.apache.tools.ant.util,
|
||||
org.junit;version="4.8.1"
|
||||
org.junit;version="4"
|
||||
Bundle-Vendor: Lightweight Java Game Library Project
|
||||
Require-Bundle: org.junit;bundle-version="4.8.1"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,34 @@
|
|||
How to build the Eclipse update site
|
||||
------------------------------------
|
||||
Author: Jens von Pilgrim <developer@jevopi.de>
|
||||
|
||||
Building the Eclipse update site is fully integrated into the main LWJGL build script.
|
||||
Here is how to build the update site:
|
||||
|
||||
Run main lwjgl ant script (LWJGL/build.xml) with target "eclipse-updatesite"
|
||||
|
||||
You will find the updatesite in
|
||||
LWJGL/eclipse-update/org.lwjgl.build/build/plugins/org.lwjgl.updatesite
|
||||
|
||||
Note that there are two targets: eclipse-updatesite and
|
||||
eclipse-updatesite-simple. The first one depends from the target "release",
|
||||
defined in the main build file. However, if you are sure the relase target has
|
||||
been called before, you may want to only create the update site without
|
||||
building the release target again. In that case, you can all
|
||||
eclipse-update-simple.
|
||||
|
||||
The update site build requires some Java classes to be precompiled. These classes
|
||||
can be found in some zip archives in folder plugin-classes and anttasks.jar.
|
||||
Building these classes requires Eclipse dependencies (in case of the
|
||||
plugin-classes) or they define anttasks required to be present when running ant.
|
||||
In order to build these classes, open all projects found in subfolder
|
||||
LWJGL/eclipse-update in Eclipse: this way, all Eclipse classes will get
|
||||
automatically compiled. Then run the ant script buildEclipseClasses.xml from
|
||||
within Eclipse. Actually, this is rarely necessary as the archives are all
|
||||
committed to the LWJGL SVN and will be present if you check out everything. You
|
||||
only need to run that build if the Eclise plugin classes (or the anttasks) were
|
||||
changed.
|
||||
|
||||
The build plugin is part of the LWJGL Eclipse plugins. The following plugins are
|
||||
required:
|
||||
|
||||
|
|
@ -46,35 +77,11 @@ org.lwjgl.build -- THIS Plugin
|
|||
This is the build script project. Although it is an Eclipse project, you can
|
||||
simply run the build script with ant from command line. See later on.
|
||||
|
||||
Everything is created in org.lwjgl.build/build.
|
||||
Here is how to build the update site:
|
||||
|
||||
1) Create a new folder in org.lwjgl.build/lwjgl-archives , use the version
|
||||
number as folder name. E.g., for version 2.6 create a folder "2.6",
|
||||
for version 2.6.1 "2.6.1" and so on.
|
||||
2) Copy the lwjgl, lwjgl-docs and lwjgl-source zips into that folder. E.g.,
|
||||
for version 2.6, this folder must contain the following files:
|
||||
org.lwjgl.build/lwjgl-archives
|
||||
+ 2.6
|
||||
- lwjgl-2.6.zip
|
||||
- lwjgl-docs-2.6.zip
|
||||
- lwjgl-source-2.6.zip
|
||||
3) In order to run the build script, change to folder org.lwjgl.build and run
|
||||
ant with a parameter indicating the appropriate LWJGL version, e.g.
|
||||
ant -Dversion=2.6 dist
|
||||
|
||||
You will find the updatesite in
|
||||
org.lwjgl.build/build/plugins/org.lwjgl.updatesite
|
||||
|
||||
You may note that the jars are all signed. I have added a temporary keystore
|
||||
with a dummy alias. In order to use your key, simply edit the properties
|
||||
(line 11-14) in the build script. If you do not want to store the password in
|
||||
the build script, simply define it via "-Dstorepass=****" in the command line.
|
||||
Everything is created in LWJGL/eclipse-update/org.lwjgl.build/build.
|
||||
|
||||
Some additional remarks:
|
||||
- The version number is automatically "normalized" to Eclipse standards,
|
||||
that is 2.6 will become 2.6.0. You do not have to rename the initial archives,
|
||||
you can use 2.6. Or 2.6.1 ;-)
|
||||
that is 2.6 will become 2.6.0 with the current date and time added.
|
||||
- The lwjgl-debug.jar is not added to the org.lwjgl plugin, as I do not know
|
||||
how to select one or the other. But I have not further investigated in
|
||||
that direction.
|
||||
|
|
@ -85,4 +92,7 @@ Some additional remarks:
|
|||
to the Eclipse P2 system, which caches a lot of things. Simply uninstalling
|
||||
a plugin does not remove the plugins from the Eclipse installation. When
|
||||
the very same version is re-installed, instead of loading new files from the
|
||||
update site these pre-installed versions are reused!
|
||||
update site these pre-installed versions are reused! Since the date and time
|
||||
is added to the plugin version number, this should cause no problems.
|
||||
- default values for keystore, alias and passphrase are the same as in
|
||||
lwjgl-applet
|
||||
|
|
|
|||
BIN
eclipse-update/org.lwjgl.build/anttasks.jar
Normal file
BIN
eclipse-update/org.lwjgl.build/anttasks.jar
Normal file
Binary file not shown.
500
eclipse-update/org.lwjgl.build/build-updatesite.xml
Normal file
500
eclipse-update/org.lwjgl.build/build-updatesite.xml
Normal file
|
|
@ -0,0 +1,500 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
Called from main build script.
|
||||
Expects
|
||||
lwjgl.version
|
||||
to be set.
|
||||
|
||||
(C) 2011 LWJGL-Project
|
||||
Author: Jens von Pilgrim, developer@jevopi.de
|
||||
-->
|
||||
|
||||
<project default="eclipse-updatesite" basedir="." name="eclipse.antscript" xmlns:ant4eclipse="antlib:org.ant4eclipse" xmlns:antcontrib="antlib:net.sf.antcontrib">
|
||||
|
||||
<dirname property="eclipse.antscript.basedir" file="${ant.file.eclipse.antscript}" />
|
||||
|
||||
<property name="keystore" value="applet/lwjglkeystore" />
|
||||
<property name="alias" value="lwjgl" />
|
||||
<property name="password" value="123456" />
|
||||
|
||||
<property name="eclipse.updatesite" value="http://www.lwjgl.org/update/" />
|
||||
<property name="eclipse.bundle.vendor" value="lwjgl.org" />
|
||||
|
||||
<taskdef name="packagelist" classname="org.lwjgl.ant.PackageList">
|
||||
<classpath>
|
||||
<pathelement location="${eclipse.antscript.basedir}/anttasks.jar" />
|
||||
</classpath>
|
||||
</taskdef>
|
||||
<taskdef name="normalizeversion" classname="org.lwjgl.ant.NormalizeVersion">
|
||||
<classpath>
|
||||
<pathelement location="${eclipse.antscript.basedir}/anttasks.jar" />
|
||||
</classpath>
|
||||
</taskdef>
|
||||
<taskdef name="publishBundlesAndFeatures" classname="org.lwjgl.ant.StandalonePublisher">
|
||||
<classpath>
|
||||
<pathelement location="${eclipse.antscript.basedir}/anttasks.jar" />
|
||||
</classpath>
|
||||
</taskdef>
|
||||
|
||||
<!-- properties imported from build-definitions.xml:
|
||||
<property name="lwjgl.temp" location="temp" />
|
||||
<property name="lwjgl.src" location="src" />
|
||||
<property name="lwjgl.version" value="2.8.3" />
|
||||
-->
|
||||
|
||||
<!-- where to build the update site and temporary build files -->
|
||||
<property name="eclipse.build.path" value="${eclipse.antscript.basedir}/build" />
|
||||
<property name="eclipse.build.temp" value="${eclipse.build.path}/temp" />
|
||||
<property name="eclipse.build.plugins" value="${eclipse.build.path}/plugins" />
|
||||
<property name="eclipse.prebuild-plugin-classes" value="${eclipse.antscript.basedir}/plugin-classes" />
|
||||
|
||||
|
||||
<!-- from where to retrieve LWJGL files -->
|
||||
<property name="eclipse.skeletons.dir" value="${eclipse.antscript.basedir}/.." />
|
||||
|
||||
<!-- base: ${lwjgl.temp} : <patternset refid="lwjgl_applet"/>
|
||||
doc: basedir="${lwjgl.docs}" includes="javadoc/**"
|
||||
source: refid="lwjgl.source.fileset"
|
||||
|
||||
-->
|
||||
|
||||
|
||||
<property name="NL" value=" " />
|
||||
|
||||
|
||||
<target name="eclipse-updatesite">
|
||||
<mkdir dir="${lwjgl.temp}"/>
|
||||
<unzip dest="${lwjgl.temp}/eclipse" src="${lwjgl.dist}/lwjgl-${lwjgl.version}.zip" />
|
||||
<antcall target="eclipse-updatesite-simple" />
|
||||
</target>
|
||||
|
||||
|
||||
<target name="eclipse-updatesite-simple">
|
||||
<normalizeversion version="${lwjgl.version}" property="eclipse.normversion" addDateQualifier="yes" />
|
||||
<echo>Building plugins for version ${lwjgl.version}, normalized version ${eclipse.normversion}</echo>
|
||||
|
||||
<mkdir dir="${eclipse.build.temp}" />
|
||||
|
||||
|
||||
<!-- *******************************************************************
|
||||
*
|
||||
* Assemble plugins
|
||||
*
|
||||
******************************************************************** -->
|
||||
|
||||
<!-- Main plugin: lwjgl.org -->
|
||||
<!-- Copy plugin skeletons -->
|
||||
<mkdir dir="${eclipse.build.plugins}" />
|
||||
<copy todir="${eclipse.build.plugins}/org.lwjgl">
|
||||
<fileset dir="${eclipse.skeletons.dir}/org.lwjgl" casesensitive="yes">
|
||||
<exclude name="**/src/**" />
|
||||
<exclude name="**/*.jar" />
|
||||
<!-- do not copy jars used for development -->
|
||||
<exclude name="**/build/**" />
|
||||
<exclude name="**/build.properties" />
|
||||
<!-- do not copy development settings -->
|
||||
<exclude name="**/.settings/**" />
|
||||
<exclude name="**/.classpath" />
|
||||
<exclude name="**/.project" />
|
||||
<!-- do not copy native libraries -->
|
||||
<exclude name="**/native/**" />
|
||||
</fileset>
|
||||
</copy>
|
||||
<!-- Copy LWJGL native files and classes -->
|
||||
<copy todir="${eclipse.build.plugins}/org.lwjgl">
|
||||
<fileset dir="${lwjgl.temp}/eclipse/lwjgl-${lwjgl.version}/">
|
||||
<patternset refid="lwjgl_base"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
<move todir="${eclipse.build.plugins}/org.lwjgl">
|
||||
<fileset dir="${eclipse.build.plugins}/org.lwjgl/jar">
|
||||
<include name="**" />
|
||||
<exclude name="lwjgl-debug.jar" />
|
||||
</fileset>
|
||||
</move>
|
||||
<delete dir="${eclipse.build.plugins}/org.lwjgl/jar" />
|
||||
<!-- unzip Eclipse dependent classes,
|
||||
have to be previously built by buildEclipseClasses.xml, but
|
||||
are also contained in SVN
|
||||
-->
|
||||
<unzip dest="${eclipse.build.plugins}/org.lwjgl" src="${eclipse.prebuild-plugin-classes}/org.lwjgl.zip" />
|
||||
|
||||
|
||||
<!-- Sources plugin: lwjgl.org.source -->
|
||||
<!-- Copy plugin skeletons -->
|
||||
<copy todir="${eclipse.build.plugins}/org.lwjgl.source">
|
||||
<fileset dir="${eclipse.skeletons.dir}/org.lwjgl.source" casesensitive="yes">
|
||||
<exclude name="**/build.properties" />
|
||||
<exclude name="**/.settings/**" />
|
||||
<exclude name="**/.classpath" />
|
||||
<exclude name="**/.project" />
|
||||
</fileset>
|
||||
</copy>
|
||||
<!-- Create zip files containing the source -->
|
||||
<property name="eclipse.org.lwjgl.src.dir" value="${eclipse.build.plugins}/org.lwjgl.source/src/org.lwjgl_${eclipse.normversion}" />
|
||||
<mkdir dir="${eclipse.org.lwjgl.src.dir}" />
|
||||
<!-- Build src zips for plugin org.lwjgl -->
|
||||
<!-- lwjgl sources (only Java sources) -->
|
||||
<zip destfile="${eclipse.org.lwjgl.src.dir}/lwjglsrc.zip">
|
||||
<fileset dir="${lwjgl.src}/generated" />
|
||||
<fileset dir="${lwjgl.src}/java">
|
||||
<exclude name="org/lwjgl/util/**" />
|
||||
</fileset>
|
||||
</zip>
|
||||
<zip destfile="${eclipse.org.lwjgl.src.dir}/lwjgl_utilsrc.zip">
|
||||
<fileset dir="${lwjgl.src}/java">
|
||||
<include name="org/lwjgl/util/**" />
|
||||
<exclude name="org/lwjgl/util/applet/**" />
|
||||
</fileset>
|
||||
</zip>
|
||||
<zip destfile="${eclipse.org.lwjgl.src.dir}/lwjgl_util_applet.zip">
|
||||
<fileset dir="${lwjgl.src}/java">
|
||||
<include name="org/lwjgl/util/applet/**" />
|
||||
</fileset>
|
||||
</zip>
|
||||
<!-- and the Eclipse related sources -->
|
||||
<zip destfile="${eclipse.org.lwjgl.src.dir}/lwjgl_eclipse.zip">
|
||||
<fileset dir="${eclipse.skeletons.dir}/org.lwjgl/src/java" casesensitive="yes">
|
||||
<include name="org/lwjgl/**" />
|
||||
</fileset>
|
||||
</zip>
|
||||
<zip destfile="${eclipse.org.lwjgl.src.dir}/lwjgl_tools.zip">
|
||||
<fileset dir="${eclipse.skeletons.dir}/org.lwjgl.tools/src/java" casesensitive="yes">
|
||||
<include name="org/lwjgl/**" />
|
||||
</fileset>
|
||||
</zip>
|
||||
<zip destfile="${eclipse.org.lwjgl.src.dir}/lwjgl_info.zip">
|
||||
<fileset dir="${eclipse.skeletons.dir}/org.lwjgl.info/src/java" casesensitive="yes">
|
||||
<include name="org/lwjgl/**" />
|
||||
</fileset>
|
||||
</zip>
|
||||
|
||||
<!-- Documentation plugin: lwjgl.org.doc -->
|
||||
<!-- Copy plugin skeletons including Eclipse documentation-->
|
||||
<copy todir="${eclipse.build.plugins}/org.lwjgl.doc">
|
||||
<fileset dir="${eclipse.skeletons.dir}/org.lwjgl.doc" casesensitive="yes">
|
||||
<exclude name="**/build.properties" />
|
||||
<exclude name="**/.settings/**" />
|
||||
<exclude name="**/.classpath" />
|
||||
<exclude name="**/.project" />
|
||||
</fileset>
|
||||
</copy>
|
||||
<copy todir="${eclipse.build.plugins}/org.lwjgl.doc">
|
||||
<fileset dir="${lwjgl.docs}">
|
||||
<exclude name="javadoc/**" />
|
||||
</fileset>
|
||||
</copy>
|
||||
<!-- create JavaDoc archive -->
|
||||
<zip destfile="${eclipse.build.plugins}/org.lwjgl.doc/doc.zip" basedir="${lwjgl.docs}" includes="javadoc/**" />
|
||||
|
||||
|
||||
<!-- Information view plugin: org.lwjgl.info -->
|
||||
<copy todir="${eclipse.build.plugins}/org.lwjgl.info">
|
||||
<fileset dir="${eclipse.skeletons.dir}/org.lwjgl.info" casesensitive="yes">
|
||||
<exclude name="**/src/**" />
|
||||
<exclude name="**/build/**" />
|
||||
<exclude name="**/build.properties" />
|
||||
<exclude name="**/.settings/**" />
|
||||
<exclude name="**/.classpath" />
|
||||
<exclude name="**/.project" />
|
||||
</fileset>
|
||||
</copy>
|
||||
<!-- unzip Eclipse dependent classes,
|
||||
have to be previously built by buildEclipseClasses.xml, but
|
||||
are also contained in SVN
|
||||
-->
|
||||
<unzip dest="${eclipse.build.plugins}/org.lwjgl.info" src="${eclipse.prebuild-plugin-classes}/org.lwjgl.info.zip" />
|
||||
|
||||
<!-- Tools plugin: org.lwjgl.tools -->
|
||||
<copy todir="${eclipse.build.plugins}/org.lwjgl.tools">
|
||||
<fileset dir="${eclipse.skeletons.dir}/org.lwjgl.tools" casesensitive="yes">
|
||||
<exclude name="**/src/**" />
|
||||
<exclude name="**/build/**" />
|
||||
<exclude name="**/build.properties" />
|
||||
<exclude name="**/.settings/**" />
|
||||
<exclude name="**/.classpath" />
|
||||
<exclude name="**/.project" />
|
||||
</fileset>
|
||||
</copy>
|
||||
<!-- unzip Eclipse dependent classes,
|
||||
have to be previously built by buildEclipseClasses.xml, but
|
||||
are also contained in SVN
|
||||
-->
|
||||
<unzip dest="${eclipse.build.plugins}/org.lwjgl.tools" src="${eclipse.prebuild-plugin-classes}/org.lwjgl.tools.zip" />
|
||||
|
||||
<!-- Feature -->
|
||||
<copy todir="${eclipse.build.plugins}/org.lwjgl.feature">
|
||||
<fileset dir="${eclipse.skeletons.dir}/org.lwjgl.feature" casesensitive="yes">
|
||||
<exclude name="**/build.properties" />
|
||||
<exclude name="**/.settings/**" />
|
||||
<exclude name="**/.classpath" />
|
||||
<exclude name="**/.project" />
|
||||
<exclude name="**/*.template" />
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<!-- Update Site -->
|
||||
<copy todir="${eclipse.build.plugins}/org.lwjgl.updatesite">
|
||||
<fileset dir="${eclipse.skeletons.dir}/org.lwjgl.updatesite" casesensitive="yes">
|
||||
<exclude name="**/.settings/**" />
|
||||
<exclude name="**/.classpath" />
|
||||
<exclude name="**/.project" />
|
||||
<exclude name="**/*.template" />
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
|
||||
<!-- *******************************************************************
|
||||
*
|
||||
* Build manifest files
|
||||
*
|
||||
******************************************************************** -->
|
||||
|
||||
<!-- Calculate package export and bundle class paths -->
|
||||
<packagelist property="eclipse.bundle.export-package" pathsep=",${NL} ">
|
||||
<fileset dir="${lwjgl.temp}/eclipse/lwjgl-${lwjgl.version}/jar">
|
||||
<exclude name="**/lwjgl-debug.jar" />
|
||||
</fileset>
|
||||
<patternset>
|
||||
<exclude name="**/test/**" />
|
||||
<exclude name="**/examples/**" />
|
||||
</patternset>
|
||||
</packagelist>
|
||||
<pathconvert property="eclipse.bundle.classpath.jars" pathsep=",${NL} ">
|
||||
<map from="${lwjgl.temp}/eclipse/lwjgl-${lwjgl.version}/jar/" to="" />
|
||||
<fileset dir="${lwjgl.temp}/eclipse/lwjgl-${lwjgl.version}/jar">
|
||||
<exclude name="**/lwjgl-debug.jar" />
|
||||
<exclude name="**/lwjgl_test.jar" />
|
||||
</fileset>
|
||||
</pathconvert>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- *******************************************************************
|
||||
*
|
||||
* org.lwjgl
|
||||
*
|
||||
* Build manifest files, not using manifest task, since manifest wraps
|
||||
* at the wrong positions (at least ant 1.7)
|
||||
*
|
||||
******************************************************************** -->
|
||||
<echo file="${eclipse.build.plugins}/org.lwjgl/META-INF/MANIFEST.MF" encoding="UTF-8">Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: LWJGL Lightweight Java Game Library
|
||||
Bundle-SymbolicName: org.lwjgl
|
||||
Bundle-Version: ${eclipse.normversion}
|
||||
Bundle-Vendor: ${eclipse.bundle.vendor}
|
||||
Bundle-Activator: org.lwjgl.Activator
|
||||
Require-Bundle: org.eclipse.ui,
|
||||
org.eclipse.core.runtime
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Export-Package: org.lwjgl.eclipse,${NL} ${eclipse.bundle.export-package}
|
||||
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
||||
Bundle-ClassPath: .,${NL} ${eclipse.bundle.classpath.jars}
|
||||
</echo>
|
||||
|
||||
<!-- *******************************************************************
|
||||
*
|
||||
* org.lwjgl.doc
|
||||
*
|
||||
* Build manifest files, not using manifest task, since manifest wraps
|
||||
* at the wrong positions (at least ant 1.7)
|
||||
*
|
||||
******************************************************************** -->
|
||||
|
||||
<echo file="${eclipse.build.plugins}/org.lwjgl.doc/META-INF/MANIFEST.MF" encoding="UTF-8">Manifest-Version: 1.0
|
||||
Bundle-Vendor: ${eclipse.bundle.vendor}
|
||||
Bundle-Version: ${eclipse.normversion}
|
||||
Bundle-SymbolicName: org.lwjgl.doc;singleton:=true
|
||||
Bundle-Localization: plugin
|
||||
Require-Bundle: org.eclipse.help;bundle-version="3.2.0"
|
||||
Eclipse-LazyStart: true
|
||||
</echo>
|
||||
|
||||
|
||||
<!-- *******************************************************************
|
||||
*
|
||||
* org.lwjgl.source
|
||||
*
|
||||
* Build manifest files, not using manifest task, since manifest wraps
|
||||
* at the wrong positions (at least ant 1.7)
|
||||
*
|
||||
******************************************************************** -->
|
||||
|
||||
<!-- Build manfest -->
|
||||
<!-- not using manifest task, since manifest wraps at the wrong positions -->
|
||||
<echo file="${eclipse.build.plugins}/org.lwjgl.source/META-INF/MANIFEST.MF" encoding="UTF-8">Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: LWJGL Sources
|
||||
Bundle-Vendor: ${eclipse.bundle.vendor}
|
||||
Bundle-Version: ${eclipse.normversion}
|
||||
Bundle-SymbolicName: org.lwjgl.source;singleton:=true
|
||||
Bundle-Localization: plugin
|
||||
</echo>
|
||||
|
||||
<!-- *******************************************************************
|
||||
*
|
||||
* org.lwjgl.info
|
||||
*
|
||||
* Build manifest files, not using manifest task, since manifest wraps
|
||||
* at the wrong positions (at least ant 1.7)
|
||||
*
|
||||
******************************************************************** -->
|
||||
<echo file="${eclipse.build.plugins}/org.lwjgl.info/META-INF/MANIFEST.MF" encoding="UTF-8">Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: LWJGL Test and Info View
|
||||
Bundle-Vendor: ${eclipse.bundle.vendor}
|
||||
Bundle-Version: ${eclipse.normversion}
|
||||
Bundle-SymbolicName: org.lwjgl.info;singleton:=true
|
||||
Bundle-Localization: plugin
|
||||
Require-Bundle: org.eclipse.ui,
|
||||
org.eclipse.core.runtime,
|
||||
org.eclipse.ui.views,
|
||||
org.eclipse.core.resources,
|
||||
org.lwjgl
|
||||
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
||||
</echo>
|
||||
<!-- Files are already in place -->
|
||||
|
||||
<!-- *******************************************************************
|
||||
*
|
||||
* org.lwjgl.tools
|
||||
*
|
||||
* Build manifest files, not using manifest task, since manifest wraps
|
||||
* at the wrong positions (at least ant 1.7)
|
||||
*
|
||||
******************************************************************** -->
|
||||
<!-- Build plugin org.lwjgl.tools -->
|
||||
<echo file="${eclipse.build.plugins}/org.lwjgl.tools/META-INF/MANIFEST.MF" encoding="UTF-8">Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: LWJGL Tools Plug-in
|
||||
Bundle-SymbolicName: org.lwjgl.tools;singleton:=true
|
||||
Bundle-Version: ${eclipse.normversion}
|
||||
Bundle-Vendor: ${eclipse.bundle.vendor}
|
||||
Bundle-Activator: org.lwjgl.tools.Activator
|
||||
Require-Bundle: org.eclipse.ui,
|
||||
org.eclipse.core.runtime,
|
||||
org.eclipse.core.resources;bundle-version="3.4.0",
|
||||
org.eclipse.jdt.core;bundle-version="3.4.0",
|
||||
org.eclipse.jdt.ui;bundle-version="3.4.0",
|
||||
org.lwjgl;bundle-version="${eclipse.normversion}",
|
||||
org.eclipse.jdt.launching;bundle-version="3.4.0"
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
||||
</echo>
|
||||
<!-- Files are already in place -->
|
||||
|
||||
|
||||
<!-- Create features -->
|
||||
|
||||
<!-- *******************************************************************
|
||||
*
|
||||
* org.lwjgl.feature
|
||||
*
|
||||
******************************************************************** -->
|
||||
<!-- Build org.lwjgl.feature -->
|
||||
<copy file="${eclipse.skeletons.dir}/org.lwjgl.feature/feature.xml.template" tofile="${eclipse.build.plugins}/org.lwjgl.feature/feature.xml" encoding="UTF-8" overwrite="true">
|
||||
<filterset>
|
||||
<filter token="VERSION" value="${eclipse.normversion}" />
|
||||
<filter token="PROVIDERNAME" value="${eclipse.bundle.vendor}" />
|
||||
<filter token="UPDATEURL" value="${eclipse.updatesite}" />
|
||||
</filterset>
|
||||
</copy>
|
||||
|
||||
|
||||
<!-- *******************************************************************
|
||||
*
|
||||
* org.lwjgl.feature.sdk
|
||||
*
|
||||
******************************************************************** -->
|
||||
<!-- Build org.lwjgl.feature -->
|
||||
<copy file="${eclipse.skeletons.dir}/org.lwjgl.feature.sdk/feature.xml.template" tofile="${eclipse.build.plugins}/org.lwjgl.feature.sdk/feature.xml" encoding="UTF-8" overwrite="true">
|
||||
<filterset>
|
||||
<filter token="VERSION" value="${eclipse.normversion}" />
|
||||
<filter token="PROVIDERNAME" value="${eclipse.bundle.vendor}" />
|
||||
<filter token="UPDATEURL" value="${eclipse.updatesite}" />
|
||||
</filterset>
|
||||
</copy>
|
||||
|
||||
|
||||
<!-- *******************************************************************
|
||||
*
|
||||
* Build update site, i.e. zip all plugins and feature with version
|
||||
* number to appropriate place
|
||||
*
|
||||
******************************************************************** -->
|
||||
<!-- Build update site -->
|
||||
<copy file="${eclipse.skeletons.dir}/org.lwjgl.updatesite/site.xml.template" tofile="${eclipse.build.plugins}/org.lwjgl.updatesite/site.xml" encoding="UTF-8" overwrite="true">
|
||||
<filterset>
|
||||
<filter token="VERSION" value="${eclipse.normversion}" />
|
||||
<filter token="PROVIDERNAME" value="${eclipse.bundle.vendor}" />
|
||||
<filter token="UPDATEURL" value="${eclipse.updatesite}" />
|
||||
</filterset>
|
||||
</copy>
|
||||
<mkdir dir="${eclipse.build.plugins}/org.lwjgl.updatesite/plugins" />
|
||||
<mkdir dir="${eclipse.build.plugins}/org.lwjgl.updatesite/features" />
|
||||
<jar destfile="${eclipse.build.plugins}/org.lwjgl.updatesite/plugins/org.lwjgl_${eclipse.normversion}.jar" manifest="${eclipse.build.plugins}/org.lwjgl/META-INF/MANIFEST.MF">
|
||||
<fileset dir="${eclipse.build.plugins}/org.lwjgl" casesensitive="yes" />
|
||||
</jar>
|
||||
<jar destfile="${eclipse.build.plugins}/org.lwjgl.updatesite/plugins/org.lwjgl.doc_${eclipse.normversion}.jar" manifest="${eclipse.build.plugins}/org.lwjgl.doc/META-INF/MANIFEST.MF">
|
||||
<fileset dir="${eclipse.build.plugins}/org.lwjgl.doc" casesensitive="yes" />
|
||||
</jar>
|
||||
<jar destfile="${eclipse.build.plugins}/org.lwjgl.updatesite/plugins/org.lwjgl.source_${eclipse.normversion}.jar" manifest="${eclipse.build.plugins}/org.lwjgl.source/META-INF/MANIFEST.MF">
|
||||
<fileset dir="${eclipse.build.plugins}/org.lwjgl.source" casesensitive="yes" />
|
||||
</jar>
|
||||
<jar destfile="${eclipse.build.plugins}/org.lwjgl.updatesite/plugins/org.lwjgl.info_${eclipse.normversion}.jar" manifest="${eclipse.build.plugins}/org.lwjgl.info/META-INF/MANIFEST.MF">
|
||||
<fileset dir="${eclipse.build.plugins}/org.lwjgl.info" casesensitive="yes" />
|
||||
</jar>
|
||||
<jar destfile="${eclipse.build.plugins}/org.lwjgl.updatesite/plugins/org.lwjgl.tools_${eclipse.normversion}.jar" manifest="${eclipse.build.plugins}/org.lwjgl.tools/META-INF/MANIFEST.MF">
|
||||
<fileset dir="${eclipse.build.plugins}/org.lwjgl.tools" casesensitive="yes" />
|
||||
</jar>
|
||||
<jar destfile="${eclipse.build.plugins}/org.lwjgl.updatesite/features/org.lwjgl_${eclipse.normversion}.jar">
|
||||
<fileset dir="${eclipse.build.plugins}/org.lwjgl.feature" casesensitive="yes" />
|
||||
</jar>
|
||||
<jar destfile="${eclipse.build.plugins}/org.lwjgl.updatesite/features/org.lwjgl.sdk_${eclipse.normversion}.jar">
|
||||
<fileset dir="${eclipse.build.plugins}/org.lwjgl.feature.sdk" casesensitive="yes" />
|
||||
</jar>
|
||||
|
||||
<!-- *******************************************************************
|
||||
*
|
||||
* Sign plugins and feature
|
||||
*
|
||||
******************************************************************** -->
|
||||
|
||||
<signjar jar="${eclipse.build.plugins}/org.lwjgl.updatesite/features/org.lwjgl_${eclipse.normversion}.jar" keystore="${keystore}" alias="${alias}" storepass="${password}" />
|
||||
<signjar jar="${eclipse.build.plugins}/org.lwjgl.updatesite/features/org.lwjgl.sdk_${eclipse.normversion}.jar" keystore="${keystore}" alias="${alias}" storepass="${password}" />
|
||||
<signjar jar="${eclipse.build.plugins}/org.lwjgl.updatesite/plugins/org.lwjgl_${eclipse.normversion}.jar" keystore="${keystore}" alias="${alias}" storepass="${password}" />
|
||||
<signjar jar="${eclipse.build.plugins}/org.lwjgl.updatesite/plugins/org.lwjgl.doc_${eclipse.normversion}.jar" keystore="${keystore}" alias="${alias}" storepass="${password}" />
|
||||
<signjar jar="${eclipse.build.plugins}/org.lwjgl.updatesite/plugins/org.lwjgl.source_${eclipse.normversion}.jar" keystore="${keystore}" alias="${alias}" storepass="${password}" />
|
||||
<signjar jar="${eclipse.build.plugins}/org.lwjgl.updatesite/plugins/org.lwjgl.info_${eclipse.normversion}.jar" keystore="${keystore}" alias="${alias}" storepass="${password}" />
|
||||
<signjar jar="${eclipse.build.plugins}/org.lwjgl.updatesite/plugins/org.lwjgl.tools_${eclipse.normversion}.jar" keystore="${keystore}" alias="${alias}" storepass="${password}" />
|
||||
|
||||
<!-- *******************************************************************
|
||||
*
|
||||
* Publish plugins and feature
|
||||
* content.xml/jar and artifacts.xml/jar, required for some newer featues
|
||||
* and tools such as Eclipse Tycho.
|
||||
*
|
||||
******************************************************************** -->
|
||||
<publishBundlesAndFeatures compressed="true"
|
||||
updatesitefolder="${eclipse.build.plugins}/org.lwjgl.updatesite"
|
||||
repositoryname="lwjgl.org"
|
||||
repositoryuri="${eclipse.updatesite}" />
|
||||
|
||||
<echo>Created Eclipse update site: ${eclipse.build.plugins}/org.lwjgl.updatesite</echo>
|
||||
</target>
|
||||
|
||||
<target name="eclipse-clean">
|
||||
<delete dir="${eclipse.build.path}" />
|
||||
</target>
|
||||
|
||||
<target name="eclipse-help">
|
||||
<echo>This plugin is to be called from main LWJGL build.xml file.</echo>
|
||||
<echo>It creates the update site, the result will be found in</echo>
|
||||
<echo>${eclipse.build.plugins}/org.lwjgl.updatesite</echo>
|
||||
<echo>For more information, read READ.ME</echo>
|
||||
</target>
|
||||
|
||||
</project>
|
||||
|
|
@ -1,444 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
Call with
|
||||
ant -Dversion=1.9.1 dist
|
||||
(C) 2011 LWJGL-Project
|
||||
Author: Jens von Pilgrim, developer@jevopi.de
|
||||
-->
|
||||
|
||||
<project default="help" basedir="." name="" xmlns:ant4eclipse="antlib:org.ant4eclipse" xmlns:antcontrib="antlib:net.sf.antcontrib">
|
||||
|
||||
<property name="keystore" value="teststore" />
|
||||
<property name="alias" value="tester" />
|
||||
<property name="storepass" value="tester" />
|
||||
<property name="keypass" value="${storepass}" />
|
||||
|
||||
<property name="eclipse.updatesite" value="http://www.lwjgl.org/update/" />
|
||||
<property name="bundle.vendor" value="lwjgl.org" />
|
||||
|
||||
<taskdef name="packagelist" classname="org.lwjgl.ant.PackageList">
|
||||
<classpath>
|
||||
<pathelement location="./anttasks" />
|
||||
</classpath>
|
||||
</taskdef>
|
||||
<taskdef name="normalizeversion" classname="org.lwjgl.ant.NormalizeVersion">
|
||||
<classpath>
|
||||
<pathelement location="./anttasks" />
|
||||
</classpath>
|
||||
</taskdef>
|
||||
|
||||
<property name="version" value="unknown" />
|
||||
<property name="archives.dir" value="lwjgl-archives/${version}" />
|
||||
<property name="skeletons.dir" value=".." />
|
||||
|
||||
<property name="build.path" value="build" />
|
||||
<property name="build.temp" value="${build.path}/temp" />
|
||||
<property name="build.plugins" value="${build.path}/plugins" />
|
||||
|
||||
<property name="lwjgl.zip" value="lwjgl-${version}.zip" />
|
||||
<property name="lwjgl_docs.zip" value="lwjgl-docs-${version}.zip" />
|
||||
<property name="lwjgl_source.zip" value="lwjgl-source-${version}.zip" />
|
||||
|
||||
<property name="lwjgl.dir" value="${build.temp}/lwjgl-${version}" />
|
||||
<property name="lwjgl_docs.dir" value="${build.temp}/javadoc" />
|
||||
<property name="lwjgl_source.dir" value="${build.temp}/src" />
|
||||
|
||||
<property name="NL" value=" " />
|
||||
|
||||
|
||||
|
||||
<!--
|
||||
<property name="" value="" />
|
||||
-->
|
||||
|
||||
|
||||
<target name="init">
|
||||
<normalizeversion version="${version}" property="normversion" />
|
||||
<echo>Building plugins for version ${version}, normalized version ${normversion}</echo>
|
||||
</target>
|
||||
|
||||
|
||||
<target name="dist" depends="init">
|
||||
<mkdir dir="${build.temp}" />
|
||||
|
||||
|
||||
<!-- *******************************************************************
|
||||
*
|
||||
* Copy original plugins to build folder. Copy source to source plugin
|
||||
* only, move classes into place.
|
||||
*
|
||||
******************************************************************** -->
|
||||
<mkdir dir="${build.plugins}" />
|
||||
<copy todir="${build.plugins}/org.lwjgl">
|
||||
<fileset dir="${skeletons.dir}/org.lwjgl" casesensitive="yes">
|
||||
<exclude name="**/src/**" />
|
||||
<exclude name="**/*.jar" />
|
||||
<!-- do not copy jars used for development -->
|
||||
<exclude name="**/build/**" />
|
||||
<exclude name="**/build.properties" />
|
||||
<!-- do not copy development settings -->
|
||||
<exclude name="**/.settings/**" />
|
||||
<exclude name="**/.classpath" />
|
||||
<exclude name="**/.project" />
|
||||
</fileset>
|
||||
</copy>
|
||||
<copy todir="${build.plugins}/org.lwjgl">
|
||||
<fileset dir="${skeletons.dir}/org.lwjgl/build/classes" casesensitive="yes">
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<copy todir="${build.plugins}/org.lwjgl.source">
|
||||
<fileset dir="${skeletons.dir}/org.lwjgl.source" casesensitive="yes">
|
||||
<exclude name="**/build.properties" />
|
||||
<exclude name="**/.settings/**" />
|
||||
<exclude name="**/.classpath" />
|
||||
<exclude name="**/.project" />
|
||||
</fileset>
|
||||
</copy>
|
||||
<copy todir="${build.plugins}/org.lwjgl.doc">
|
||||
<fileset dir="${skeletons.dir}/org.lwjgl.doc" casesensitive="yes">
|
||||
<exclude name="**/build.properties" />
|
||||
<exclude name="**/.settings/**" />
|
||||
<exclude name="**/.classpath" />
|
||||
<exclude name="**/.project" />
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<copy todir="${build.plugins}/org.lwjgl.info">
|
||||
<fileset dir="${skeletons.dir}/org.lwjgl.info" casesensitive="yes">
|
||||
<exclude name="**/src/**" />
|
||||
<exclude name="**/build/**" />
|
||||
<exclude name="**/build.properties" />
|
||||
<exclude name="**/.settings/**" />
|
||||
<exclude name="**/.classpath" />
|
||||
<exclude name="**/.project" />
|
||||
</fileset>
|
||||
</copy>
|
||||
<copy todir="${build.plugins}/org.lwjgl.info">
|
||||
<fileset dir="${skeletons.dir}/org.lwjgl.info/build/classes" casesensitive="yes">
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<copy todir="${build.plugins}/org.lwjgl.tools">
|
||||
<fileset dir="${skeletons.dir}/org.lwjgl.tools" casesensitive="yes">
|
||||
<exclude name="**/src/**" />
|
||||
<exclude name="**/build/**" />
|
||||
<exclude name="**/build.properties" />
|
||||
<exclude name="**/.settings/**" />
|
||||
<exclude name="**/.classpath" />
|
||||
<exclude name="**/.project" />
|
||||
</fileset>
|
||||
</copy>
|
||||
<copy todir="${build.plugins}/org.lwjgl.tools">
|
||||
<fileset dir="${skeletons.dir}/org.lwjgl.tools/build/classes" casesensitive="yes">
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<copy todir="${build.plugins}/org.lwjgl.feature">
|
||||
<fileset dir="${skeletons.dir}/org.lwjgl.feature" casesensitive="yes">
|
||||
<exclude name="**/build.properties" />
|
||||
<exclude name="**/.settings/**" />
|
||||
<exclude name="**/.classpath" />
|
||||
<exclude name="**/.project" />
|
||||
<exclude name="**/*.template" />
|
||||
</fileset>
|
||||
</copy>
|
||||
<copy todir="${build.plugins}/org.lwjgl.updatesite">
|
||||
<fileset dir="${skeletons.dir}/org.lwjgl.updatesite" casesensitive="yes">
|
||||
<exclude name="**/.settings/**" />
|
||||
<exclude name="**/.classpath" />
|
||||
<exclude name="**/.project" />
|
||||
<exclude name="**/*.template" />
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
|
||||
<!-- *******************************************************************
|
||||
*
|
||||
* Unzip archives and move content into approriate plugins
|
||||
*
|
||||
******************************************************************** -->
|
||||
<unzip src="${archives.dir}/${lwjgl.zip}" dest="${build.temp}" />
|
||||
<copy todir="${build.plugins}/org.lwjgl/native">
|
||||
<fileset dir="${lwjgl.dir}/native" />
|
||||
</copy>
|
||||
<copy todir="${build.plugins}/org.lwjgl/">
|
||||
<fileset dir="${lwjgl.dir}/jar">
|
||||
<exclude name="**/lwjgl-debug.jar" />
|
||||
</fileset>
|
||||
</copy>
|
||||
<copy todir="${build.plugins}/org.lwjgl/doc">
|
||||
<fileset dir="${lwjgl.dir}/doc" />
|
||||
</copy>
|
||||
<packagelist property="bundle.export-package" pathsep=",${NL} ">
|
||||
<fileset dir="${lwjgl.dir}/jar">
|
||||
<exclude name="**/lwjgl-debug.jar" />
|
||||
</fileset>
|
||||
<patternset>
|
||||
<exclude name="**/test/**" />
|
||||
<exclude name="**/examples/**" />
|
||||
</patternset>
|
||||
</packagelist>
|
||||
<pathconvert property="bundle.classpath.jars" pathsep=",${NL} ">
|
||||
<map from="${basedir}/${lwjgl.dir}/jar/" to="" />
|
||||
<fileset dir="${lwjgl.dir}/jar">
|
||||
<exclude name="**/lwjgl-debug.jar" />
|
||||
<exclude name="**/lwjgl_test.jar" />
|
||||
</fileset>
|
||||
</pathconvert>
|
||||
|
||||
|
||||
<!-- *******************************************************************
|
||||
*
|
||||
* Build plugins
|
||||
*
|
||||
******************************************************************** -->
|
||||
|
||||
<!-- *******************************************************************
|
||||
*
|
||||
* org.lwjgl
|
||||
*
|
||||
* Build manifest files, not using manifest task, since manifest wraps
|
||||
* at the wrong positions (at least ant 1.7)
|
||||
*
|
||||
******************************************************************** -->
|
||||
<echo file="${build.plugins}/org.lwjgl/META-INF/MANIFEST.MF" encoding="UTF-8">Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: LWJGL Lightweight Java Game Library
|
||||
Bundle-SymbolicName: org.lwjgl
|
||||
Bundle-Version: ${normversion}
|
||||
Bundle-Vendor: ${bundle.vendor}
|
||||
Bundle-Activator: org.lwjgl.eclipse.Activator
|
||||
Require-Bundle: org.eclipse.ui,
|
||||
org.eclipse.core.runtime
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Export-Package: org.lwjgl.eclipse,${NL} ${bundle.export-package}
|
||||
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
||||
Bundle-ClassPath: .,${NL} ${bundle.classpath.jars}
|
||||
</echo>
|
||||
|
||||
<!-- *******************************************************************
|
||||
*
|
||||
* org.lwjgl.doc
|
||||
*
|
||||
* Build manifest files, not using manifest task, since manifest wraps
|
||||
* at the wrong positions (at least ant 1.7)
|
||||
*
|
||||
******************************************************************** -->
|
||||
<copy file="${archives.dir}/${lwjgl_docs.zip}" tofile="${build.plugins}/org.lwjgl.doc/doc.zip" />
|
||||
<echo file="${build.plugins}/org.lwjgl.doc/META-INF/MANIFEST.MF" encoding="UTF-8">Manifest-Version: 1.0
|
||||
Bundle-Vendor: ${bundle.vendor}
|
||||
Bundle-Version: ${normversion}
|
||||
Bundle-SymbolicName: org.lwjgl.doc;singleton:=true
|
||||
Bundle-Localization: plugin
|
||||
Require-Bundle: org.eclipse.help;bundle-version="3.2.0"
|
||||
Eclipse-LazyStart: true
|
||||
</echo>
|
||||
|
||||
|
||||
<!-- *******************************************************************
|
||||
*
|
||||
* org.lwjgl.source
|
||||
*
|
||||
* Build manifest files, not using manifest task, since manifest wraps
|
||||
* at the wrong positions (at least ant 1.7)
|
||||
*
|
||||
******************************************************************** -->
|
||||
<unzip src="${archives.dir}/${lwjgl_source.zip}" dest="${build.temp}" />
|
||||
<!-- Build src zips for plugin org.lwjgl -->
|
||||
<property name="org.lwjgl.src.dir" value="${build.plugins}/org.lwjgl.source/src/org.lwjgl_${normversion}" />
|
||||
<mkdir dir="${org.lwjgl.src.dir}" />
|
||||
<zip destfile="${org.lwjgl.src.dir}/lwjglsrc.zip">
|
||||
<fileset dir="${lwjgl_source.dir}/generated" />
|
||||
<fileset dir="${lwjgl_source.dir}/java">
|
||||
<exclude name="org/lwjgl/util/**" />
|
||||
</fileset>
|
||||
</zip>
|
||||
<zip destfile="${org.lwjgl.src.dir}/lwjgl_utilsrc.zip">
|
||||
<fileset dir="${lwjgl_source.dir}/java">
|
||||
<include name="org/lwjgl/util/**" />
|
||||
<exclude name="org/lwjgl/util/applet/**" />
|
||||
</fileset>
|
||||
</zip>
|
||||
<!--
|
||||
<zip destfile="${org.lwjgl.src.dir}/lwjgl_util_applet.zip">
|
||||
<fileset dir="${lwjgl_source.dir}/java">
|
||||
<include name="org/lwjgl/util/applet/**" />
|
||||
</fileset>
|
||||
</zip>
|
||||
-->
|
||||
<zip destfile="${org.lwjgl.src.dir}/lwjgl_eclipse.zip">
|
||||
<fileset dir="${skeletons.dir}/org.lwjgl/src/java" casesensitive="yes">
|
||||
<include name="org/lwjgl/**" />
|
||||
</fileset>
|
||||
</zip>
|
||||
<zip destfile="${org.lwjgl.src.dir}/lwjgl_tools.zip">
|
||||
<fileset dir="${skeletons.dir}/org.lwjgl.tools/src/java" casesensitive="yes">
|
||||
<include name="org/lwjgl/**" />
|
||||
</fileset>
|
||||
</zip>
|
||||
<zip destfile="${org.lwjgl.src.dir}/lwjgl_info.zip">
|
||||
<fileset dir="${skeletons.dir}/org.lwjgl.info/src/java" casesensitive="yes">
|
||||
<include name="org/lwjgl/**" />
|
||||
</fileset>
|
||||
</zip>
|
||||
|
||||
<!-- Build manfest -->
|
||||
<!-- not using manifest task, since manifest wraps at the wrong positions -->
|
||||
<echo file="${build.plugins}/org.lwjgl.source/META-INF/MANIFEST.MF" encoding="UTF-8">Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: LWJGL Sources
|
||||
Bundle-Vendor: ${bundle.vendor}
|
||||
Bundle-Version: ${normversion}
|
||||
Bundle-SymbolicName: org.lwjgl.source;singleton:=true
|
||||
Bundle-Localization: plugin
|
||||
</echo>
|
||||
|
||||
<!-- *******************************************************************
|
||||
*
|
||||
* org.lwjgl.info
|
||||
*
|
||||
* Build manifest files, not using manifest task, since manifest wraps
|
||||
* at the wrong positions (at least ant 1.7)
|
||||
*
|
||||
******************************************************************** -->
|
||||
<echo file="${build.plugins}/org.lwjgl.info/META-INF/MANIFEST.MF" encoding="UTF-8">Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: LWJGL Test and Info View
|
||||
Bundle-Vendor: ${bundle.vendor}
|
||||
Bundle-Version: ${normversion}
|
||||
Bundle-SymbolicName: org.lwjgl.info;singleton:=true
|
||||
Bundle-Localization: plugin
|
||||
Require-Bundle: org.eclipse.ui,
|
||||
org.eclipse.core.runtime,
|
||||
org.eclipse.ui.views,
|
||||
org.eclipse.core.resources,
|
||||
org.lwjgl
|
||||
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
||||
</echo>
|
||||
<!-- Files are already in place -->
|
||||
|
||||
<!-- *******************************************************************
|
||||
*
|
||||
* org.lwjgl.tools
|
||||
*
|
||||
* Build manifest files, not using manifest task, since manifest wraps
|
||||
* at the wrong positions (at least ant 1.7)
|
||||
*
|
||||
******************************************************************** -->
|
||||
<!-- Build plugin org.lwjgl.tools -->
|
||||
<echo file="${build.plugins}/org.lwjgl.tools/META-INF/MANIFEST.MF" encoding="UTF-8">Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: LWJGL Tools Plug-in
|
||||
Bundle-SymbolicName: org.lwjgl.tools;singleton:=true
|
||||
Bundle-Version: ${normversion}
|
||||
Bundle-Vendor: ${bundle.vendor}
|
||||
Bundle-Activator: org.lwjgl.tools.Activator
|
||||
Require-Bundle: org.eclipse.ui,
|
||||
org.eclipse.core.runtime,
|
||||
org.eclipse.core.resources;bundle-version="3.4.0",
|
||||
org.eclipse.jdt.core;bundle-version="3.4.0",
|
||||
org.eclipse.jdt.ui;bundle-version="3.4.0",
|
||||
org.lwjgl;bundle-version="${normversion}",
|
||||
org.eclipse.jdt.launching;bundle-version="3.4.0"
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
||||
</echo>
|
||||
<!-- Files are already in place -->
|
||||
|
||||
<!-- *******************************************************************
|
||||
*
|
||||
* org.lwjgl.feature
|
||||
*
|
||||
******************************************************************** -->
|
||||
<!-- Build org.lwjgl.feature -->
|
||||
<copy file="${skeletons.dir}/org.lwjgl.feature/feature.xml.template" tofile="${build.plugins}/org.lwjgl.feature/feature.xml" encoding="UTF-8" overwrite="true">
|
||||
<filterset>
|
||||
<filter token="VERSION" value="${normversion}" />
|
||||
<filter token="PROVIDERNAME" value="${bundle.vendor}" />
|
||||
<filter token="UPDATEURL" value="${eclipse.updatesite}" />
|
||||
</filterset>
|
||||
</copy>
|
||||
|
||||
|
||||
|
||||
<!-- *******************************************************************
|
||||
*
|
||||
* org.lwjgl.feature.sdk
|
||||
*
|
||||
*
|
||||
******************************************************************** -->
|
||||
<!-- Build org.lwjgl.feature -->
|
||||
<copy file="${skeletons.dir}/org.lwjgl.feature.sdk/feature.xml.template" tofile="${build.plugins}/org.lwjgl.feature.sdk/feature.xml" encoding="UTF-8" overwrite="true">
|
||||
<filterset>
|
||||
<filter token="VERSION" value="${normversion}" />
|
||||
<filter token="PROVIDERNAME" value="${bundle.vendor}" />
|
||||
<filter token="UPDATEURL" value="${eclipse.updatesite}" />
|
||||
</filterset>
|
||||
</copy>
|
||||
|
||||
<!-- *******************************************************************
|
||||
*
|
||||
* Build update site, i.e. zip all plugins and feature with version
|
||||
* number to appropriate place
|
||||
*
|
||||
******************************************************************** -->
|
||||
<!-- Build update site -->
|
||||
<copy file="${skeletons.dir}/org.lwjgl.updatesite/site.xml.template" tofile="${build.plugins}/org.lwjgl.updatesite/site.xml" encoding="UTF-8" overwrite="true">
|
||||
<filterset>
|
||||
<filter token="VERSION" value="${normversion}" />
|
||||
<filter token="PROVIDERNAME" value="${bundle.vendor}" />
|
||||
<filter token="UPDATEURL" value="${eclipse.updatesite}" />
|
||||
</filterset>
|
||||
</copy>
|
||||
<mkdir dir="${build.plugins}/org.lwjgl.updatesite/plugins" />
|
||||
<mkdir dir="${build.plugins}/org.lwjgl.updatesite/features" />
|
||||
<jar destfile="${build.plugins}/org.lwjgl.updatesite/plugins/org.lwjgl_${normversion}.jar" manifest="${build.plugins}/org.lwjgl/META-INF/MANIFEST.MF">
|
||||
<fileset dir="${build.plugins}/org.lwjgl" casesensitive="yes" />
|
||||
</jar>
|
||||
<jar destfile="${build.plugins}/org.lwjgl.updatesite/plugins/org.lwjgl.doc_${normversion}.jar" manifest="${build.plugins}/org.lwjgl.doc/META-INF/MANIFEST.MF">
|
||||
<fileset dir="${build.plugins}/org.lwjgl.doc" casesensitive="yes" />
|
||||
</jar>
|
||||
<jar destfile="${build.plugins}/org.lwjgl.updatesite/plugins/org.lwjgl.source_${normversion}.jar" manifest="${build.plugins}/org.lwjgl.source/META-INF/MANIFEST.MF">
|
||||
<fileset dir="${build.plugins}/org.lwjgl.source" casesensitive="yes" />
|
||||
</jar>
|
||||
<jar destfile="${build.plugins}/org.lwjgl.updatesite/plugins/org.lwjgl.info_${normversion}.jar" manifest="${build.plugins}/org.lwjgl.info/META-INF/MANIFEST.MF">
|
||||
<fileset dir="${build.plugins}/org.lwjgl.info" casesensitive="yes" />
|
||||
</jar>
|
||||
<jar destfile="${build.plugins}/org.lwjgl.updatesite/plugins/org.lwjgl.tools_${normversion}.jar" manifest="${build.plugins}/org.lwjgl.tools/META-INF/MANIFEST.MF">
|
||||
<fileset dir="${build.plugins}/org.lwjgl.tools" casesensitive="yes" />
|
||||
</jar>
|
||||
<jar destfile="${build.plugins}/org.lwjgl.updatesite/features/org.lwjgl_${normversion}.jar">
|
||||
<fileset dir="${build.plugins}/org.lwjgl.feature" casesensitive="yes" />
|
||||
</jar>
|
||||
<jar destfile="${build.plugins}/org.lwjgl.updatesite/features/org.lwjgl.sdk_${normversion}.jar">
|
||||
<fileset dir="${build.plugins}/org.lwjgl.feature.sdk" casesensitive="yes" />
|
||||
</jar>
|
||||
|
||||
<!-- *******************************************************************
|
||||
*
|
||||
* Sign plugins and feature
|
||||
*
|
||||
******************************************************************** -->
|
||||
|
||||
<signjar jar="${build.plugins}/org.lwjgl.updatesite/features/org.lwjgl_${normversion}.jar" keystore="${keystore}" alias="${alias}" storepass="${storepass}" keypass="${keypass}" />
|
||||
<signjar jar="${build.plugins}/org.lwjgl.updatesite/features/org.lwjgl.sdk_${normversion}.jar" keystore="${keystore}" alias="${alias}" storepass="${storepass}" keypass="${keypass}" />
|
||||
<signjar jar="${build.plugins}/org.lwjgl.updatesite/plugins/org.lwjgl_${normversion}.jar" keystore="${keystore}" alias="${alias}" storepass="${storepass}" keypass="${keypass}" />
|
||||
<signjar jar="${build.plugins}/org.lwjgl.updatesite/plugins/org.lwjgl.doc_${normversion}.jar" keystore="${keystore}" alias="${alias}" storepass="${storepass}" keypass="${keypass}" />
|
||||
<signjar jar="${build.plugins}/org.lwjgl.updatesite/plugins/org.lwjgl.source_${normversion}.jar" keystore="${keystore}" alias="${alias}" storepass="${storepass}" keypass="${keypass}" />
|
||||
<signjar jar="${build.plugins}/org.lwjgl.updatesite/plugins/org.lwjgl.info_${normversion}.jar" keystore="${keystore}" alias="${alias}" storepass="${storepass}" keypass="${keypass}" />
|
||||
<signjar jar="${build.plugins}/org.lwjgl.updatesite/plugins/org.lwjgl.tools_${normversion}.jar" keystore="${keystore}" alias="${alias}" storepass="${storepass}" keypass="${keypass}" />
|
||||
|
||||
</target>
|
||||
|
||||
<target name="clean">
|
||||
<delete dir="${build.path}" />
|
||||
</target>
|
||||
|
||||
<target name="help">
|
||||
<echo>Call this build with version number and target dist, e.g.</echo>
|
||||
<echo> ant -Dversion=1.1.2 dist</echo>
|
||||
</target>
|
||||
|
||||
</project>
|
||||
50
eclipse-update/org.lwjgl.build/buildEclipseClasses.xml
Normal file
50
eclipse-update/org.lwjgl.build/buildEclipseClasses.xml
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
ant
|
||||
(C) 2011 LWJGL-Project
|
||||
Author: Jens von Pilgrim, developer@jevopi.de
|
||||
-->
|
||||
|
||||
<project default="buildClasses" basedir="." name="Build Eclipse classes" xmlns:ant4eclipse="antlib:org.ant4eclipse" xmlns:antcontrib="antlib:net.sf.antcontrib">
|
||||
|
||||
<property name="plugin.lwjgl.org" value="org.lwjgl" />
|
||||
<property name="plugin.lwjgl.org.info" value="org.lwjgl.info" />
|
||||
<property name="plugin.lwjgl.org.tools" value="org.lwjgl.tools" />
|
||||
<property name="classes.folder" value="build/classes" />
|
||||
|
||||
<property name="plugin.build.folder" value="plugin-classes" />
|
||||
|
||||
|
||||
|
||||
<!--
|
||||
<property name="" value="" />
|
||||
-->
|
||||
|
||||
|
||||
<target name="init">
|
||||
<echo></echo>
|
||||
</target>
|
||||
|
||||
<target name="buildClasses" depends="init">
|
||||
<mkdir dir="${plugin.build.folder}" />
|
||||
<zip basedir="../${plugin.lwjgl.org}/${classes.folder}" destfile="${plugin.build.folder}/${plugin.lwjgl.org}.zip" />
|
||||
<zip basedir="../${plugin.lwjgl.org.info}/${classes.folder}" destfile="${plugin.build.folder}/${plugin.lwjgl.org.info}.zip" />
|
||||
<zip basedir="../${plugin.lwjgl.org.tools}/${classes.folder}" destfile="${plugin.build.folder}/${plugin.lwjgl.org.tools}.zip" />
|
||||
|
||||
<jar basedir="anttasks" destfile="anttasks.jar" />
|
||||
</target>
|
||||
|
||||
|
||||
<target name="clean">
|
||||
<delete dir="${plugin.build.folder}" />
|
||||
</target>
|
||||
|
||||
<target name="help">
|
||||
<echo>Call this ant script in order to create archives containing the classes of all</echo>
|
||||
<echo>Eclipes plugin related classes, such as Activors.</echo>
|
||||
<echo>This build file removes the burden of building Eclipse dependent classes from</echo>
|
||||
<echo>within the main build script</echo>
|
||||
</target>
|
||||
|
||||
</project>
|
||||
BIN
eclipse-update/org.lwjgl.build/plugin-classes/org.lwjgl.info.zip
Normal file
BIN
eclipse-update/org.lwjgl.build/plugin-classes/org.lwjgl.info.zip
Normal file
Binary file not shown.
Binary file not shown.
BIN
eclipse-update/org.lwjgl.build/plugin-classes/org.lwjgl.zip
Normal file
BIN
eclipse-update/org.lwjgl.build/plugin-classes/org.lwjgl.zip
Normal file
Binary file not shown.
|
|
@ -11,6 +11,9 @@
|
|||
******************************************************************************/
|
||||
package org.lwjgl.ant;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.tools.ant.BuildException;
|
||||
import org.apache.tools.ant.Task;
|
||||
|
||||
|
|
@ -24,7 +27,11 @@ import org.apache.tools.ant.Task;
|
|||
*/
|
||||
public class NormalizeVersion extends Task {
|
||||
|
||||
|
||||
public final static String SEGMENTS[] = { "major", "minor", "service",
|
||||
"qualifier" };
|
||||
|
||||
public final static String VERSION_QUALIFIER_PATTERN = "yyyyMMdd-HHmm";
|
||||
|
||||
/**
|
||||
* name of the property to set
|
||||
*/
|
||||
|
|
@ -32,6 +39,22 @@ public class NormalizeVersion extends Task {
|
|||
|
||||
protected String version;
|
||||
|
||||
protected boolean addDateQualifier = false;
|
||||
|
||||
/**
|
||||
* @return the addQualifier
|
||||
*/
|
||||
public boolean isAddDateQualifier() {
|
||||
return addDateQualifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param i_addQualifier the addQualifier to set
|
||||
*/
|
||||
public void setAddDateQualifier(boolean i_addDateQualifier) {
|
||||
addDateQualifier = i_addDateQualifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the property
|
||||
*/
|
||||
|
|
@ -57,7 +80,7 @@ public class NormalizeVersion extends Task {
|
|||
* @param i_versionNumber the versionNumber to set
|
||||
*/
|
||||
public void setVersion(String version) {
|
||||
this.version =version;
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -72,6 +95,30 @@ public class NormalizeVersion extends Task {
|
|||
if (version == null) {
|
||||
throw new BuildException("attribute version missing");
|
||||
}
|
||||
String s = getVersion().trim();
|
||||
int sn = 0;
|
||||
boolean qualifier = false;
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
if (s.charAt(i) == '.') {
|
||||
sn++;
|
||||
} else {
|
||||
|
||||
qualifier = !Character.isDigit(s.charAt(i));
|
||||
if (sn < 1 && !Character.isDigit(s.charAt(i))) {
|
||||
|
||||
throw new BuildException(
|
||||
"Wrong version format, must contain only digits in the "
|
||||
+ SEGMENTS[sn] + " segment, was "
|
||||
+ s.substring(0, i) + ">>" + s.charAt(i)
|
||||
+ "<<" + s.substring(i + 1));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((sn > 2 || qualifier) && isAddDateQualifier()) {
|
||||
throw new BuildException(
|
||||
"Cannot add date qualifier, qualifier already specified");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -147,11 +194,11 @@ public class NormalizeVersion extends Task {
|
|||
}
|
||||
n.append(c);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (!qualifier) {
|
||||
if (digits.length()>0) {
|
||||
if (digits.length() > 0) {
|
||||
if (snIndex > 0)
|
||||
n.append('.');
|
||||
n.append(digits);
|
||||
|
|
@ -166,8 +213,25 @@ public class NormalizeVersion extends Task {
|
|||
case 2: // e.g. "1.2.beta
|
||||
n.append(".0");
|
||||
}
|
||||
if (isAddDateQualifier())
|
||||
n.append(createDateQualifier());
|
||||
} else {
|
||||
if (isAddDateQualifier()) {
|
||||
throw new BuildException(
|
||||
"Cannot add date qualifier, qualifier already specified");
|
||||
}
|
||||
}
|
||||
|
||||
return n.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
private String createDateQualifier() {
|
||||
return ".v"
|
||||
+ new SimpleDateFormat(VERSION_QUALIFIER_PATTERN)
|
||||
.format(new Date());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -67,5 +67,42 @@ public class NormalizeVersionTest {
|
|||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testQualifier() {
|
||||
NormalizeVersion t = new NormalizeVersion();
|
||||
t.setProperty("normalized");
|
||||
t.setAddDateQualifier(true);
|
||||
|
||||
t.setVersion("1");
|
||||
String s = t.doExecute();
|
||||
Assert.assertEquals(20, s.length());
|
||||
Assert.assertTrue(s.startsWith("1.0.0"));
|
||||
|
||||
t.setVersion("1.2");
|
||||
s = t.doExecute();
|
||||
Assert.assertEquals(20, s.length());
|
||||
Assert.assertTrue(s.startsWith("1.2.0"));
|
||||
|
||||
t.setVersion("1.2.3");
|
||||
s = t.doExecute();
|
||||
Assert.assertEquals(20, s.length());
|
||||
Assert.assertTrue(s.startsWith("1.2.3"));
|
||||
|
||||
t.setVersion("2.8.2");
|
||||
s = t.doExecute();
|
||||
Assert.assertEquals(20, s.length());
|
||||
Assert.assertTrue(s.startsWith("2.8.2"));
|
||||
|
||||
}
|
||||
|
||||
@Test(expected= BuildException.class) public void dateQualifierWithQualifier() {
|
||||
NormalizeVersion t = new NormalizeVersion();
|
||||
t.setProperty("normalized");
|
||||
t.setAddDateQualifier(true);
|
||||
t.setVersion("1.2.beta");
|
||||
t.doExecute();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
<plugin>
|
||||
<extension point="org.eclipse.ui.views" >
|
||||
<view
|
||||
category="org.eclipse.ui"
|
||||
class="org.lwjgl.info.LWJGLTestView"
|
||||
icon="icons/lwjgl_logo_16.gif"
|
||||
id="org.lwjgl.info.LWJGLTestView"
|
||||
|
|
@ -11,6 +12,7 @@
|
|||
|
||||
<extension point="org.eclipse.ui.views" >
|
||||
<view
|
||||
category="org.eclipse.ui"
|
||||
class="org.lwjgl.info.LWJGLInfoView"
|
||||
icon="icons/lwjgl_logo_16.gif"
|
||||
id="org.lwjgl.info.LWJGLInfoView"
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ import org.eclipse.core.runtime.IBundleGroup;
|
|||
import org.eclipse.core.runtime.IBundleGroupProvider;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.opengl.GLCanvas;
|
||||
import org.eclipse.swt.opengl.GLData;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
import org.eclipse.ui.part.ViewPart;
|
||||
|
|
@ -54,13 +56,23 @@ public class LWJGLInfoView extends ViewPart {
|
|||
*/
|
||||
@Override
|
||||
public void createPartControl(Composite i_parent) {
|
||||
|
||||
Text info = new Text(i_parent, SWT.READ_ONLY | SWT.LEFT | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL );
|
||||
|
||||
|
||||
Text info = new Text(i_parent, SWT.READ_ONLY | SWT.LEFT | SWT.MULTI
|
||||
| SWT.H_SCROLL | SWT.V_SCROLL);
|
||||
|
||||
GLCanvas canvas = new GLCanvas(i_parent, SWT.NONE, new GLData());
|
||||
canvas.setCurrent();
|
||||
try {
|
||||
GLContext.useContext(canvas);
|
||||
} catch (LWJGLException ex) {
|
||||
// TODO Implement catch block for LWJGLException
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
String infoString = gatherInformation();
|
||||
info.setText(infoString);
|
||||
}
|
||||
|
||||
|
||||
static String getFeatureVersion(String myFeatureId) {
|
||||
IBundleGroupProvider[] providers = Platform.getBundleGroupProviders();
|
||||
if (providers != null) {
|
||||
|
|
@ -77,41 +89,36 @@ public class LWJGLInfoView extends ViewPart {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param i_canvas
|
||||
* @return
|
||||
*/
|
||||
public static String gatherInformation() {
|
||||
private static String gatherInformation() {
|
||||
StringBuffer strb = new StringBuffer();
|
||||
|
||||
try {
|
||||
Display.setFullscreen(false);
|
||||
Display.create();
|
||||
} catch (LWJGLException ex) {
|
||||
warnNL(strb, "Error initializing OpenGL display: " + ex.getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
infoNL(strb, "LWJGL feature version", getFeatureVersion("org.lwjgl"));
|
||||
infoNL(strb, "LWJGL feature version",
|
||||
getFeatureVersion("org.lwjgl"));
|
||||
} catch (Exception ex) {
|
||||
warnNL(strb, "Error retrieving feature version: " + ex.getMessage());
|
||||
}
|
||||
|
||||
infoNL(strb, "LWJGL version", Sys.getVersion() + (Sys.is64Bit() ? " (64bit)" : ""));
|
||||
|
||||
infoNL(strb, "Java", System.getProperty("java.version"), System
|
||||
.getProperty("java.vendor"));
|
||||
infoNL(strb, "LWJGL version", Sys.getVersion()
|
||||
+ (Sys.is64Bit() ? " (64bit)" : ""));
|
||||
|
||||
infoNL(strb, "Java", System.getProperty("java.version"),
|
||||
System.getProperty("java.vendor"));
|
||||
infoNL(strb, "Platform", LWJGLUtil.getPlatformName());
|
||||
infoNL(strb, "Graphics card", Display.getAdapter());
|
||||
infoNL(strb, "Driver version", Display.getVersion());
|
||||
infoNL(strb, "OpenGL driver version", GL11.glGetString(GL11.GL_VERSION));
|
||||
|
||||
infoNL(strb, "GLU version", Registry.gluGetString(GLU.GLU_VERSION));
|
||||
infoNL(strb, "GLU extensions", Registry.gluGetString(GLU.GLU_EXTENSIONS));
|
||||
|
||||
|
||||
|
||||
infoNL(strb, "GLU extensions",
|
||||
Registry.gluGetString(GLU.GLU_EXTENSIONS));
|
||||
|
||||
ContextCapabilities caps = GLContext.getCapabilities();
|
||||
openGLVersions(strb, caps);
|
||||
|
||||
|
||||
strb.append(NL).append("Capabilities").append(NL);
|
||||
TreeMap<String, Boolean> capInfos = new TreeMap<String, Boolean>();
|
||||
gatherCapabilities(caps, capInfos);
|
||||
|
|
@ -121,23 +128,37 @@ public class LWJGLInfoView extends ViewPart {
|
|||
|
||||
return strb.toString();
|
||||
}
|
||||
|
||||
|
||||
static void openGLVersions(StringBuffer strb, ContextCapabilities caps) {
|
||||
StringBuffer versions = new StringBuffer();
|
||||
if (caps.OpenGL11) versions.append(", 1.1");
|
||||
if (caps.OpenGL12) versions.append(", 1.2");
|
||||
if (caps.OpenGL13) versions.append(", 1.3");
|
||||
if (caps.OpenGL14) versions.append(", 1.4");
|
||||
if (caps.OpenGL15) versions.append(", 1.5");
|
||||
if (caps.OpenGL20) versions.append(", 2.0");
|
||||
if (caps.OpenGL21) versions.append(", 2.1");
|
||||
if (caps.OpenGL30) versions.append(", 3.0");
|
||||
if (caps.OpenGL31) versions.append(", 3.1");
|
||||
if (caps.OpenGL32) versions.append(", 3.2");
|
||||
if (caps.OpenGL33) versions.append(", 3.3");
|
||||
if (caps.OpenGL40) versions.append(", 4.0");
|
||||
if (caps.OpenGL41) versions.append(", 4.1");
|
||||
if (strb.length()>2) versions.delete(0, 2);
|
||||
if (caps.OpenGL11)
|
||||
versions.append(", 1.1");
|
||||
if (caps.OpenGL12)
|
||||
versions.append(", 1.2");
|
||||
if (caps.OpenGL13)
|
||||
versions.append(", 1.3");
|
||||
if (caps.OpenGL14)
|
||||
versions.append(", 1.4");
|
||||
if (caps.OpenGL15)
|
||||
versions.append(", 1.5");
|
||||
if (caps.OpenGL20)
|
||||
versions.append(", 2.0");
|
||||
if (caps.OpenGL21)
|
||||
versions.append(", 2.1");
|
||||
if (caps.OpenGL30)
|
||||
versions.append(", 3.0");
|
||||
if (caps.OpenGL31)
|
||||
versions.append(", 3.1");
|
||||
if (caps.OpenGL32)
|
||||
versions.append(", 3.2");
|
||||
if (caps.OpenGL33)
|
||||
versions.append(", 3.3");
|
||||
if (caps.OpenGL40)
|
||||
versions.append(", 4.0");
|
||||
if (caps.OpenGL41)
|
||||
versions.append(", 4.1");
|
||||
if (strb.length() > 2)
|
||||
versions.delete(0, 2);
|
||||
infoNL(strb, "Supported OpenGL versions", versions.toString());
|
||||
}
|
||||
|
||||
|
|
@ -178,7 +199,7 @@ public class LWJGLInfoView extends ViewPart {
|
|||
if (groupInfosSupported.isEmpty()) {
|
||||
infoNL(strb, title, "n.a.");
|
||||
} else {
|
||||
|
||||
|
||||
strb.append(title).append(": ");
|
||||
for (int i = 0; i < TAB - title.length(); i++) {
|
||||
strb.append(' ');
|
||||
|
|
@ -214,8 +235,7 @@ public class LWJGLInfoView extends ViewPart {
|
|||
capInfos.put("AMD debug output", caps.GL_AMD_debug_output);
|
||||
capInfos.put("AMD draw buffers blend", caps.GL_AMD_draw_buffers_blend);
|
||||
capInfos.put("AMD name gen delete", caps.GL_AMD_name_gen_delete);
|
||||
capInfos
|
||||
.put("AMD performance monitor", caps.GL_AMD_performance_monitor);
|
||||
capInfos.put("AMD performance monitor", caps.GL_AMD_performance_monitor);
|
||||
capInfos.put("AMD seamless cubemap per texture",
|
||||
caps.GL_AMD_seamless_cubemap_per_texture);
|
||||
capInfos.put("AMD shader stencil export",
|
||||
|
|
@ -225,8 +245,7 @@ public class LWJGLInfoView extends ViewPart {
|
|||
caps.GL_AMD_transform_feedback3_lines_triangles);
|
||||
capInfos.put("AMD vertex shader tessellator",
|
||||
caps.GL_AMD_vertex_shader_tessellator);
|
||||
capInfos
|
||||
.put("APPLE aux depth stencil", caps.GL_APPLE_aux_depth_stencil);
|
||||
capInfos.put("APPLE aux depth stencil", caps.GL_APPLE_aux_depth_stencil);
|
||||
capInfos.put("APPLE client storage", caps.GL_APPLE_client_storage);
|
||||
capInfos.put("APPLE element array", caps.GL_APPLE_element_array);
|
||||
capInfos.put("APPLE fence", caps.GL_APPLE_fence);
|
||||
|
|
@ -246,8 +265,7 @@ public class LWJGLInfoView extends ViewPart {
|
|||
caps.GL_APPLE_vertex_program_evaluators);
|
||||
capInfos.put("APPLE ycbcr 422", caps.GL_APPLE_ycbcr_422);
|
||||
capInfos.put("ARB ES2 compatibility", caps.GL_ARB_ES2_compatibility);
|
||||
capInfos
|
||||
.put("ARB blend func extended", caps.GL_ARB_blend_func_extended);
|
||||
capInfos.put("ARB blend func extended", caps.GL_ARB_blend_func_extended);
|
||||
capInfos.put("ARB cl event", caps.GL_ARB_cl_event);
|
||||
capInfos.put("ARB color buffer float", caps.GL_ARB_color_buffer_float);
|
||||
capInfos.put("ARB compatibility", caps.GL_ARB_compatibility);
|
||||
|
|
@ -286,8 +304,7 @@ public class LWJGLInfoView extends ViewPart {
|
|||
capInfos.put("ARB multitexture", caps.GL_ARB_multitexture);
|
||||
capInfos.put("ARB occlusion query", caps.GL_ARB_occlusion_query);
|
||||
capInfos.put("ARB occlusion query2", caps.GL_ARB_occlusion_query2);
|
||||
capInfos
|
||||
.put("ARB pixel buffer object", caps.GL_ARB_pixel_buffer_object);
|
||||
capInfos.put("ARB pixel buffer object", caps.GL_ARB_pixel_buffer_object);
|
||||
capInfos.put("ARB point parameters", caps.GL_ARB_point_parameters);
|
||||
capInfos.put("ARB point sprite", caps.GL_ARB_point_sprite);
|
||||
capInfos.put("ARB provoking vertex", caps.GL_ARB_provoking_vertex);
|
||||
|
|
@ -297,8 +314,7 @@ public class LWJGLInfoView extends ViewPart {
|
|||
capInfos.put("ARB seamless cube map", caps.GL_ARB_seamless_cube_map);
|
||||
capInfos.put("ARB separate shader objects",
|
||||
caps.GL_ARB_separate_shader_objects);
|
||||
capInfos
|
||||
.put("ARB shader bit encoding", caps.GL_ARB_shader_bit_encoding);
|
||||
capInfos.put("ARB shader bit encoding", caps.GL_ARB_shader_bit_encoding);
|
||||
capInfos.put("ARB shader objects", caps.GL_ARB_shader_objects);
|
||||
capInfos.put("ARB shader precision", caps.GL_ARB_shader_precision);
|
||||
capInfos.put("ARB shader stencil export",
|
||||
|
|
@ -312,16 +328,14 @@ public class LWJGLInfoView extends ViewPart {
|
|||
capInfos.put("ARB shadow", caps.GL_ARB_shadow);
|
||||
capInfos.put("ARB shadow ambient", caps.GL_ARB_shadow_ambient);
|
||||
capInfos.put("ARB sync", caps.GL_ARB_sync);
|
||||
capInfos
|
||||
.put("ARB tessellation shader", caps.GL_ARB_tessellation_shader);
|
||||
capInfos.put("ARB tessellation shader", caps.GL_ARB_tessellation_shader);
|
||||
capInfos.put("ARB texture border clamp",
|
||||
caps.GL_ARB_texture_border_clamp);
|
||||
capInfos.put("ARB texture buffer object",
|
||||
caps.GL_ARB_texture_buffer_object);
|
||||
capInfos.put("ARB texture buffer object rgb32",
|
||||
caps.GL_ARB_texture_buffer_object_rgb32);
|
||||
capInfos
|
||||
.put("ARB texture compression", caps.GL_ARB_texture_compression);
|
||||
capInfos.put("ARB texture compression", caps.GL_ARB_texture_compression);
|
||||
capInfos.put("ARB texture compression bptc",
|
||||
caps.GL_ARB_texture_compression_bptc);
|
||||
capInfos.put("ARB texture compression rgtc",
|
||||
|
|
@ -330,8 +344,7 @@ public class LWJGLInfoView extends ViewPart {
|
|||
capInfos.put("ARB texture cube map array",
|
||||
caps.GL_ARB_texture_cube_map_array);
|
||||
capInfos.put("ARB texture env add", caps.GL_ARB_texture_env_add);
|
||||
capInfos
|
||||
.put("ARB texture env combine", caps.GL_ARB_texture_env_combine);
|
||||
capInfos.put("ARB texture env combine", caps.GL_ARB_texture_env_combine);
|
||||
capInfos.put("ARB texture env crossbar",
|
||||
caps.GL_ARB_texture_env_crossbar);
|
||||
capInfos.put("ARB texture env dot3", caps.GL_ARB_texture_env_dot3);
|
||||
|
|
@ -339,8 +352,7 @@ public class LWJGLInfoView extends ViewPart {
|
|||
capInfos.put("ARB texture gather", caps.GL_ARB_texture_gather);
|
||||
capInfos.put("ARB texture mirrored repeat",
|
||||
caps.GL_ARB_texture_mirrored_repeat);
|
||||
capInfos
|
||||
.put("ARB texture multisample", caps.GL_ARB_texture_multisample);
|
||||
capInfos.put("ARB texture multisample", caps.GL_ARB_texture_multisample);
|
||||
capInfos.put("ARB texture non power of two",
|
||||
caps.GL_ARB_texture_non_power_of_two);
|
||||
capInfos.put("ARB texture query lod", caps.GL_ARB_texture_query_lod);
|
||||
|
|
@ -349,18 +361,14 @@ public class LWJGLInfoView extends ViewPart {
|
|||
capInfos.put("ARB texture rgb10 a2ui", caps.GL_ARB_texture_rgb10_a2ui);
|
||||
capInfos.put("ARB texture swizzle", caps.GL_ARB_texture_swizzle);
|
||||
capInfos.put("ARB timer query", caps.GL_ARB_timer_query);
|
||||
capInfos
|
||||
.put("ARB transform feedback2", caps.GL_ARB_transform_feedback2);
|
||||
capInfos
|
||||
.put("ARB transform feedback3", caps.GL_ARB_transform_feedback3);
|
||||
capInfos.put("ARB transform feedback2", caps.GL_ARB_transform_feedback2);
|
||||
capInfos.put("ARB transform feedback3", caps.GL_ARB_transform_feedback3);
|
||||
capInfos.put("ARB transpose matrix", caps.GL_ARB_transpose_matrix);
|
||||
capInfos.put("ARB uniform buffer object",
|
||||
caps.GL_ARB_uniform_buffer_object);
|
||||
capInfos.put("ARB vertex array bgra", caps.GL_ARB_vertex_array_bgra);
|
||||
capInfos
|
||||
.put("ARB vertex array object", caps.GL_ARB_vertex_array_object);
|
||||
capInfos
|
||||
.put("ARB vertex attrib 64bit", caps.GL_ARB_vertex_attrib_64bit);
|
||||
capInfos.put("ARB vertex array object", caps.GL_ARB_vertex_array_object);
|
||||
capInfos.put("ARB vertex attrib 64bit", caps.GL_ARB_vertex_attrib_64bit);
|
||||
capInfos.put("ARB vertex blend", caps.GL_ARB_vertex_blend);
|
||||
capInfos.put("ARB vertex buffer object",
|
||||
caps.GL_ARB_vertex_buffer_object);
|
||||
|
|
@ -386,10 +394,8 @@ public class LWJGLInfoView extends ViewPart {
|
|||
capInfos.put("ATI texture env combine3",
|
||||
caps.GL_ATI_texture_env_combine3);
|
||||
capInfos.put("ATI texture float", caps.GL_ATI_texture_float);
|
||||
capInfos
|
||||
.put("ATI texture mirror once", caps.GL_ATI_texture_mirror_once);
|
||||
capInfos
|
||||
.put("ATI vertex array object", caps.GL_ATI_vertex_array_object);
|
||||
capInfos.put("ATI texture mirror once", caps.GL_ATI_texture_mirror_once);
|
||||
capInfos.put("ATI vertex array object", caps.GL_ATI_vertex_array_object);
|
||||
capInfos.put("ATI vertex attrib array object",
|
||||
caps.GL_ATI_vertex_attrib_array_object);
|
||||
capInfos.put("ATI vertex streams", caps.GL_ATI_vertex_streams);
|
||||
|
|
@ -399,20 +405,17 @@ public class LWJGLInfoView extends ViewPart {
|
|||
capInfos.put("EXT blend color", caps.GL_EXT_blend_color);
|
||||
capInfos.put("EXT blend equation separate",
|
||||
caps.GL_EXT_blend_equation_separate);
|
||||
capInfos
|
||||
.put("EXT blend func separate", caps.GL_EXT_blend_func_separate);
|
||||
capInfos.put("EXT blend func separate", caps.GL_EXT_blend_func_separate);
|
||||
capInfos.put("EXT blend minmax", caps.GL_EXT_blend_minmax);
|
||||
capInfos.put("EXT blend subtract", caps.GL_EXT_blend_subtract);
|
||||
capInfos.put("EXT Cg shader", caps.GL_EXT_Cg_shader);
|
||||
capInfos.put("EXT compiled vertex array",
|
||||
caps.GL_EXT_compiled_vertex_array);
|
||||
capInfos.put("EXT depth bounds test", caps.GL_EXT_depth_bounds_test);
|
||||
capInfos
|
||||
.put("EXT direct state access", caps.GL_EXT_direct_state_access);
|
||||
capInfos.put("EXT direct state access", caps.GL_EXT_direct_state_access);
|
||||
capInfos.put("EXT draw buffers2", caps.GL_EXT_draw_buffers2);
|
||||
capInfos.put("EXT draw instanced", caps.GL_EXT_draw_instanced);
|
||||
capInfos
|
||||
.put("EXT draw range elements", caps.GL_EXT_draw_range_elements);
|
||||
capInfos.put("EXT draw range elements", caps.GL_EXT_draw_range_elements);
|
||||
capInfos.put("EXT fog coord", caps.GL_EXT_fog_coord);
|
||||
capInfos.put("EXT framebuffer blit", caps.GL_EXT_framebuffer_blit);
|
||||
capInfos.put("EXT framebuffer multisample",
|
||||
|
|
@ -429,8 +432,7 @@ public class LWJGLInfoView extends ViewPart {
|
|||
capInfos.put("EXT packed float", caps.GL_EXT_packed_float);
|
||||
capInfos.put("EXT packed pixels", caps.GL_EXT_packed_pixels);
|
||||
capInfos.put("EXT paletted texture", caps.GL_EXT_paletted_texture);
|
||||
capInfos
|
||||
.put("EXT pixel buffer object", caps.GL_EXT_pixel_buffer_object);
|
||||
capInfos.put("EXT pixel buffer object", caps.GL_EXT_pixel_buffer_object);
|
||||
capInfos.put("EXT point parameters", caps.GL_EXT_point_parameters);
|
||||
capInfos.put("EXT provoking vertex", caps.GL_EXT_provoking_vertex);
|
||||
capInfos.put("EXT rescale normal", caps.GL_EXT_rescale_normal);
|
||||
|
|
@ -457,8 +459,7 @@ public class LWJGLInfoView extends ViewPart {
|
|||
caps.GL_EXT_texture_compression_rgtc);
|
||||
capInfos.put("EXT texture compression s3tc",
|
||||
caps.GL_EXT_texture_compression_s3tc);
|
||||
capInfos
|
||||
.put("EXT texture env combine", caps.GL_EXT_texture_env_combine);
|
||||
capInfos.put("EXT texture env combine", caps.GL_EXT_texture_env_combine);
|
||||
capInfos.put("EXT texture env dot3", caps.GL_EXT_texture_env_dot3);
|
||||
capInfos.put("EXT texture filter anisotropic",
|
||||
caps.GL_EXT_texture_filter_anisotropic);
|
||||
|
|
@ -475,8 +476,7 @@ public class LWJGLInfoView extends ViewPart {
|
|||
capInfos.put("EXT timer query", caps.GL_EXT_timer_query);
|
||||
capInfos.put("EXT transform feedback", caps.GL_EXT_transform_feedback);
|
||||
capInfos.put("EXT vertex array bgra", caps.GL_EXT_vertex_array_bgra);
|
||||
capInfos
|
||||
.put("EXT vertex attrib 64bit", caps.GL_EXT_vertex_attrib_64bit);
|
||||
capInfos.put("EXT vertex attrib 64bit", caps.GL_EXT_vertex_attrib_64bit);
|
||||
capInfos.put("EXT vertex shader", caps.GL_EXT_vertex_shader);
|
||||
capInfos.put("EXT vertex weighting", caps.GL_EXT_vertex_weighting);
|
||||
|
||||
|
|
@ -491,8 +491,7 @@ public class LWJGLInfoView extends ViewPart {
|
|||
capInfos.put("NV depth buffer float", caps.GL_NV_depth_buffer_float);
|
||||
capInfos.put("NV depth clamp", caps.GL_NV_depth_clamp);
|
||||
capInfos.put("NV evaluators", caps.GL_NV_evaluators);
|
||||
capInfos
|
||||
.put("NV explicit multisample", caps.GL_NV_explicit_multisample);
|
||||
capInfos.put("NV explicit multisample", caps.GL_NV_explicit_multisample);
|
||||
capInfos.put("NV fence", caps.GL_NV_fence);
|
||||
capInfos.put("NV float buffer", caps.GL_NV_float_buffer);
|
||||
capInfos.put("NV fog distance", caps.GL_NV_fog_distance);
|
||||
|
|
@ -510,13 +509,11 @@ public class LWJGLInfoView extends ViewPart {
|
|||
capInfos.put("NV gpu shader5", caps.GL_NV_gpu_shader5);
|
||||
capInfos.put("NV half float", caps.GL_NV_half_float);
|
||||
capInfos.put("NV light max exponent", caps.GL_NV_light_max_exponent);
|
||||
capInfos
|
||||
.put("NV multisample coverage", caps.GL_NV_multisample_coverage);
|
||||
capInfos.put("NV multisample coverage", caps.GL_NV_multisample_coverage);
|
||||
capInfos.put("NV multisample filter hint",
|
||||
caps.GL_NV_multisample_filter_hint);
|
||||
capInfos.put("NV occlusion query", caps.GL_NV_occlusion_query);
|
||||
capInfos
|
||||
.put("NV packed depth stencil", caps.GL_NV_packed_depth_stencil);
|
||||
capInfos.put("NV packed depth stencil", caps.GL_NV_packed_depth_stencil);
|
||||
capInfos.put("NV parameter buffer object",
|
||||
caps.GL_NV_parameter_buffer_object);
|
||||
capInfos.put("NV parameter buffer object2",
|
||||
|
|
@ -534,8 +531,7 @@ public class LWJGLInfoView extends ViewPart {
|
|||
capInfos.put("NV texture barrier", caps.GL_NV_texture_barrier);
|
||||
capInfos.put("NV texture compression vtc",
|
||||
caps.GL_NV_texture_compression_vtc);
|
||||
capInfos
|
||||
.put("NV texture env combine4", caps.GL_NV_texture_env_combine4);
|
||||
capInfos.put("NV texture env combine4", caps.GL_NV_texture_env_combine4);
|
||||
capInfos.put("NV texture expand normal",
|
||||
caps.GL_NV_texture_expand_normal);
|
||||
capInfos.put("NV texture rectangle", caps.GL_NV_texture_rectangle);
|
||||
|
|
@ -591,7 +587,11 @@ public class LWJGLInfoView extends ViewPart {
|
|||
io_strb.append(NL);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
Display.setFullscreen(false);
|
||||
Display.create();
|
||||
|
||||
String s = gatherInformation();
|
||||
System.out.println(s);
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
BIN
libs/linux/libopenal64.so
Executable file → Normal file
BIN
libs/linux/libopenal64.so
Executable file → Normal file
Binary file not shown.
BIN
libs/lzma.jar
BIN
libs/lzma.jar
Binary file not shown.
BIN
libs/macosx/openal.dylib
Normal file → Executable file
BIN
libs/macosx/openal.dylib
Normal file → Executable file
Binary file not shown.
BIN
libs/solaris/libopenal.so
Executable file → Normal file
BIN
libs/solaris/libopenal.so
Executable file → Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
147
platform_build/bsd_ant/build.xml
Normal file
147
platform_build/bsd_ant/build.xml
Normal file
|
|
@ -0,0 +1,147 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<project name="lwjgl native code, bsd" basedir="../../bin/lwjgl" default="compile">
|
||||
<property name="native" location="../../src/native"/>
|
||||
<property name="libname32" value="liblwjgl.so"/>
|
||||
<property name="libname64" value="liblwjgl64.so"/>
|
||||
<property name="libs32" value="-L/usr/X11R6/lib -L/usr/local/lib -lm -lX11 -lXext -lXcursor -lXrandr -pthread -L${java.home}/lib/i386 -ljawt" />
|
||||
<property name="libs64" value="-L/usr/X11R6/lib -L/usr/local/lib -lm -lX11 -lXext -lXcursor -lXrandr -lXxf86vm -pthread -L${java.home}/lib/amd64 -ljawt" />
|
||||
<property name="cflags32" value="-O2 -Wall -c -fPIC -std=c99 -Wunused"/>
|
||||
|
||||
<target name="clean">
|
||||
<delete>
|
||||
<fileset dir="x32"/>
|
||||
<fileset dir="x64"/>
|
||||
<fileset dir="." includes="*.o"/>
|
||||
<fileset dir="." includes="*.so"/>
|
||||
</delete>
|
||||
</target>
|
||||
|
||||
<target name="compile">
|
||||
<exec executable="uname" outputproperty="hwplatform">
|
||||
<arg value="-m"/>
|
||||
</exec>
|
||||
<condition property="xf86vm_lib" value="-lXxf86vm" else="-Wl,-static,-lXxf86vm,-call_shared">
|
||||
<os name="SunOS" />
|
||||
</condition>
|
||||
<condition property="cflags_pthread" value="-pthreads" else="-pthread">
|
||||
<os name="SunOS" />
|
||||
</condition>
|
||||
<condition property="version_script_flags32" value="" else="-Wl,--version-script='${native}/linux/lwjgl.map'">
|
||||
<os name="SunOS" />
|
||||
</condition>
|
||||
<condition property="version_script_flags64" value="-m64" else="-Wl,--version-script='${native}/linux/lwjgl.map'">
|
||||
<and>
|
||||
<os name="SunOS" />
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="cflags64" value="-O2 -m64 -Wall -c -fPIC -std=c99 -Wunused" else="-O2 -Wall -c -fPIC -std=c99 -Wunused">
|
||||
<os name="SunOS" />
|
||||
</condition>
|
||||
|
||||
<property name="linker_flags32" value="${version_script_flags32} -shared -O2 -Wall -o ${libname32} ${libs32} ${xf86vm_lib}"/>
|
||||
<property name="linker_flags64" value="${version_script_flags64} -shared -O2 -Wall -o ${libname64} ${libs64} ${xf86vm_lib}"/>
|
||||
|
||||
<condition property="build.32bit.only">
|
||||
<and>
|
||||
<os name="FreeBSD"/>
|
||||
<equals arg1="${hwplatform}" arg2="i386"/>
|
||||
</and>
|
||||
</condition>
|
||||
|
||||
<condition property="build.32bit.only">
|
||||
<and>
|
||||
<os name="OpenBSD"/>
|
||||
<equals arg1="${hwplatform}" arg2="i386"/>
|
||||
</and>
|
||||
</condition>
|
||||
|
||||
<!-- On freebsd, the 64 bit jre doesn't have the 32 bit libs -->
|
||||
<condition property="build.64bit.only">
|
||||
<and>
|
||||
<os name="FreeBSD"/>
|
||||
<equals arg1="${hwplatform}" arg2="amd64"/>
|
||||
</and>
|
||||
</condition>
|
||||
|
||||
<condition property="build.64bit.only">
|
||||
<and>
|
||||
<os name="OpenBSD"/>
|
||||
<equals arg1="${hwplatform}" arg2="amd64"/>
|
||||
</and>
|
||||
</condition>
|
||||
|
||||
<antcall target="compile32"/>
|
||||
<antcall target="compile64"/>
|
||||
</target>
|
||||
|
||||
<target name="compile32" unless="build.64bit.only">
|
||||
<mkdir dir="x32"/>
|
||||
<apply dir="x32" executable="cc" skipemptyfilesets="true" failonerror="true">
|
||||
<arg line="${cflags32} ${cflags_pthread}"/>
|
||||
<arg value="-I${java.home}/include"/>
|
||||
<arg value="-I${java.home}/include/freebsd"/>
|
||||
<arg value="-I${java.home}/include/openbsd"/>
|
||||
<arg value="-I${java.home}/../include"/>
|
||||
<arg value="-I${java.home}/../include/freebsd"/>
|
||||
<arg value="-I${java.home}/../include/openbsd"/>
|
||||
<arg value="-I/usr/local/include"/>
|
||||
<arg value="-I/usr/X11R6/include"/>
|
||||
<arg value="-I${native}/common"/>
|
||||
<arg value="-I${native}/common/opengl"/>
|
||||
<arg value="-I${native}/linux"/>
|
||||
<arg value="-I${native}/linux/opengl"/>
|
||||
<mapper type="glob" from="*.c" to="*.o"/>
|
||||
<fileset dir="${native}/common" includes="*.c"/>
|
||||
<fileset dir="${native}/common/opengl" includes="*.c"/>
|
||||
<fileset dir="${native}/generated/openal" includes="*.c"/>
|
||||
<fileset dir="${native}/generated/opencl" includes="*.c"/>
|
||||
<fileset dir="${native}/generated/opengl" includes="*.c"/>
|
||||
<fileset dir="${native}/linux" includes="*.c"/>
|
||||
<fileset dir="${native}/linux/opengl" includes="*.c"/>
|
||||
</apply>
|
||||
<apply dir="." parallel="true" executable="cc" failonerror="true">
|
||||
<srcfile/>
|
||||
<arg line="${linker_flags32}"/>
|
||||
<fileset dir="x32" includes="*.o"/>
|
||||
</apply>
|
||||
<apply dir="." parallel="true" executable="strip" failonerror="true">
|
||||
<fileset file="${libname32}"/>
|
||||
</apply>
|
||||
</target>
|
||||
|
||||
<target name="compile64" unless="build.32bit.only">
|
||||
<mkdir dir="x64"/>
|
||||
<apply dir="x64" executable="cc" skipemptyfilesets="true" failonerror="true">
|
||||
<arg line="${cflags64} ${cflags_pthread}"/>
|
||||
<arg value="-I${java.home}/include"/>
|
||||
<arg value="-I${java.home}/include/freebsd"/>
|
||||
<arg value="-I${java.home}/include/openbsd"/>
|
||||
<arg value="-I${java.home}/../include"/>
|
||||
<arg value="-I${java.home}/../include/freebsd"/>
|
||||
<arg value="-I${java.home}/../include/openbsd"/>
|
||||
<arg value="-I/usr/local/include"/>
|
||||
<arg value="-I/usr/X11R6/include"/>
|
||||
<arg value="-I${native}/common"/>
|
||||
<arg value="-I${native}/common/opengl"/>
|
||||
<arg value="-I${native}/linux"/>
|
||||
<arg value="-I${native}/linux/opengl"/>
|
||||
<mapper type="glob" from="*.c" to="*.o"/>
|
||||
<fileset dir="${native}/common" includes="*.c"/>
|
||||
<fileset dir="${native}/common/opengl" includes="*.c"/>
|
||||
<fileset dir="${native}/generated/openal" includes="*.c"/>
|
||||
<fileset dir="${native}/generated/opencl" includes="*.c"/>
|
||||
<fileset dir="${native}/generated/opengl" includes="*.c"/>
|
||||
<fileset dir="${native}/linux" includes="*.c"/>
|
||||
<fileset dir="${native}/linux/opengl" includes="*.c"/>
|
||||
</apply>
|
||||
<apply dir="." parallel="true" executable="cc" failonerror="true">
|
||||
<srcfile/>
|
||||
<arg line="${linker_flags64}"/>
|
||||
<fileset dir="x64" includes="*.o"/>
|
||||
</apply>
|
||||
<apply dir="." parallel="true" executable="strip" failonerror="true">
|
||||
<fileset file="${libname64}"/>
|
||||
</apply>
|
||||
</target>
|
||||
</project>
|
||||
|
|
@ -12,13 +12,19 @@
|
|||
<property name="lwjgl.docs" location="doc" />
|
||||
<property name="lwjgl.temp" location="temp" />
|
||||
<property name="lwjgl.res" location="res" />
|
||||
<property name="lwjgl.version" value="2.8.1" />
|
||||
<property name="lwjgl.version" value="2.9.4" />
|
||||
<property name="lwjgl.web" location="www" />
|
||||
|
||||
<property name="opengl-template-pattern" value="org/lwjgl/opengl/GL*.java,org/lwjgl/opengl/ARB*.java,org/lwjgl/opengl/AMD*.java,org/lwjgl/opengl/APPLE*.java,org/lwjgl/opengl/ATI*.java,org/lwjgl/opengl/EXT*.java,org/lwjgl/opengl/NV*.java,org/lwjgl/opengl/NVX*.java,org/lwjgl/opengl/HP*.java,org/lwjgl/opengl/IBM*.java,org/lwjgl/opengl/SUN*.java,org/lwjgl/opengl/SGIS*.java,org/lwjgl/opengl/GREMEDY*.java"/>
|
||||
<property name="opengles-template-pattern" value="org/lwjgl/opengles/GLES*.java,org/lwjgl/opengles/ARB*.java,org/lwjgl/opengles/EXT*.java,org/lwjgl/opengles/AMD*.java,org/lwjgl/opengles/ANGLE*.java,org/lwjgl/opengles/APPLE*.java,org/lwjgl/opengles/ARM*.java,org/lwjgl/opengles/DMP*.java,org/lwjgl/opengles/IMG*.java,org/lwjgl/opengles/NV*.java,org/lwjgl/opengles/OES*.java,org/lwjgl/opengles/QCOM*.java,org/lwjgl/opengles/VIV*.java"/>
|
||||
<property name="opencl-template-pattern-extensions" value="org/lwjgl/opencl/KHR*.java,org/lwjgl/opencl/EXT*.java,org/lwjgl/opencl/APPLE*.java,org/lwjgl/opencl/AMD*.java,org/lwjgl/opencl/INTEL*.java,org/lwjgl/opencl/NV*.java"/>
|
||||
<property name="opencl-template-pattern" value="org/lwjgl/opencl/CL*.java,${opencl-template-pattern-extensions}"/>
|
||||
<property name="lwjgl.src.templates.al" location="${lwjgl.src.templates}/org/lwjgl/openal"/>
|
||||
<property name="lwjgl.src.templates.gl" location="${lwjgl.src.templates}/org/lwjgl/opengl"/>
|
||||
<property name="lwjgl.src.templates.gles" location="${lwjgl.src.templates}/org/lwjgl/opengles"/>
|
||||
<property name="lwjgl.src.templates.cl" location="${lwjgl.src.templates}/org/lwjgl/opencl"/>
|
||||
|
||||
<property name="openal-template-pattern" value="AL*.java,EFX*.java"/>
|
||||
<property name="opengl-template-pattern" value="GL*.java,ARB*.java,EXT*.java,KHR*.java,AMD*.java,APPLE*.java,ATI*.java,NV*.java,NVX*.java,HP*.java,IBM*.java,SUN*.java,SGIS*.java,GREMEDY*.java,INTEL*.java"/>
|
||||
<property name="opengles-template-pattern" value="GLES*.java,ARB*.java,EXT*.java,KHR*.java,AMD*.java,ANGLE*.java,APPLE*.java,ARM*.java,DMP*.java,IMG*.java,NV*.java,OES*.java,QCOM*.java,VIV*.java"/>
|
||||
<property name="opencl-template-pattern-extensions" value="KHR*.java,EXT*.java,APPLE*.java,AMD*.java,INTEL*.java,NV*.java"/>
|
||||
<property name="opencl-template-pattern" value="CL*.java,${opencl-template-pattern-extensions}"/>
|
||||
|
||||
<!-- ================================================================== -->
|
||||
<!-- Filesets used for targets -->
|
||||
|
|
@ -141,12 +147,12 @@
|
|||
<!-- Files to include in mac os x package -->
|
||||
<patternset id="lwjgl-macosx.fileset">
|
||||
<patternset id="lwjgl-macosx-lwjgl.fileset">
|
||||
<include name="liblwjgl.jnilib" />
|
||||
<include name="liblwjgl.dylib" />
|
||||
<include name="openal.dylib" />
|
||||
</patternset>
|
||||
<patternset id="lwjgl-macosx-jinput.fileset">
|
||||
<include name="libjinput-osx.jnilib" />
|
||||
<include name="libjinput-osx-legacy.jnilib" />
|
||||
<include name="libjinput-osx.dylib" />
|
||||
<include name="libjinput-osx-legacy.dylib" />
|
||||
</patternset>
|
||||
</patternset>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<project name="generator">
|
||||
|
||||
<import file="build-definitions.xml"/>
|
||||
|
||||
<!-- clean the generated files -->
|
||||
<target name="clean-generated" description="Deletes the generated java source">
|
||||
<delete quiet="true" failonerror="false">
|
||||
|
|
@ -14,35 +16,42 @@
|
|||
</target>
|
||||
|
||||
<!-- Compiles the Java generator source code -->
|
||||
<target name="generators" description="Compiles the native method generators">
|
||||
<javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" includes="org/lwjgl/util/generator/**.java" source="1.5" target="1.5" taskname="generator">
|
||||
<target name="generators" description="Compiles the native method generators">
|
||||
<mkdir dir="${lwjgl.src}/generated/"/>
|
||||
<mkdir dir="${lwjgl.src.native}/generated/openal"/>
|
||||
<mkdir dir="${lwjgl.src.native}/generated/opengl"/>
|
||||
<mkdir dir="${lwjgl.src.native}/generated/opengles"/>
|
||||
<mkdir dir="${lwjgl.src.native}/generated/opencl"/>
|
||||
<mkdir dir="${lwjgl.bin}"/>
|
||||
|
||||
<javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" source="1.7" target="1.7" includes="org/lwjgl/util/generator/**.java" taskname="generator">
|
||||
<include name="org/lwjgl/util/generator/openal/**.java"/>
|
||||
<include name="org/lwjgl/util/generator/opengl/**.java"/>
|
||||
<include name="org/lwjgl/util/generator/opengles/**.java"/>
|
||||
<include name="org/lwjgl/util/generator/opencl/**.java"/>
|
||||
<compilerarg value="-Xlint:all"/>
|
||||
<compilerarg value="-Xlint:none"/>
|
||||
</javac>
|
||||
<!-- Compile helper classes used by the templates -->
|
||||
<javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" source="1.5" target="1.5" taskname="generator">
|
||||
|
||||
<!-- Compile helper classes used by the templates -->
|
||||
<javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" source="1.7" target="1.7" taskname="generator">
|
||||
<include name="org/lwjgl/PointerWrapper.java"/>
|
||||
<include name="org/lwjgl/PointerBuffer.java"/>
|
||||
<!-- OpenGL -->
|
||||
<include name="org/lwjgl/opengl/GLSync.java"/>
|
||||
<include name="org/lwjgl/opengl/AMDDebugOutputCallback.java"/>
|
||||
<include name="org/lwjgl/opengl/ARBDebugOutputCallback.java"/>
|
||||
<include name="org/lwjgl/opengl/KHRDebugCallback.java"/>
|
||||
<!-- OpenGL ES -->
|
||||
<include name="org/lwjgl/opengles/EGLImageOES.java"/>
|
||||
<include name="org/lwjgl/opengles/KHRDebugCallback.java"/>
|
||||
<!-- OpenCL -->
|
||||
<include name="org/lwjgl/opencl/CLPlatform.java"/>
|
||||
<include name="org/lwjgl/opencl/CLDevice.java"/>
|
||||
<include name="org/lwjgl/opencl/CLContext.java"/>
|
||||
<include name="org/lwjgl/opencl/CLContextCallback.java"/>
|
||||
<include name="org/lwjgl/opencl/CLCommandQueue.java"/>
|
||||
<include name="org/lwjgl/opencl/CLMem.java"/>
|
||||
<include name="org/lwjgl/opencl/CLMemObjectDestructorCallback.java"/>
|
||||
<include name="org/lwjgl/opencl/CLBuildProgramCallback.java"/>
|
||||
<include name="org/lwjgl/opencl/CL*Callback.java"/>
|
||||
<include name="org/lwjgl/opencl/CLNativeKernel.java"/>
|
||||
<include name="org/lwjgl/opencl/CLEventCallback.java"/>
|
||||
<include name="org/lwjgl/opencl/CLFunctionAddress.java"/>
|
||||
</javac>
|
||||
</target>
|
||||
|
|
@ -59,38 +68,48 @@
|
|||
**************************************************************************** -->
|
||||
|
||||
<!-- Generate OpenAL -->
|
||||
<target name="generate-openal" depends="generators" description="Generates java and native source for AL">
|
||||
<apply executable="apt" parallel="true">
|
||||
<arg value="-nocompile"/>
|
||||
<arg value="-factory"/>
|
||||
<arg value="org.lwjgl.util.generator.GeneratorProcessorFactory"/>
|
||||
<arg value="-cp"/>
|
||||
<arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
|
||||
<arg value="-s"/>
|
||||
<arg path="${lwjgl.src}/generated"/>
|
||||
<arg value="-d"/>
|
||||
<arg path="${lwjgl.src.native}/generated/openal"/>
|
||||
<arg value="-Atypemap=org.lwjgl.util.generator.openal.ALTypeMap"/>
|
||||
<fileset dir="${lwjgl.src.templates}" includes="org/lwjgl/openal/AL10.java, org/lwjgl/openal/AL11.java, org/lwjgl/openal/EFX10.java"/>
|
||||
</apply>
|
||||
<target name="generate-openal" depends="generators" description="Generates java and native source for AL">
|
||||
<javac destdir="${lwjgl.bin}" source="1.7" target="1.7" srcdir="${lwjgl.src.templates.al}" fork="true" taskname="processor">
|
||||
<compilerarg value="-proc:only"/>
|
||||
<compilerarg value="-processor"/>
|
||||
<compilerarg value="org.lwjgl.util.generator.GeneratorProcessor"/>
|
||||
<compilerarg value="-cp"/>
|
||||
<compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
|
||||
<compilerarg value="-s"/>
|
||||
<compilerarg path="${lwjgl.src}/generated"/>
|
||||
<compilerarg value="-d"/>
|
||||
<compilerarg path="${lwjgl.src.native}/generated/openal"/>
|
||||
<compilerarg value="-Abinpath=${lwjgl.bin}"/>
|
||||
<compilerarg value="-Atypemap=org.lwjgl.util.generator.openal.ALTypeMap"/>
|
||||
<src>
|
||||
<fileset dir="${lwjgl.src.templates.al}">
|
||||
<include name="${openal-template-pattern}"/>
|
||||
</fileset>
|
||||
</src>
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<!-- Generate OpenAL [DEBUG] -->
|
||||
<target name="generate-openal-debug" depends="generators" description="Generates java and native source for AL">
|
||||
<apply executable="apt" parallel="true">
|
||||
<arg value="-nocompile"/>
|
||||
<arg value="-factory"/>
|
||||
<arg value="org.lwjgl.util.generator.GeneratorProcessorFactory"/>
|
||||
<arg value="-cp"/>
|
||||
<arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
|
||||
<arg value="-s"/>
|
||||
<arg path="${lwjgl.src}/generated"/>
|
||||
<arg value="-d"/>
|
||||
<arg path="${lwjgl.src.native}/generated/openal"/>
|
||||
<arg value="-Atypemap=org.lwjgl.util.generator.openal.ALTypeMap"/>
|
||||
<arg value="-Ageneratechecks"/>
|
||||
<fileset dir="${lwjgl.src.templates}" includes="org/lwjgl/openal/AL10.java, org/lwjgl/openal/AL11.java, org/lwjgl/openal/EFX10.java"/>
|
||||
</apply>
|
||||
<javac destdir="${lwjgl.bin}" source="1.7" target="1.7" srcdir="${lwjgl.src.templates.al}" fork="true" taskname="processor">
|
||||
<compilerarg value="-proc:only"/>
|
||||
<compilerarg value="-processor"/>
|
||||
<compilerarg value="org.lwjgl.util.generator.GeneratorProcessor"/>
|
||||
<compilerarg value="-cp"/>
|
||||
<compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
|
||||
<compilerarg value="-s"/>
|
||||
<compilerarg path="${lwjgl.src}/generated"/>
|
||||
<compilerarg value="-d"/>
|
||||
<compilerarg path="${lwjgl.src.native}/generated/openal"/>
|
||||
<compilerarg value="-Abinpath=${lwjgl.bin}"/>
|
||||
<compilerarg value="-Atypemap=org.lwjgl.util.generator.openal.ALTypeMap"/>
|
||||
<compilerarg value="-Ageneratechecks"/>
|
||||
<src>
|
||||
<fileset dir="${lwjgl.src.templates.al}">
|
||||
<include name="${openal-template-pattern}"/>
|
||||
</fileset>
|
||||
</src>
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<!-- ********************************************************************************
|
||||
|
|
@ -101,84 +120,106 @@
|
|||
|
||||
<!-- Generate OpenGL -->
|
||||
<target name="generate-opengl" depends="generators" description="Generates java and native source for GL">
|
||||
<apply executable="apt" parallel="true">
|
||||
<arg value="-nocompile"/>
|
||||
<arg value="-factory"/>
|
||||
<arg value="org.lwjgl.util.generator.GeneratorProcessorFactory"/>
|
||||
<arg value="-cp"/>
|
||||
<arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
|
||||
<arg value="-s"/>
|
||||
<arg path="${lwjgl.src}/generated"/>
|
||||
<arg value="-d"/>
|
||||
<arg path="${lwjgl.src.native}/generated/opengl"/>
|
||||
<arg value="-Acontextspecific"/>
|
||||
<arg value="-Atypemap=org.lwjgl.util.generator.opengl.GLTypeMap"/>
|
||||
<fileset dir="${lwjgl.src.templates}" includes="${opengl-template-pattern}"/>
|
||||
</apply>
|
||||
<javac destdir="${lwjgl.bin}" source="1.7" target="1.7" srcdir="${lwjgl.src.templates.gl}" fork="true" taskname="processorGL">
|
||||
<compilerarg value="-proc:only"/>
|
||||
<compilerarg value="-processor"/>
|
||||
<compilerarg value="org.lwjgl.util.generator.GeneratorProcessor"/>
|
||||
<compilerarg value="-cp"/>
|
||||
<compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
|
||||
<compilerarg value="-s"/>
|
||||
<compilerarg path="${lwjgl.src}/generated"/>
|
||||
<compilerarg value="-d"/>
|
||||
<compilerarg path="${lwjgl.src.native}/generated/opengl"/>
|
||||
<compilerarg value="-Abinpath=${lwjgl.bin}"/>
|
||||
<compilerarg value="-Atypemap=org.lwjgl.util.generator.opengl.GLTypeMap"/>
|
||||
<compilerarg value="-Acontextspecific"/>
|
||||
<src>
|
||||
<fileset dir="${lwjgl.src.templates.gl}">
|
||||
<include name="${opengl-template-pattern}"/>
|
||||
</fileset>
|
||||
</src>
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<!-- Generate OpenGL [DEBUG] -->
|
||||
<target name="generate-opengl-debug" depends="generators" description="Generates debug java and native source for GL">
|
||||
<apply executable="apt" parallel="true">
|
||||
<arg value="-nocompile"/>
|
||||
<arg value="-factory"/>
|
||||
<arg value="org.lwjgl.util.generator.GeneratorProcessorFactory"/>
|
||||
<arg value="-cp"/>
|
||||
<arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
|
||||
<arg value="-s"/>
|
||||
<arg path="${lwjgl.src}/generated"/>
|
||||
<arg value="-d"/>
|
||||
<arg path="${lwjgl.src.native}/generated/opengl"/>
|
||||
<arg value="-Ageneratechecks"/>
|
||||
<arg value="-Acontextspecific"/>
|
||||
<arg value="-Atypemap=org.lwjgl.util.generator.opengl.GLTypeMap"/>
|
||||
<fileset dir="${lwjgl.src.templates}" includes="${opengl-template-pattern}"/>
|
||||
</apply>
|
||||
<javac destdir="${lwjgl.bin}" source="1.7" target="1.7" srcdir="${lwjgl.src.templates.gl}" fork="true" taskname="processor">
|
||||
<compilerarg value="-proc:only"/>
|
||||
<compilerarg value="-processor"/>
|
||||
<compilerarg value="org.lwjgl.util.generator.GeneratorProcessor"/>
|
||||
<compilerarg value="-cp"/>
|
||||
<compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
|
||||
<compilerarg value="-s"/>
|
||||
<compilerarg path="${lwjgl.src}/generated"/>
|
||||
<compilerarg value="-d"/>
|
||||
<compilerarg path="${lwjgl.src.native}/generated/opengl"/>
|
||||
<compilerarg value="-Abinpath=${lwjgl.bin}"/>
|
||||
<compilerarg value="-Ageneratechecks"/>
|
||||
<compilerarg value="-Acontextspecific"/>
|
||||
<compilerarg value="-Atypemap=org.lwjgl.util.generator.opengl.GLTypeMap"/>
|
||||
<src>
|
||||
<fileset dir="${lwjgl.src.templates.gl}">
|
||||
<include name="${opengl-template-pattern}"/>
|
||||
</fileset>
|
||||
</src>
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<!-- Generate OpenGL references -->
|
||||
<target name="generate-opengl-references" depends="generators" description="Generates java and native source for GL">
|
||||
<apply executable="apt" parallel="true">
|
||||
<arg value="-nocompile"/>
|
||||
<arg value="-factory"/>
|
||||
<arg value="org.lwjgl.util.generator.opengl.GLReferencesGeneratorProcessorFactory"/>
|
||||
<arg value="-cp"/>
|
||||
<arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
|
||||
<arg value="-s"/>
|
||||
<arg path="${lwjgl.src}/generated"/>
|
||||
<fileset dir="${lwjgl.src.templates}" includes="${opengl-template-pattern}"/>
|
||||
</apply>
|
||||
<javac destdir="${lwjgl.bin}" source="1.7" target="1.7" srcdir="${lwjgl.src.templates.gl}" fork="true" taskname="processor">
|
||||
<compilerarg value="-proc:only"/>
|
||||
<compilerarg value="-processor"/>
|
||||
<compilerarg value="org.lwjgl.util.generator.opengl.GLReferencesGeneratorProcessor"/>
|
||||
<compilerarg value="-cp"/>
|
||||
<compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
|
||||
<compilerarg value="-s"/>
|
||||
<compilerarg path="${lwjgl.src}/generated"/>
|
||||
<src>
|
||||
<fileset dir="${lwjgl.src.templates.gl}">
|
||||
<include name="${opengl-template-pattern}"/>
|
||||
</fileset>
|
||||
</src>
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<!-- Generate OpenGL context capabilities -->
|
||||
<target name="generate-opengl-capabilities" depends="generators" description="Generates java and native source for GL">
|
||||
<apply executable="apt" parallel="true">
|
||||
<arg value="-nocompile"/>
|
||||
<arg value="-factory"/>
|
||||
<arg value="org.lwjgl.util.generator.opengl.GLGeneratorProcessorFactory"/>
|
||||
<arg value="-cp"/>
|
||||
<arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
|
||||
<arg value="-s"/>
|
||||
<arg path="${lwjgl.src}/generated"/>
|
||||
<arg value="-Acontextspecific"/>
|
||||
<fileset dir="${lwjgl.src.templates}" includes="${opengl-template-pattern}"/>
|
||||
</apply>
|
||||
<javac destdir="${lwjgl.bin}" source="1.7" target="1.7" srcdir="${lwjgl.src.templates.gl}" fork="true" taskname="processor">
|
||||
<compilerarg value="-proc:only"/>
|
||||
<compilerarg value="-processor"/>
|
||||
<compilerarg value="org.lwjgl.util.generator.opengl.GLGeneratorProcessor"/>
|
||||
<compilerarg value="-cp"/>
|
||||
<compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
|
||||
<compilerarg value="-s"/>
|
||||
<compilerarg path="${lwjgl.src}/generated"/>
|
||||
<compilerarg value="-Acontextspecific"/>
|
||||
<src>
|
||||
<fileset dir="${lwjgl.src.templates.gl}">
|
||||
<include name="${opengl-template-pattern}"/>
|
||||
</fileset>
|
||||
</src>
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<!-- Generate OpenGL context capabilities [DEBUG] -->
|
||||
<target name="generate-opengl-capabilities-debug" depends="generators" description="Generates debug java and native source for GL">
|
||||
<apply executable="apt" parallel="true">
|
||||
<arg value="-nocompile"/>
|
||||
<arg value="-factory"/>
|
||||
<arg value="org.lwjgl.util.generator.opengl.GLGeneratorProcessorFactory"/>
|
||||
<arg value="-cp"/>
|
||||
<arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
|
||||
<arg value="-s"/>
|
||||
<arg path="${lwjgl.src}/generated"/>
|
||||
<arg value="-Ageneratechecks"/>
|
||||
<arg value="-Acontextspecific"/>
|
||||
<fileset dir="${lwjgl.src.templates}" includes="${opengl-template-pattern}"/>
|
||||
</apply>
|
||||
<javac destdir="${lwjgl.bin}" source="1.7" target="1.7" srcdir="${lwjgl.src.templates.gl}" fork="true" taskname="processor">
|
||||
<compilerarg value="-proc:only"/>
|
||||
<compilerarg value="-processor"/>
|
||||
<compilerarg value="org.lwjgl.util.generator.opengl.GLGeneratorProcessor"/>
|
||||
<compilerarg value="-cp"/>
|
||||
<compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
|
||||
<compilerarg value="-s"/>
|
||||
<compilerarg path="${lwjgl.src}/generated"/>
|
||||
<compilerarg value="-Ageneratechecks"/>
|
||||
<compilerarg value="-Acontextspecific"/>
|
||||
<src>
|
||||
<fileset dir="${lwjgl.src.templates.gl}">
|
||||
<include name="${opengl-template-pattern}"/>
|
||||
</fileset>
|
||||
</src>
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<!-- ********************************************************************************
|
||||
|
|
@ -189,70 +230,88 @@
|
|||
|
||||
<!-- Generate OpenGL ES -->
|
||||
<target name="generate-opengles" depends="generators" description="Generates java and native source for GL ES">
|
||||
<apply executable="apt" parallel="true">
|
||||
<arg value="-nocompile"/>
|
||||
<arg value="-factory"/>
|
||||
<arg value="org.lwjgl.util.generator.GeneratorProcessorFactory"/>
|
||||
<arg value="-cp"/>
|
||||
<arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
|
||||
<arg value="-s"/>
|
||||
<arg path="${lwjgl.src}/generated"/>
|
||||
<arg value="-d"/>
|
||||
<arg path="${lwjgl.src.native}/generated/opengles"/>
|
||||
<!--<arg value="-Acontextspecific"/>-->
|
||||
<arg value="-Atypemap=org.lwjgl.util.generator.opengl.GLESTypeMap"/>
|
||||
<fileset dir="${lwjgl.src.templates}" includes="${opengles-template-pattern}"/>
|
||||
</apply>
|
||||
<javac destdir="${lwjgl.bin}" source="1.7" target="1.7" srcdir="${lwjgl.src.templates.gles}" fork="true" taskname="processor">
|
||||
<compilerarg value="-proc:only"/>
|
||||
<compilerarg value="-processor"/>
|
||||
<compilerarg value="org.lwjgl.util.generator.GeneratorProcessor"/>
|
||||
<compilerarg value="-cp"/>
|
||||
<compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
|
||||
<compilerarg value="-s"/>
|
||||
<compilerarg path="${lwjgl.src}/generated"/>
|
||||
<compilerarg value="-d"/>
|
||||
<compilerarg path="${lwjgl.src.native}/generated/opengles"/>
|
||||
<compilerarg value="-Abinpath=${lwjgl.bin}"/>
|
||||
<!--<compilerarg value="-Acontextspecific"/>-->
|
||||
<compilerarg value="-Atypemap=org.lwjgl.util.generator.opengl.GLESTypeMap"/>
|
||||
<src>
|
||||
<fileset dir="${lwjgl.src.templates.gles}">
|
||||
<include name="${opengles-template-pattern}"/>
|
||||
</fileset>
|
||||
</src>
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<!-- Generate OpenGL ES [DEBUG] -->
|
||||
<target name="generate-opengles-debug" depends="generators" description="Generates debug java and native source for GL ES">
|
||||
<apply executable="apt" parallel="true">
|
||||
<arg value="-nocompile"/>
|
||||
<arg value="-factory"/>
|
||||
<arg value="org.lwjgl.util.generator.GeneratorProcessorFactory"/>
|
||||
<arg value="-cp"/>
|
||||
<arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
|
||||
<arg value="-s"/>
|
||||
<arg path="${lwjgl.src}/generated"/>
|
||||
<arg value="-d"/>
|
||||
<arg path="${lwjgl.src.native}/generated/opengles"/>
|
||||
<arg value="-Ageneratechecks"/>
|
||||
<!--<arg value="-Acontextspecific"/>-->
|
||||
<arg value="-Atypemap=org.lwjgl.util.generator.opengl.GLESTypeMap"/>
|
||||
<fileset dir="${lwjgl.src.templates}" includes="${opengles-template-pattern}"/>
|
||||
</apply>
|
||||
<javac destdir="${lwjgl.bin}" source="1.7" target="1.7" srcdir="${lwjgl.src.templates.gles}" fork="true" taskname="processor">
|
||||
<compilerarg value="-proc:only"/>
|
||||
<compilerarg value="-processor"/>
|
||||
<compilerarg value="org.lwjgl.util.generator.GeneratorProcessor"/>
|
||||
<compilerarg value="-cp"/>
|
||||
<compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
|
||||
<compilerarg value="-s"/>
|
||||
<compilerarg path="${lwjgl.src}/generated"/>
|
||||
<compilerarg value="-d"/>
|
||||
<compilerarg path="${lwjgl.src.native}/generated/opengles"/>
|
||||
<compilerarg value="-Abinpath=${lwjgl.bin}"/>
|
||||
<compilerarg value="-Ageneratechecks"/>
|
||||
<!--<compilerarg value="-Acontextspecific"/>-->
|
||||
<compilerarg value="-Atypemap=org.lwjgl.util.generator.opengl.GLESTypeMap"/>
|
||||
<src>
|
||||
<fileset dir="${lwjgl.src.templates.gles}">
|
||||
<include name="${opengles-template-pattern}"/>
|
||||
</fileset>
|
||||
</src>
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<!-- Generate OpenGL ES context capabilities -->
|
||||
<target name="generate-opengles-capabilities" depends="generators" description="Generates java and native source for GL ES">
|
||||
<apply executable="apt" parallel="true">
|
||||
<arg value="-nocompile"/>
|
||||
<arg value="-factory"/>
|
||||
<arg value="org.lwjgl.util.generator.opengl.GLESGeneratorProcessorFactory"/>
|
||||
<arg value="-cp"/>
|
||||
<arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
|
||||
<arg value="-s"/>
|
||||
<arg path="${lwjgl.src}/generated"/>
|
||||
<!--<arg value="-Acontextspecific"/>-->
|
||||
<fileset dir="${lwjgl.src.templates}" includes="${opengles-template-pattern}"/>
|
||||
</apply>
|
||||
<javac destdir="${lwjgl.bin}" source="1.7" target="1.7" srcdir="${lwjgl.src.templates.gles}" fork="true" taskname="processor">
|
||||
<compilerarg value="-proc:only"/>
|
||||
<compilerarg value="-processor"/>
|
||||
<compilerarg value="org.lwjgl.util.generator.opengl.GLESGeneratorProcessor"/>
|
||||
<compilerarg value="-cp"/>
|
||||
<compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
|
||||
<compilerarg value="-s"/>
|
||||
<compilerarg path="${lwjgl.src}/generated"/>
|
||||
<!--<compilerarg value="-Acontextspecific"/>-->
|
||||
<src>
|
||||
<fileset dir="${lwjgl.src.templates.gles}">
|
||||
<include name="${opengles-template-pattern}"/>
|
||||
</fileset>
|
||||
</src>
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<!-- Generate OpenGL ES context capabilities [DEBUG] -->
|
||||
<target name="generate-opengles-capabilities-debug" depends="generators" description="Generates debug java and native source for GL ES">
|
||||
<apply executable="apt" parallel="true">
|
||||
<arg value="-nocompile"/>
|
||||
<arg value="-factory"/>
|
||||
<arg value="org.lwjgl.util.generator.opengl.GLESGeneratorProcessorFactory"/>
|
||||
<arg value="-cp"/>
|
||||
<arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
|
||||
<arg value="-s"/>
|
||||
<arg path="${lwjgl.src}/generated"/>
|
||||
<arg value="-Ageneratechecks"/>
|
||||
<!--<arg value="-Acontextspecific"/>-->
|
||||
<fileset dir="${lwjgl.src.templates}" includes="${opengles-template-pattern}"/>
|
||||
</apply>
|
||||
<javac destdir="${lwjgl.bin}" source="1.7" target="1.7" srcdir="${lwjgl.src.templates.gles}" fork="true" taskname="processor">
|
||||
<compilerarg value="-proc:only"/>
|
||||
<compilerarg value="-processor"/>
|
||||
<compilerarg value="org.lwjgl.util.generator.opengl.GLESGeneratorProcessor"/>
|
||||
<compilerarg value="-cp"/>
|
||||
<compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
|
||||
<compilerarg value="-s"/>
|
||||
<compilerarg path="${lwjgl.src}/generated"/>
|
||||
<compilerarg value="-Ageneratechecks"/>
|
||||
<!--<compilerarg value="-Acontextspecific"/>-->
|
||||
<src>
|
||||
<fileset dir="${lwjgl.src.templates.gles}">
|
||||
<include name="${opengles-template-pattern}"/>
|
||||
</fileset>
|
||||
</src>
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<!-- ********************************************************************************
|
||||
|
|
@ -263,69 +322,87 @@
|
|||
|
||||
<!-- Generate OpenCL -->
|
||||
<target name="generate-opencl" depends="generators" description="Generates java and native source for CL">
|
||||
<apply executable="apt" parallel="true">
|
||||
<arg value="-nocompile"/>
|
||||
<arg value="-factory"/>
|
||||
<arg value="org.lwjgl.util.generator.GeneratorProcessorFactory"/>
|
||||
<arg value="-cp"/>
|
||||
<arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
|
||||
<arg value="-s"/>
|
||||
<arg path="${lwjgl.src}/generated"/>
|
||||
<arg value="-d"/>
|
||||
<arg path="${lwjgl.src.native}/generated/opencl"/>
|
||||
<arg value="-Acontextspecific"/>
|
||||
<arg value="-Atypemap=org.lwjgl.util.generator.opencl.CLTypeMap"/>
|
||||
<fileset dir="${lwjgl.src.templates}" includes="${opencl-template-pattern}"/>
|
||||
</apply>
|
||||
<javac destdir="${lwjgl.bin}" source="1.7" target="1.7" srcdir="${lwjgl.src.templates.cl}" fork="true" taskname="processor">
|
||||
<compilerarg value="-proc:only"/>
|
||||
<compilerarg value="-processor"/>
|
||||
<compilerarg value="org.lwjgl.util.generator.GeneratorProcessor"/>
|
||||
<compilerarg value="-cp"/>
|
||||
<compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
|
||||
<compilerarg value="-s"/>
|
||||
<compilerarg path="${lwjgl.src}/generated"/>
|
||||
<compilerarg value="-d"/>
|
||||
<compilerarg path="${lwjgl.src.native}/generated/opencl"/>
|
||||
<compilerarg value="-Abinpath=${lwjgl.bin}"/>
|
||||
<compilerarg value="-Acontextspecific"/>
|
||||
<compilerarg value="-Atypemap=org.lwjgl.util.generator.opencl.CLTypeMap"/>
|
||||
<src>
|
||||
<fileset dir="${lwjgl.src.templates.cl}">
|
||||
<include name="${opencl-template-pattern}"/>
|
||||
</fileset>
|
||||
</src>
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<!-- Generate OpenCL [DEBUG] -->
|
||||
<target name="generate-opencl-debug" depends="generators" description="Generates debug java and native source for CL">
|
||||
<apply executable="apt" parallel="true">
|
||||
<arg value="-nocompile"/>
|
||||
<arg value="-factory"/>
|
||||
<arg value="org.lwjgl.util.generator.GeneratorProcessorFactory"/>
|
||||
<arg value="-cp"/>
|
||||
<arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
|
||||
<arg value="-s"/>
|
||||
<arg path="${lwjgl.src}/generated"/>
|
||||
<arg value="-d"/>
|
||||
<arg path="${lwjgl.src.native}/generated/opencl"/>
|
||||
<arg value="-Ageneratechecks"/>
|
||||
<arg value="-Acontextspecific"/>
|
||||
<arg value="-Atypemap=org.lwjgl.util.generator.opencl.CLTypeMap"/>
|
||||
<fileset dir="${lwjgl.src.templates}" includes="${opencl-template-pattern}"/>
|
||||
</apply>
|
||||
<javac destdir="${lwjgl.bin}" source="1.7" target="1.7" srcdir="${lwjgl.src.templates.cl}" fork="true" taskname="processor">
|
||||
<compilerarg value="-proc:only"/>
|
||||
<compilerarg value="-processor"/>
|
||||
<compilerarg value="org.lwjgl.util.generator.GeneratorProcessor"/>
|
||||
<compilerarg value="-cp"/>
|
||||
<compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
|
||||
<compilerarg value="-s"/>
|
||||
<compilerarg path="${lwjgl.src}/generated"/>
|
||||
<compilerarg value="-d"/>
|
||||
<compilerarg path="${lwjgl.src.native}/generated/opencl"/>
|
||||
<compilerarg value="-Abinpath=${lwjgl.bin}"/>
|
||||
<compilerarg value="-Ageneratechecks"/>
|
||||
<compilerarg value="-Acontextspecific"/>
|
||||
<compilerarg value="-Atypemap=org.lwjgl.util.generator.opencl.CLTypeMap"/>
|
||||
<src>
|
||||
<fileset dir="${lwjgl.src.templates.cl}">
|
||||
<include name="${opencl-template-pattern}"/>
|
||||
</fileset>
|
||||
</src>
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<!-- Generate OpenCL capabilities -->
|
||||
<target name="generate-opencl-capabilities" depends="generators" description="Generates capabilities for CL">
|
||||
<apply executable="apt" parallel="true">
|
||||
<arg value="-nocompile"/>
|
||||
<arg value="-factory"/>
|
||||
<arg value="org.lwjgl.util.generator.opencl.CLGeneratorProcessorFactory"/>
|
||||
<arg value="-cp"/>
|
||||
<arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
|
||||
<arg value="-s"/>
|
||||
<arg path="${lwjgl.src}/generated"/>
|
||||
<arg value="-Acontextspecific"/>
|
||||
<fileset dir="${lwjgl.src.templates}" includes="${opencl-template-pattern}"/>
|
||||
</apply>
|
||||
<javac destdir="${lwjgl.bin}" source="1.7" target="1.7" srcdir="${lwjgl.src.templates.cl}" fork="true" taskname="processor">
|
||||
<compilerarg value="-proc:only"/>
|
||||
<compilerarg value="-processor"/>
|
||||
<compilerarg value="org.lwjgl.util.generator.opencl.CLGeneratorProcessor"/>
|
||||
<compilerarg value="-cp"/>
|
||||
<compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
|
||||
<compilerarg value="-s"/>
|
||||
<compilerarg path="${lwjgl.src}/generated"/>
|
||||
<compilerarg value="-Acontextspecific"/>
|
||||
<src>
|
||||
<fileset dir="${lwjgl.src.templates.cl}">
|
||||
<include name="${opencl-template-pattern}"/>
|
||||
</fileset>
|
||||
</src>
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<!-- Generate OpenCL capabilities [DEBUG] -->
|
||||
<target name="generate-opencl-capabilities-debug" depends="generators" description="Generates debug capabilities for CL">
|
||||
<apply executable="apt" parallel="true">
|
||||
<arg value="-nocompile"/>
|
||||
<arg value="-factory"/>
|
||||
<arg value="org.lwjgl.util.generator.opencl.CLGeneratorProcessorFactory"/>
|
||||
<arg value="-cp"/>
|
||||
<arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
|
||||
<arg value="-s"/>
|
||||
<arg path="${lwjgl.src}/generated"/>
|
||||
<arg value="-Ageneratechecks"/>
|
||||
<arg value="-Acontextspecific"/>
|
||||
<fileset dir="${lwjgl.src.templates}" includes="${opencl-template-pattern}"/>
|
||||
</apply>
|
||||
<javac destdir="${lwjgl.bin}" source="1.7" target="1.7" srcdir="${lwjgl.src.templates.cl}" fork="true" taskname="processor">
|
||||
<compilerarg value="-proc:only"/>
|
||||
<compilerarg value="-processor"/>
|
||||
<compilerarg value="org.lwjgl.util.generator.opencl.CLGeneratorProcessor"/>
|
||||
<compilerarg value="-cp"/>
|
||||
<compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
|
||||
<compilerarg value="-s"/>
|
||||
<compilerarg path="${lwjgl.src}/generated"/>
|
||||
<compilerarg value="-Ageneratechecks"/>
|
||||
<compilerarg value="-Acontextspecific"/>
|
||||
<src>
|
||||
<fileset dir="${lwjgl.src.templates.cl}">
|
||||
<include name="${opencl-template-pattern}"/>
|
||||
</fileset>
|
||||
</src>
|
||||
</javac>
|
||||
</target>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<property name="native" location="../../src/native"/>
|
||||
<property name="libname32" value="liblwjgl.so"/>
|
||||
<property name="libname64" value="liblwjgl64.so"/>
|
||||
<property name="libs32" value="-L/usr/X11R6/lib -L/usr/X11/lib -lm -lX11 -lXext -lXcursor -lXrandr -lpthread -L${java.home}/lib/i386 -ljawt" />
|
||||
<property name="libs32" value="-L/usr/X11R6/lib -L/usr/X11/lib -lm -lX11 -lXext -lXcursor -lXrandr -lXxf86vm -lpthread -L${java.home}/lib/i386 -ljawt" />
|
||||
<property name="libs64" value="-L/usr/X11R6/lib64 -L/usr/X11/lib64 -lm -lX11 -lXext -lXcursor -lXrandr -lXxf86vm -lpthread -L${java.home}/lib/amd64 -ljawt" />
|
||||
<property name="cflags32" value="-O2 -Wall -c -fPIC -std=c99 -Wunused"/>
|
||||
|
||||
|
|
@ -21,9 +21,6 @@
|
|||
<exec executable="uname" outputproperty="hwplatform">
|
||||
<arg value="-m"/>
|
||||
</exec>
|
||||
<condition property="xf86vm_lib" value="-lXxf86vm" else="-Wl,-static,-lXxf86vm,-call_shared">
|
||||
<os name="SunOS" />
|
||||
</condition>
|
||||
<condition property="cflags_pthread" value="-pthreads" else="-pthread">
|
||||
<os name="SunOS" />
|
||||
</condition>
|
||||
|
|
@ -39,8 +36,8 @@
|
|||
<os name="SunOS" />
|
||||
</condition>
|
||||
|
||||
<property name="linker_flags32" value="${version_script_flags32} -shared -O2 -Wall -o ${libname32} ${libs32} ${xf86vm_lib}"/>
|
||||
<property name="linker_flags64" value="${version_script_flags64} -shared -O2 -Wall -o ${libname64} ${libs64} ${xf86vm_lib}"/>
|
||||
<property name="linker_flags32" value="${version_script_flags32} -shared -O2 -Wall -o ${libname32} ${libs32}"/>
|
||||
<property name="linker_flags64" value="${version_script_flags64} -shared -O2 -Wall -o ${libname64} ${libs64}"/>
|
||||
|
||||
<condition property="build.32bit.only">
|
||||
<not>
|
||||
|
|
@ -65,7 +62,7 @@
|
|||
|
||||
<target name="compile32" unless="build.64bit.only">
|
||||
<mkdir dir="x32"/>
|
||||
<apply dir="x32" executable="gcc" skipemptyfilesets="true" failonerror="true">
|
||||
<apply dir="x32" executable="gcc" skipemptyfilesets="true" failonerror="true" parallel="true">
|
||||
<arg line="${cflags32} ${cflags_pthread}"/>
|
||||
<arg value="-I${java.home}/include"/>
|
||||
<arg value="-I${java.home}/include/linux"/>
|
||||
|
|
@ -97,7 +94,7 @@
|
|||
|
||||
<target name="compile64" unless="build.32bit.only">
|
||||
<mkdir dir="x64"/>
|
||||
<apply dir="x64" executable="gcc" skipemptyfilesets="true" failonerror="true">
|
||||
<apply dir="x64" executable="gcc" skipemptyfilesets="true" failonerror="true" parallel="true">
|
||||
<arg line="${cflags64} ${cflags_pthread}"/>
|
||||
<arg value="-I${java.home}/include"/>
|
||||
<arg value="-I${java.home}/include/linux"/>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@
|
|||
<property name="native" location="../../src/native"/>
|
||||
<property name="libname32" value="liblwjgl.so"/>
|
||||
<property name="libname64" value="liblwjgl64.so"/>
|
||||
<property name="libs32" value="-L/home/spasi/lwjgl/libs/linux -lEGL -L/usr/X11R6/lib -L/usr/X11/lib -lm -lX11 -lXext -lXcursor -lXrandr -lpthread -L${java.home}/lib/i386 -ljawt" />
|
||||
<property name="lib_folder" value="${lwjgl.lib}/linux"/>
|
||||
<property name="libs32" value="-L${lib_folder} -lEGL -L/usr/X11R6/lib -L/usr/X11/lib -lm -lX11 -lXext -lXcursor -lXrandr -lXxf86vm -lpthread -L${java.home}/lib/i386 -ljawt" />
|
||||
<property name="libs64" value="-L${lib_folder}/x64 -lEGL -L/usr/X11R6/lib64 -L/usr/X11/lib64 -lm -lX11 -lXext -lXcursor -lXrandr -lXxf86vm -lpthread -L${java.home}/lib/amd64 -ljawt" />
|
||||
<property name="cflags32" value="-O2 -Wall -c -fPIC -std=c99 -Wunused"/>
|
||||
|
||||
|
|
@ -21,9 +22,6 @@
|
|||
<exec executable="uname" outputproperty="hwplatform">
|
||||
<arg value="-m"/>
|
||||
</exec>
|
||||
<condition property="xf86vm_lib" value="-lXxf86vm" else="-Wl,-static,-lXxf86vm,-call_shared">
|
||||
<os name="SunOS" />
|
||||
</condition>
|
||||
<condition property="cflags_pthread" value="-pthreads" else="-pthread">
|
||||
<os name="SunOS" />
|
||||
</condition>
|
||||
|
|
@ -39,8 +37,8 @@
|
|||
<os name="SunOS" />
|
||||
</condition>
|
||||
|
||||
<property name="linker_flags32" value="${version_script_flags32} -shared -O2 -Wall -o ${libname32} ${libs32} ${xf86vm_lib}"/>
|
||||
<property name="linker_flags64" value="${version_script_flags64} -shared -O2 -Wall -o ${libname64} ${libs64} ${xf86vm_lib}"/>
|
||||
<property name="linker_flags32" value="${version_script_flags32} -shared -O2 -Wall -o ${libname32} ${libs32}"/>
|
||||
<property name="linker_flags64" value="${version_script_flags64} -shared -O2 -Wall -o ${libname64} ${libs64}"/>
|
||||
|
||||
<condition property="build.32bit.only">
|
||||
<not>
|
||||
|
|
@ -126,4 +124,4 @@
|
|||
<fileset file="${libname64}"/>
|
||||
</apply>
|
||||
</target>
|
||||
</project>
|
||||
</project>
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
nm -g "$1"/*.o | grep "Java_" | cut -d ' ' -f3 | cut -c 1-
|
||||
nm -g "$1"/*.o | grep "JNI_" | cut -d ' ' -f3 | cut -c 1-
|
||||
nm -j -g "$1"/*.o | grep -E "J(ava|NI)_[^.]*$"
|
||||
|
|
|
|||
|
|
@ -1,103 +1,220 @@
|
|||
|
||||
<project name="OS X Native code" basedir="../../bin/lwjgl" default="nativelibrary">
|
||||
<property name="native" location="../../src/native"/>
|
||||
|
||||
<target name="init">
|
||||
<mkdir dir="ppc"/>
|
||||
<mkdir dir="i386"/>
|
||||
<mkdir dir="x86_64"/>
|
||||
</target>
|
||||
|
||||
<target name="clean">
|
||||
<delete failonerror="false">
|
||||
<fileset dir="i386"/>
|
||||
<fileset dir="x86_64"/>
|
||||
<fileset dir="ppc"/>
|
||||
<fileset dir="." includes="liblwjgl.jnilib"/>
|
||||
<fileset dir="." includes="lwjgl.symbols"/>
|
||||
</delete>
|
||||
</target>
|
||||
|
||||
<target name="compile">
|
||||
<apply dir="${dstdir}" executable="${compiler}" os="Mac OS X" skipemptyfilesets="true" failonerror="true" dest="${dstdir}">
|
||||
<arg line="${cflags} -ObjC -O2 -Wall -Wunused -c -fPIC -I/System/Library/Frameworks/JavaVM.framework/Versions/A/Headers -I${native}/common -I${native}/common/opengl -I${native}/macosx -I/System/Library/Frameworks/JavaVM.framework/Versions/A/Frameworks/JavaNativeFoundation.framework/Versions/A/Headers"/>
|
||||
<!-- Map from *.m and *.c to .o -->
|
||||
<mapper type="regexp" from="^(.*)\.(c|m)" to="\1.o"/>
|
||||
<fileset dir="${native}/macosx" includes="*.m"/>
|
||||
<fileset dir="${native}/macosx" includes="*.c"/>
|
||||
<fileset dir="${native}/common" includes="*.c"/>
|
||||
<fileset dir="${native}/common/opengl" includes="*.c"/>
|
||||
<fileset dir="${native}/generated/openal" includes="*.c"/>
|
||||
<fileset dir="${native}/generated/opencl" includes="*.c"/>
|
||||
<fileset dir="${native}/generated/opengl" includes="*.c"/>
|
||||
</apply>
|
||||
</target>
|
||||
|
||||
<target name="link">
|
||||
<apply dir="${objdir}" parallel="true" executable="${linker}" os="Mac OS X" failonerror="true" skipemptyfilesets="true">
|
||||
<arg line="${linkerflags} -exported_symbols_list ../lwjgl.symbols -dynamiclib -o ${libname} -framework Foundation -framework AppKit -framework JavaVM -framework Carbon -framework OpenGL -framework JavaNativeFoundation -F/System/Library/Frameworks/JavaVM.framework/Frameworks"/>
|
||||
<fileset dir="${objdir}" includes="*.o"/>
|
||||
</apply>
|
||||
<apply dir="${objdir}" executable="strip" os="Mac OS X" failonerror="true">
|
||||
<arg line="-S -X"/>
|
||||
<fileset dir="." file="${libname}"/>
|
||||
</apply>
|
||||
</target>
|
||||
|
||||
<target name="nativelibrary" depends="init">
|
||||
<property name="universal_sdkroot" location="/Developer/SDKs/MacOSX10.6.sdk"/>
|
||||
<property name="ppc_sdkroot" location="/Developer/SDKs/MacOSX10.6.sdk"/>
|
||||
<property name="x86_64_sdkroot" location="/Developer/SDKs/MacOSX10.6.sdk"/>
|
||||
<property name="universal_flags" value="-isysroot ${universal_sdkroot}"/>
|
||||
<property name="ppc_flags" value="-isysroot ${ppc_sdkroot}"/>
|
||||
<antcall target="compile">
|
||||
<param name="dstdir" location="ppc"/>
|
||||
<param name="compiler" value="gcc-4.2"/>
|
||||
<param name="sdkroot" location="${ppc_sdkroot}"/>
|
||||
<param name="cflags" value="${universal_flags} -arch ppc -mmacosx-version-min=10.3"/>
|
||||
</antcall>
|
||||
<antcall target="compile">
|
||||
<param name="dstdir" location="i386"/>
|
||||
<param name="compiler" value="gcc-4.2"/>
|
||||
<param name="sdkroot" location="${universal_sdkroot}"/>
|
||||
<param name="cflags" value="${universal_flags} -arch i386 -mmacosx-version-min=10.4"/>
|
||||
</antcall>
|
||||
<antcall target="compile">
|
||||
<param name="dstdir" location="x86_64"/>
|
||||
<param name="compiler" value="gcc-4.2"/>
|
||||
<param name="sdkroot" location="${universal_sdkroot}"/>
|
||||
<param name="cflags" value="-isysroot ${x86_64_sdkroot} -arch x86_64 -mmacosx-version-min=10.5"/>
|
||||
</antcall>
|
||||
<exec vmlauncher="true" executable="sh" output="lwjgl.symbols" failonerror="true">
|
||||
<arg path="../../platform_build/macosx_ant/build-symbol-list"/>
|
||||
<arg path="i386"/>
|
||||
</exec>
|
||||
<antcall target="link">
|
||||
<param name="objdir" location="ppc"/>
|
||||
<param name="libname" value="liblwjgl-ppc.jnilib"/>
|
||||
<param name="linker" value="gcc-4.2"/>
|
||||
<param name="linkerflags" value="${universal_flags} -arch ppc -mmacosx-version-min=10.3"/>
|
||||
</antcall>
|
||||
<antcall target="link">
|
||||
<param name="objdir" location="i386"/>
|
||||
<param name="libname" value="liblwjgl-i386.jnilib"/>
|
||||
<param name="linker" value="gcc-4.2"/>
|
||||
<param name="linkerflags" value="${universal_flags} -arch i386 -mmacosx-version-min=10.4"/>
|
||||
</antcall>
|
||||
<antcall target="link">
|
||||
<param name="objdir" location="x86_64"/>
|
||||
<param name="libname" value="liblwjgl-i86_64.jnilib"/>
|
||||
<param name="linker" value="gcc-4.2"/>
|
||||
<param name="linkerflags" value="-isysroot ${x86_64_sdkroot} -arch x86_64 -mmacosx-version-min=10.5"/>
|
||||
</antcall>
|
||||
<apply dir="." parallel="true" executable="lipo" os="Mac OS X" failonerror="true" skipemptyfilesets="true" >
|
||||
<arg value="-create"/>
|
||||
<srcfile/>
|
||||
<arg value="-output"/>
|
||||
<arg path="liblwjgl.jnilib"/>
|
||||
<fileset file="ppc/liblwjgl-ppc.jnilib"/>
|
||||
<fileset file="i386/liblwjgl-i386.jnilib"/>
|
||||
<fileset file="x86_64/liblwjgl-i86_64.jnilib"/>
|
||||
</apply>
|
||||
</target>
|
||||
</project>
|
||||
<project name="OS X Native code" basedir="../../bin/lwjgl" default="nativelibrary">
|
||||
<property name="native" location="../../src/native"/>
|
||||
|
||||
<target name="init">
|
||||
<mkdir dir="arm64"/>
|
||||
<property environment="env" />
|
||||
<!-- Ask Xcode for correct path to XCode tools -->
|
||||
<!-- Will fail if XCode Command Line Tools are not installed on 10.7+ (Lion) -->
|
||||
<exec executable="xcode-select" outputproperty="developer_path" errorproperty="xcode-select.error" failonerror="false" failifexecutionfails="false">
|
||||
<arg value="-print-path" />
|
||||
</exec>
|
||||
<!-- Default to /Developer if xcode-select fails -->
|
||||
<condition property="developer_path" value="/Developer">
|
||||
<isset property="xcode-select.error" />
|
||||
</condition>
|
||||
|
||||
<property name="sdk_path" value="Platforms/MacOSX.platform/Developer/SDKs"/>
|
||||
<property name="jvm_headers_path" value="/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/include/"/>
|
||||
<property name="sdkroot" value="${developer_path}/${sdk_path}/MacOSX.sdk"/>
|
||||
|
||||
<!-- Choose a JavaVM.framework -->
|
||||
<condition property="javavmroot" value="${developer_path}/${sdk_path}/MacOSX10.9.sdk">
|
||||
<and>
|
||||
<not><isset property="javavmroot"/></not>
|
||||
<available file="${developer_path}/${sdk_path}/MacOSX10.9.sdk/${jvm_headers_path}" type="dir"/>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="javavmroot" value="${developer_path}/${sdk_path}/MacOSX10.8.sdk">
|
||||
<and>
|
||||
<not><isset property="javavmroot"/></not>
|
||||
<available file="${developer_path}/${sdk_path}/MacOSX10.8.sdk/${jvm_headers_path}" type="dir"/>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="javavmroot" value="${developer_path}/${sdk_path}/MacOSX10.7.sdk">
|
||||
<and>
|
||||
<not><isset property="javavmroot"/></not>
|
||||
<available file="${developer_path}/${sdk_path}/MacOSX10.7.sdk/${jvm_headers_path}" type="dir"/>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="javavmroot" value="${developer_path}/${sdk_path}/MacOSX10.6.sdk">
|
||||
<and>
|
||||
<not><isset property="javavmroot"/></not>
|
||||
<available file="${developer_path}/${sdk_path}/MacOSX10.6.sdk/${jvm_headers_path}" type="dir"/>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="javavmroot" value=""> <!-- Old location -->
|
||||
<and>
|
||||
<not><isset property="javavmroot"/></not>
|
||||
<available file="/${jvm_headers_path}" type="dir"/>
|
||||
</and>
|
||||
</condition>
|
||||
|
||||
<!-- Choose a MacOSX SDK -->
|
||||
<property name="compiler" value="clang"/> <!-- Default to clang for 10.8 and up -->
|
||||
|
||||
<condition property="sdkroot" value="${developer_path}/${sdk_path}/MacOSX10.9.sdk">
|
||||
<and>
|
||||
<not><isset property="sdkroot"/></not>
|
||||
<available file="${developer_path}/${sdk_path}/MacOSX10.9.sdk" type="dir"/>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="sdkroot" value="${developer_path}/${sdk_path}/MacOSX10.8.sdk">
|
||||
<and>
|
||||
<not><isset property="sdkroot"/></not>
|
||||
<available file="${developer_path}/${sdk_path}/MacOSX10.8.sdk" type="dir"/>
|
||||
</and>
|
||||
</condition>
|
||||
|
||||
<!-- If we're on 10.7 or lower, use gcc instead of clang -->
|
||||
<condition property="compiler" value="gcc-4.2">
|
||||
<and>
|
||||
<not><isset property="sdkroot"/></not>
|
||||
<available file="gcc-4.2" filepath="${env.PATH}"/>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="compiler" value="gcc">
|
||||
<and>
|
||||
<not><isset property="sdkroot"/></not>
|
||||
<not><available file="gcc-4.2" filepath="${env.PATH}"/></not>
|
||||
<available file="gcc" filepath="${env.PATH}"/>
|
||||
</and>
|
||||
</condition>
|
||||
|
||||
<condition property="sdkroot" value="${developer_path}/${sdk_path}/MacOSX10.7.sdk">
|
||||
<and>
|
||||
<not><isset property="sdkroot"/></not>
|
||||
<available file="${developer_path}/${sdk_path}/MacOSX10.7.sdk" type="dir"/>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="sdkroot" value="${developer_path}/${sdk_path}/MacOSX10.6.sdk">
|
||||
<and>
|
||||
<not><isset property="sdkroot"/></not>
|
||||
<available file="${developer_path}/${sdk_path}/MacOSX10.6.sdk" type="dir"/>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="sdkroot" value="${developer_path}/SDKs/MacOSx10.6.sdk"> <!-- Old XCode location -->
|
||||
<and>
|
||||
<not><isset property="sdkroot"/></not>
|
||||
<available file="${developer_path}/SDKs/MacOSx10.6.sdk" type="dir"/>
|
||||
</and>
|
||||
</condition>
|
||||
</target>
|
||||
|
||||
<target name="clean">
|
||||
<delete failonerror="false">
|
||||
<fileset dir="arm64"/>
|
||||
<fileset dir="." includes="liblwjgl.dylib"/>
|
||||
<fileset dir="." includes="lwjgl.symbols"/>
|
||||
</delete>
|
||||
</target>
|
||||
|
||||
<target name="compile" depends="init">
|
||||
<apply dir="${dstdir}" executable="${compiler}" os="Mac OS X" skipemptyfilesets="true" failonerror="true" dest="${dstdir}">
|
||||
<arg line="${cflags} -ObjC -O2 -Wall -Wunused -c -fPIC -I${jvm_headers_path} -I${jvm_headers_path}/darwin -I${native}/common -I${native}/common/opengl -I${native}/macosx"/>
|
||||
<!-- Map from *.m and *.c to .o -->
|
||||
<mapper type="regexp" from="^(.*)\.(c|m)" to="\1.o"/>
|
||||
<fileset dir="${native}/macosx" includes="*.m"/>
|
||||
<fileset dir="${native}/macosx" includes="*.c"/>
|
||||
<fileset dir="${native}/common" includes="*.c"/>
|
||||
<fileset dir="${native}/common/opengl" includes="*.c"/>
|
||||
<fileset dir="${native}/generated/openal" includes="*.c"/>
|
||||
<fileset dir="${native}/generated/opencl" includes="*.c"/>
|
||||
<fileset dir="${native}/generated/opengl" includes="*.c"/>
|
||||
</apply>
|
||||
</target>
|
||||
|
||||
<target name="link" depends="init">
|
||||
<condition property="jdk_lib" value="${java.home}/lib">
|
||||
<available file="${java.home}/lib/libjawt.dylib" type="file"/>
|
||||
</condition>
|
||||
<condition property="jdk_lib" value="${java.home}/../Libraries">
|
||||
<not><isset property="jdk_lib"/></not>
|
||||
</condition>
|
||||
|
||||
<apply dir="${objdir}" parallel="true" executable="${compiler}" os="Mac OS X" failonerror="true" skipemptyfilesets="true">
|
||||
<arg line="${linkerflags} -exported_symbols_list ../lwjgl.symbols -dynamiclib -o ${libname} -framework Foundation -weak_framework AppKit -framework Carbon -framework OpenGL -framework QuartzCore -L${jdk_lib} -ljawt"/>
|
||||
<fileset dir="${objdir}" includes="*.o"/>
|
||||
</apply>
|
||||
<!-- <apply dir="${objdir}" executable="strip" os="Mac OS X" failonerror="true"> -->
|
||||
<!-- <arg line="-S -X"/> -->
|
||||
<!-- <fileset file="${libname}"/> -->
|
||||
<!-- </apply> -->
|
||||
</target>
|
||||
|
||||
<target name="nativelibrary" depends="init">
|
||||
<echo message=" Compiler: ${compiler}"/>
|
||||
<echo message=" Mac OS SDK: ${sdkroot}"/>
|
||||
<echo message="JavaVM.framework: ${javavmroot}"/>
|
||||
|
||||
<property name="build_arm64" value="1" />
|
||||
|
||||
<antcall target="-build"/>
|
||||
</target>
|
||||
|
||||
<target name="-build" depends="-build_arm64"/>
|
||||
|
||||
<!-- <target name="-build_universal" unless="build_x86_64"> -->
|
||||
<!-- <mkdir dir="i386"/> -->
|
||||
|
||||
<!-- <property name="universal_sdkroot" location="${sdkroot}"/> -->
|
||||
<!-- <property name="x86_64_sdkroot" location="${sdkroot}"/> -->
|
||||
<!-- <property name="universal_flags" value="-isysroot ${universal_sdkroot}"/> -->
|
||||
<!-- <antcall target="compile"> -->
|
||||
<!-- <param name="dstdir" location="i386"/> -->
|
||||
<!-- <param name="sdkroot" location="${universal_sdkroot}"/> -->
|
||||
<!-- <param name="cflags" value="${universal_flags} -arch i386 -mmacosx-version-min=10.5"/> -->
|
||||
<!-- </antcall> -->
|
||||
<!-- <antcall target="compile"> -->
|
||||
<!-- <param name="dstdir" location="x86_64"/> -->
|
||||
<!-- <param name="sdkroot" location="${universal_sdkroot}"/> -->
|
||||
<!-- <param name="cflags" value="-isysroot ${x86_64_sdkroot} -arch x86_64 -mmacosx-version-min=10.5"/> -->
|
||||
<!-- </antcall> -->
|
||||
<!-- <exec vmlauncher="true" executable="sh" output="lwjgl.symbols" failonerror="true"> -->
|
||||
<!-- <arg path="../../platform_build/macosx_ant/build-symbol-list"/> -->
|
||||
<!-- <arg path="i386"/> -->
|
||||
<!-- </exec> -->
|
||||
<!-- <antcall target="link"> -->
|
||||
<!-- <param name="objdir" location="i386"/> -->
|
||||
<!-- <param name="libname" value="liblwjgl-i386.dylib"/> -->
|
||||
<!-- <param name="linkerflags" value="${universal_flags} -arch i386 -mmacosx-version-min=10.5"/> -->
|
||||
<!-- </antcall> -->
|
||||
<!-- <antcall target="link"> -->
|
||||
<!-- <param name="objdir" location="x86_64"/> -->
|
||||
<!-- <param name="libname" value="liblwjgl-i86_64.dylib"/> -->
|
||||
<!-- <param name="linkerflags" value="-isysroot ${x86_64_sdkroot} -arch x86_64 -mmacosx-version-min=10.5"/> -->
|
||||
<!-- </antcall> -->
|
||||
<!-- <apply dir="." parallel="true" executable="lipo" os="Mac OS X" failonerror="true" skipemptyfilesets="true"> -->
|
||||
<!-- <arg value="-create"/> -->
|
||||
<!-- <srcfile/> -->
|
||||
<!-- <arg value="-output"/> -->
|
||||
<!-- <arg path="liblwjgl.dylib"/> -->
|
||||
<!-- <fileset file="i386/liblwjgl-i386.dylib"/> -->
|
||||
<!-- <fileset file="x86_64/liblwjgl-i86_64.dylib"/> -->
|
||||
<!-- </apply> -->
|
||||
<!-- </target> -->
|
||||
|
||||
<target name="-build_arm64" if="build_arm64">
|
||||
<antcall target="compile">
|
||||
<param name="dstdir" location="arm64"/>
|
||||
<param name="sdkroot" location="${sdkroot}"/>
|
||||
<param name="cflags" value="-isysroot ${sdkroot} -arch arm64 -mmacosx-version-min=10.5"/>
|
||||
</antcall>
|
||||
<exec vmlauncher="true" executable="sh" output="lwjgl.symbols" failonerror="true">
|
||||
<arg path="../../platform_build/macosx_ant/build-symbol-list"/>
|
||||
<arg path="arm64"/>
|
||||
</exec>
|
||||
<antcall target="link">
|
||||
<param name="objdir" location="arm64"/>
|
||||
<param name="libname" value="liblwjgl-arm64.dylib"/>
|
||||
<param name="linkerflags" value="-isysroot ${sdkroot} -arch arm64 -mmacosx-version-min=10.5"/>
|
||||
</antcall>
|
||||
<apply dir="." parallel="true" executable="lipo" os="Mac OS X" failonerror="true" skipemptyfilesets="true">
|
||||
<arg value="-create"/>
|
||||
<srcfile/>
|
||||
<arg value="-output"/>
|
||||
<arg path="liblwjgl.dylib"/>
|
||||
<fileset file="arm64/liblwjgl-arm64.dylib"/>
|
||||
</apply>
|
||||
</target>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@
|
|||
<property name="sdkhome" location="${env.MSSDK}"/>
|
||||
|
||||
<target name="compile_dir">
|
||||
<apply dir="." failonerror="true" executable="cl" dest="." skipemptyfilesets="true">
|
||||
<arg line="/Ox /W2 /nologo /Ox /Ob2 /Oi /Ot /Oy /FD /EHsc /MT /Gy /W2 /nologo /c"/>
|
||||
<apply dir="." failonerror="true" executable="cl" dest="." skipemptyfilesets="true" parallel="true">
|
||||
<arg line="/c /W2 /EHsc /Ox /Gy /MT /MP /nologo"/>
|
||||
<arg value="/I${sdkhome}\include"/>
|
||||
<arg value="/I${java.home}\..\include"/>
|
||||
<arg value="/I${java.home}\..\include\win32"/>
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@
|
|||
<property name="sdkhome" location="${env.MSSDK}"/>
|
||||
|
||||
<target name="compile_dir">
|
||||
<apply dir="." failonerror="true" executable="cl" dest="." skipemptyfilesets="true">
|
||||
<arg line="/Ox /W2 /nologo /Ox /Ob2 /Oi /Ot /Oy /FD /EHsc /MT /Gy /W2 /nologo /c"/>
|
||||
<apply dir="." failonerror="true" executable="cl" dest="." skipemptyfilesets="true" parallel="true">
|
||||
<arg line="/c /W2 /EHsc /Ox /Gy /MT /MP /nologo"/>
|
||||
<arg value="/I${sdkhome}\include"/>
|
||||
<arg value="/I${java.home}\..\include"/>
|
||||
<arg value="/I${java.home}\..\include\win32"/>
|
||||
|
|
|
|||
|
|
@ -272,7 +272,7 @@ public class LWJGLUtil {
|
|||
final String osName = getPrivilegedProperty("os.name");
|
||||
if ( osName.startsWith("Windows") )
|
||||
PLATFORM = PLATFORM_WINDOWS;
|
||||
else if ( osName.startsWith("Linux") || osName.startsWith("FreeBSD") || osName.startsWith("SunOS") || osName.startsWith("Unix") )
|
||||
else if ( osName.startsWith("Linux") || osName.startsWith("FreeBSD") || osName.startsWith("OpenBSD") || osName.startsWith("SunOS") || osName.startsWith("Unix") )
|
||||
PLATFORM = PLATFORM_LINUX;
|
||||
else if ( osName.startsWith("Mac OS X") || osName.startsWith("Darwin") )
|
||||
PLATFORM = PLATFORM_MACOSX;
|
||||
|
|
@ -319,6 +319,21 @@ public class LWJGLUtil {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraps {@link System#mapLibraryName}. On OS X with JDK 6, the .jnilib file
|
||||
* extension will be replaced with .dylib.
|
||||
*
|
||||
* @param name the name of the library.
|
||||
*
|
||||
* @return a platform-dependent native library name.
|
||||
*/
|
||||
public static String mapLibraryName(String name) {
|
||||
String libName = System.mapLibraryName(name);
|
||||
return LWJGLUtil.getPlatform() == LWJGLUtil.PLATFORM_MACOSX && libName.endsWith(".jnilib")
|
||||
? libName.substring(0, libName.length() - ".jnilib".length()) + ".dylib"
|
||||
: libName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Locates the paths required by a library.
|
||||
*
|
||||
|
|
@ -420,9 +435,11 @@ public class LWJGLUtil {
|
|||
* @return Absolute path to library if found, otherwise null
|
||||
*/
|
||||
private static String getPathFromClassLoader(final String libname, final ClassLoader classloader) {
|
||||
Class<?> c = null;
|
||||
|
||||
try {
|
||||
log("getPathFromClassLoader: searching for: " + libname);
|
||||
Class<?> c = classloader.getClass();
|
||||
c = classloader.getClass();
|
||||
while (c != null) {
|
||||
final Class<?> clazz = c;
|
||||
try {
|
||||
|
|
@ -440,7 +457,7 @@ public class LWJGLUtil {
|
|||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log("Failure locating " + e + " using classloader:" + e);
|
||||
log("Failure locating " + e + " using classloader:" + c);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
@ -603,10 +620,10 @@ public class LWJGLUtil {
|
|||
* @param field the Field to test
|
||||
* @param value the integer value of the field
|
||||
*
|
||||
* @result true if the Field is accepted
|
||||
* @return true if the Field is accepted
|
||||
*/
|
||||
boolean accept(Field field, int value);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ final class LinuxSysImplementation extends J2SESysImplementation {
|
|||
// Linux may as well resort to pure Java hackery, as there's no Linux native way of doing it
|
||||
// right anyway.
|
||||
|
||||
String[] browsers = {"xdg-open", "firefox", "mozilla", "opera", "konqueror", "nautilus", "galeon", "netscape"};
|
||||
String[] browsers = {"sensible-browser", "xdg-open", "google-chrome", "chromium", "firefox", "iceweasel", "mozilla", "opera", "konqueror", "nautilus", "galeon", "netscape"};
|
||||
|
||||
for ( final String browser : browsers ) {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -31,9 +31,10 @@
|
|||
*/
|
||||
package org.lwjgl;
|
||||
|
||||
import java.awt.Toolkit;
|
||||
|
||||
import com.apple.eio.FileManager;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
import java.lang.UnsatisfiedLinkError;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -42,24 +43,16 @@ import com.apple.eio.FileManager;
|
|||
* $Id$
|
||||
*/
|
||||
final class MacOSXSysImplementation extends J2SESysImplementation {
|
||||
private static final int JNI_VERSION = 21;
|
||||
private static final int JNI_VERSION = 25;
|
||||
|
||||
static {
|
||||
// Make sure AWT is properly initialized. This avoids hangs on Mac OS X 10.3
|
||||
Toolkit.getDefaultToolkit();
|
||||
// Manually start the AWT Application Loop
|
||||
java.awt.Toolkit.getDefaultToolkit();
|
||||
}
|
||||
|
||||
|
||||
public int getRequiredJNIVersion() {
|
||||
return JNI_VERSION;
|
||||
}
|
||||
|
||||
public boolean openURL(String url) {
|
||||
try {
|
||||
FileManager.openURL(url);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
LWJGLUtil.log("Exception occurred while trying to invoke browser: " + e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public native boolean openURL(String url);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,10 +33,7 @@ package org.lwjgl;
|
|||
|
||||
import java.lang.reflect.Field;
|
||||
import java.nio.*;
|
||||
import java.nio.charset.CharacterCodingException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import java.nio.charset.CoderResult;
|
||||
import java.nio.charset.*;
|
||||
|
||||
/**
|
||||
* [INTERNAL USE ONLY]
|
||||
|
|
@ -65,10 +62,10 @@ public final class MemoryUtil {
|
|||
// Depends on java.nio.Buffer#address and sun.misc.Unsafe
|
||||
util = loadAccessor("org.lwjgl.MemoryUtilSun$AccessorUnsafe");
|
||||
} catch (Exception e0) {
|
||||
try {
|
||||
// Depends on java.nio.Buffer#address and sun.reflect.FieldAccessor
|
||||
util = loadAccessor("org.lwjgl.MemoryUtilSun$AccessorReflectFast");
|
||||
} catch (Exception e1) {
|
||||
// try {
|
||||
// // Depends on java.nio.Buffer#address and sun.reflect.FieldAccessor
|
||||
// util = loadAccessor("org.lwjgl.MemoryUtilSun$AccessorReflectFast");
|
||||
// } catch (Exception e1) {
|
||||
try {
|
||||
// Depends on java.nio.Buffer#address
|
||||
util = new AccessorReflect();
|
||||
|
|
@ -76,7 +73,7 @@ public final class MemoryUtil {
|
|||
LWJGLUtil.log("Unsupported JVM detected, this will likely result in low performance. Please inform LWJGL developers.");
|
||||
util = new AccessorJNI();
|
||||
}
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
LWJGLUtil.log("MemoryUtil Accessor: " + util.getClass().getSimpleName());
|
||||
|
|
@ -285,10 +282,65 @@ public final class MemoryUtil {
|
|||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
out.flip();
|
||||
// cast to use Buffer's implementation of flip even when compiling against versions of java that have ByteBuffer::flip
|
||||
((Buffer)out).flip();
|
||||
return out;
|
||||
}
|
||||
|
||||
public static String decodeASCII(final ByteBuffer buffer) {
|
||||
return decode(buffer, ascii);
|
||||
}
|
||||
|
||||
public static String decodeUTF8(final ByteBuffer buffer) {
|
||||
return decode(buffer, utf8);
|
||||
}
|
||||
|
||||
public static String decodeUTF16(final ByteBuffer buffer) {
|
||||
return decode(buffer, utf16);
|
||||
}
|
||||
|
||||
private static String decode(final ByteBuffer buffer, final Charset charset) {
|
||||
if ( buffer == null )
|
||||
return null;
|
||||
|
||||
return decodeImpl(buffer, charset);
|
||||
}
|
||||
|
||||
private static String decodeImpl(final ByteBuffer in, final Charset charset) {
|
||||
final CharsetDecoder decoder = charset.newDecoder(); // decoders are not thread-safe, create a new one on every call
|
||||
|
||||
int n = (int)(in.remaining() * decoder.averageCharsPerByte());
|
||||
CharBuffer out = BufferUtils.createCharBuffer(n);
|
||||
|
||||
if ( (n == 0) && (in.remaining() == 0) )
|
||||
return "";
|
||||
|
||||
decoder.reset();
|
||||
for (; ; ) {
|
||||
CoderResult cr = in.hasRemaining() ? decoder.decode(in, out, true) : CoderResult.UNDERFLOW;
|
||||
if ( cr.isUnderflow() )
|
||||
cr = decoder.flush(out);
|
||||
|
||||
if ( cr.isUnderflow() )
|
||||
break;
|
||||
if ( cr.isOverflow() ) {
|
||||
n = 2 * n + 1; // Ensure progress; n might be 0!
|
||||
CharBuffer o = BufferUtils.createCharBuffer(n);
|
||||
out.flip();
|
||||
o.put(out);
|
||||
out = o;
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
cr.throwException();
|
||||
} catch (CharacterCodingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
out.flip();
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
/** A null-terminated CharSequence. */
|
||||
private static class CharSequenceNT implements CharSequence {
|
||||
|
||||
|
|
@ -362,16 +414,18 @@ public final class MemoryUtil {
|
|||
return getDeclaredFieldRecursive(ByteBuffer.class, "address");
|
||||
}
|
||||
|
||||
private static Field getDeclaredFieldRecursive(Class<?> type, final String fieldName) throws NoSuchFieldException {
|
||||
while ( type != null ) {
|
||||
private static Field getDeclaredFieldRecursive(final Class<?> root, final String fieldName) throws NoSuchFieldException {
|
||||
Class<?> type = root;
|
||||
|
||||
do {
|
||||
try {
|
||||
return type.getDeclaredField(fieldName);
|
||||
} catch (NoSuchFieldException e) {
|
||||
type = type.getSuperclass();
|
||||
}
|
||||
}
|
||||
} while ( type != null );
|
||||
|
||||
throw new NoSuchFieldException(fieldName + " does not exist in " + type.getSimpleName() + " or any of its superclasses.");
|
||||
throw new NoSuchFieldException(fieldName + " does not exist in " + root.getSimpleName() + " or any of its superclasses.");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ import java.lang.reflect.Modifier;
|
|||
import java.nio.Buffer;
|
||||
|
||||
import sun.misc.Unsafe;
|
||||
import sun.reflect.FieldAccessor;
|
||||
// import sun.reflect.FieldAccessor;
|
||||
|
||||
/**
|
||||
* MemoryUtil.Accessor implementations that depend on sun.misc.
|
||||
|
|
@ -104,32 +104,32 @@ final class MemoryUtilSun {
|
|||
}
|
||||
|
||||
/** Implementation using reflection on ByteBuffer, FieldAccessor is used directly. */
|
||||
private static class AccessorReflectFast implements MemoryUtil.Accessor {
|
||||
// private static class AccessorReflectFast implements MemoryUtil.Accessor {
|
||||
|
||||
private final FieldAccessor addressAccessor;
|
||||
// private final FieldAccessor addressAccessor;
|
||||
|
||||
AccessorReflectFast() {
|
||||
Field address;
|
||||
try {
|
||||
address = MemoryUtil.getAddressField();
|
||||
} catch (NoSuchFieldException e) {
|
||||
throw new UnsupportedOperationException(e);
|
||||
}
|
||||
address.setAccessible(true);
|
||||
// AccessorReflectFast() {
|
||||
// Field address;
|
||||
// try {
|
||||
// address = MemoryUtil.getAddressField();
|
||||
// } catch (NoSuchFieldException e) {
|
||||
// throw new UnsupportedOperationException(e);
|
||||
// }
|
||||
// address.setAccessible(true);
|
||||
|
||||
try {
|
||||
Method m = Field.class.getDeclaredMethod("acquireFieldAccessor", boolean.class);
|
||||
m.setAccessible(true);
|
||||
addressAccessor = (FieldAccessor)m.invoke(address, true);
|
||||
} catch (Exception e) {
|
||||
throw new UnsupportedOperationException(e);
|
||||
}
|
||||
}
|
||||
// try {
|
||||
// Method m = Field.class.getDeclaredMethod("acquireFieldAccessor", boolean.class);
|
||||
// m.setAccessible(true);
|
||||
// addressAccessor = (FieldAccessor)m.invoke(address, true);
|
||||
// } catch (Exception e) {
|
||||
// throw new UnsupportedOperationException(e);
|
||||
// }
|
||||
// }
|
||||
|
||||
public long getAddress(final Buffer buffer) {
|
||||
return addressAccessor.getLong(buffer);
|
||||
}
|
||||
// public long getAddress(final Buffer buffer) {
|
||||
// return addressAccessor.getLong(buffer);
|
||||
// }
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,409 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2002-2008 LWJGL Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of 'LWJGL' nor the names of
|
||||
* its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.lwjgl;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ShortBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.LongBuffer;
|
||||
import java.nio.DoubleBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
/**
|
||||
* Utility class to cache thread local direct buffers so when we are passed a non-direct buffer,
|
||||
* we can put its contents into a cached direct buffer and use that at the native side instead.
|
||||
*
|
||||
* Internal class, don't use.
|
||||
* @author elias_naur <elias_naur@users.sourceforge.net>
|
||||
* @version $Revision: 2762 $
|
||||
* $Id: BufferChecks.java 2762 2007-04-11 16:13:05Z elias_naur $
|
||||
*/
|
||||
public final class NondirectBufferWrapper {
|
||||
private static final int INITIAL_BUFFER_SIZE = 1;
|
||||
|
||||
private static final ThreadLocal<CachedBuffers> thread_buffer = new ThreadLocal<CachedBuffers>() {
|
||||
protected CachedBuffers initialValue() {
|
||||
return new CachedBuffers(INITIAL_BUFFER_SIZE);
|
||||
}
|
||||
};
|
||||
|
||||
private static CachedBuffers getCachedBuffers(int minimum_byte_size) {
|
||||
CachedBuffers buffers = thread_buffer.get();
|
||||
int current_byte_size = buffers.byte_buffer.capacity();
|
||||
if (minimum_byte_size > current_byte_size) {
|
||||
buffers = new CachedBuffers(minimum_byte_size);
|
||||
thread_buffer.set(buffers);
|
||||
}
|
||||
return buffers;
|
||||
}
|
||||
|
||||
public static ByteBuffer wrapNoCopyBuffer(ByteBuffer buf, int size) {
|
||||
BufferChecks.checkBufferSize(buf, size);
|
||||
return wrapNoCopyDirect(buf);
|
||||
}
|
||||
|
||||
public static ShortBuffer wrapNoCopyBuffer(ShortBuffer buf, int size) {
|
||||
BufferChecks.checkBufferSize(buf, size);
|
||||
return wrapNoCopyDirect(buf);
|
||||
}
|
||||
|
||||
public static IntBuffer wrapNoCopyBuffer(IntBuffer buf, int size) {
|
||||
BufferChecks.checkBufferSize(buf, size);
|
||||
return wrapNoCopyDirect(buf);
|
||||
}
|
||||
|
||||
public static LongBuffer wrapNoCopyBuffer(LongBuffer buf, int size) {
|
||||
BufferChecks.checkBufferSize(buf, size);
|
||||
return wrapNoCopyDirect(buf);
|
||||
}
|
||||
|
||||
public static FloatBuffer wrapNoCopyBuffer(FloatBuffer buf, int size) {
|
||||
BufferChecks.checkBufferSize(buf, size);
|
||||
return wrapNoCopyDirect(buf);
|
||||
}
|
||||
|
||||
public static DoubleBuffer wrapNoCopyBuffer(DoubleBuffer buf, int size) {
|
||||
BufferChecks.checkBufferSize(buf, size);
|
||||
return wrapNoCopyDirect(buf);
|
||||
}
|
||||
|
||||
public static ByteBuffer wrapBuffer(ByteBuffer buf, int size) {
|
||||
BufferChecks.checkBufferSize(buf, size);
|
||||
return wrapDirect(buf);
|
||||
}
|
||||
|
||||
public static ShortBuffer wrapBuffer(ShortBuffer buf, int size) {
|
||||
BufferChecks.checkBufferSize(buf, size);
|
||||
return wrapDirect(buf);
|
||||
}
|
||||
|
||||
public static IntBuffer wrapBuffer(IntBuffer buf, int size) {
|
||||
BufferChecks.checkBufferSize(buf, size);
|
||||
return wrapDirect(buf);
|
||||
}
|
||||
|
||||
public static LongBuffer wrapBuffer(LongBuffer buf, int size) {
|
||||
BufferChecks.checkBufferSize(buf, size);
|
||||
return wrapDirect(buf);
|
||||
}
|
||||
|
||||
public static FloatBuffer wrapBuffer(FloatBuffer buf, int size) {
|
||||
BufferChecks.checkBufferSize(buf, size);
|
||||
return wrapDirect(buf);
|
||||
}
|
||||
|
||||
public static DoubleBuffer wrapBuffer(DoubleBuffer buf, int size) {
|
||||
BufferChecks.checkBufferSize(buf, size);
|
||||
return wrapDirect(buf);
|
||||
}
|
||||
|
||||
public static ByteBuffer wrapDirect(ByteBuffer buffer) {
|
||||
if (!buffer.isDirect())
|
||||
return doWrap(buffer);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public static ShortBuffer wrapDirect(ShortBuffer buffer) {
|
||||
if (!buffer.isDirect())
|
||||
return doWrap(buffer);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public static FloatBuffer wrapDirect(FloatBuffer buffer) {
|
||||
if (!buffer.isDirect())
|
||||
return doWrap(buffer);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public static IntBuffer wrapDirect(IntBuffer buffer) {
|
||||
if (!buffer.isDirect())
|
||||
return doWrap(buffer);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public static LongBuffer wrapDirect(LongBuffer buffer) {
|
||||
if (!buffer.isDirect())
|
||||
return doWrap(buffer);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public static DoubleBuffer wrapDirect(DoubleBuffer buffer) {
|
||||
if (!buffer.isDirect())
|
||||
return doWrap(buffer);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public static ByteBuffer wrapNoCopyDirect(ByteBuffer buffer) {
|
||||
if (!buffer.isDirect())
|
||||
return doNoCopyWrap(buffer);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public static ShortBuffer wrapNoCopyDirect(ShortBuffer buffer) {
|
||||
if (!buffer.isDirect())
|
||||
return doNoCopyWrap(buffer);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public static FloatBuffer wrapNoCopyDirect(FloatBuffer buffer) {
|
||||
if (!buffer.isDirect())
|
||||
return doNoCopyWrap(buffer);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public static IntBuffer wrapNoCopyDirect(IntBuffer buffer) {
|
||||
if (!buffer.isDirect())
|
||||
return doNoCopyWrap(buffer);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public static LongBuffer wrapNoCopyDirect(LongBuffer buffer) {
|
||||
if (!buffer.isDirect())
|
||||
return doNoCopyWrap(buffer);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public static DoubleBuffer wrapNoCopyDirect(DoubleBuffer buffer) {
|
||||
if (!buffer.isDirect())
|
||||
return doNoCopyWrap(buffer);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public static void copy(ByteBuffer src, ByteBuffer dst) {
|
||||
if (dst != null && !dst.isDirect()) {
|
||||
int saved_position = dst.position();
|
||||
dst.put(src);
|
||||
dst.position(saved_position);
|
||||
}
|
||||
}
|
||||
|
||||
public static void copy(ShortBuffer src, ShortBuffer dst) {
|
||||
if (dst != null && !dst.isDirect()) {
|
||||
int saved_position = dst.position();
|
||||
dst.put(src);
|
||||
dst.position(saved_position);
|
||||
}
|
||||
}
|
||||
|
||||
public static void copy(IntBuffer src, IntBuffer dst) {
|
||||
if (dst != null && !dst.isDirect()) {
|
||||
int saved_position = dst.position();
|
||||
dst.put(src);
|
||||
dst.position(saved_position);
|
||||
}
|
||||
}
|
||||
|
||||
public static void copy(FloatBuffer src, FloatBuffer dst) {
|
||||
if (dst != null && !dst.isDirect()) {
|
||||
int saved_position = dst.position();
|
||||
dst.put(src);
|
||||
dst.position(saved_position);
|
||||
}
|
||||
}
|
||||
|
||||
public static void copy(LongBuffer src, LongBuffer dst) {
|
||||
if (dst != null && !dst.isDirect()) {
|
||||
int saved_position = dst.position();
|
||||
dst.put(src);
|
||||
dst.position(saved_position);
|
||||
}
|
||||
}
|
||||
|
||||
public static void copy(DoubleBuffer src, DoubleBuffer dst) {
|
||||
if (dst != null && !dst.isDirect()) {
|
||||
int saved_position = dst.position();
|
||||
dst.put(src);
|
||||
dst.position(saved_position);
|
||||
}
|
||||
}
|
||||
|
||||
private static ByteBuffer doNoCopyWrap(ByteBuffer buffer) {
|
||||
ByteBuffer direct_buffer = lookupBuffer(buffer);
|
||||
direct_buffer.limit(buffer.limit());
|
||||
direct_buffer.position(buffer.position());
|
||||
return direct_buffer;
|
||||
}
|
||||
|
||||
private static ShortBuffer doNoCopyWrap(ShortBuffer buffer) {
|
||||
ShortBuffer direct_buffer = lookupBuffer(buffer);
|
||||
direct_buffer.limit(buffer.limit());
|
||||
direct_buffer.position(buffer.position());
|
||||
return direct_buffer;
|
||||
}
|
||||
|
||||
private static IntBuffer doNoCopyWrap(IntBuffer buffer) {
|
||||
IntBuffer direct_buffer = lookupBuffer(buffer);
|
||||
direct_buffer.limit(buffer.limit());
|
||||
direct_buffer.position(buffer.position());
|
||||
return direct_buffer;
|
||||
}
|
||||
|
||||
private static FloatBuffer doNoCopyWrap(FloatBuffer buffer) {
|
||||
FloatBuffer direct_buffer = lookupBuffer(buffer);
|
||||
direct_buffer.limit(buffer.limit());
|
||||
direct_buffer.position(buffer.position());
|
||||
return direct_buffer;
|
||||
}
|
||||
|
||||
private static LongBuffer doNoCopyWrap(LongBuffer buffer) {
|
||||
LongBuffer direct_buffer = lookupBuffer(buffer);
|
||||
direct_buffer.limit(buffer.limit());
|
||||
direct_buffer.position(buffer.position());
|
||||
return direct_buffer;
|
||||
}
|
||||
|
||||
private static DoubleBuffer doNoCopyWrap(DoubleBuffer buffer) {
|
||||
DoubleBuffer direct_buffer = lookupBuffer(buffer);
|
||||
direct_buffer.limit(buffer.limit());
|
||||
direct_buffer.position(buffer.position());
|
||||
return direct_buffer;
|
||||
}
|
||||
|
||||
private static ByteBuffer lookupBuffer(ByteBuffer buffer) {
|
||||
return getCachedBuffers(buffer.remaining()).byte_buffer;
|
||||
}
|
||||
|
||||
private static ByteBuffer doWrap(ByteBuffer buffer) {
|
||||
ByteBuffer direct_buffer = lookupBuffer(buffer);
|
||||
direct_buffer.clear();
|
||||
int saved_position = buffer.position();
|
||||
direct_buffer.put(buffer);
|
||||
buffer.position(saved_position);
|
||||
direct_buffer.flip();
|
||||
return direct_buffer;
|
||||
}
|
||||
|
||||
private static ShortBuffer lookupBuffer(ShortBuffer buffer) {
|
||||
CachedBuffers buffers = getCachedBuffers(buffer.remaining()*2);
|
||||
return buffer.order() == ByteOrder.LITTLE_ENDIAN ? buffers.short_buffer_little : buffers.short_buffer_big;
|
||||
}
|
||||
|
||||
private static ShortBuffer doWrap(ShortBuffer buffer) {
|
||||
ShortBuffer direct_buffer = lookupBuffer(buffer);
|
||||
direct_buffer.clear();
|
||||
int saved_position = buffer.position();
|
||||
direct_buffer.put(buffer);
|
||||
buffer.position(saved_position);
|
||||
direct_buffer.flip();
|
||||
return direct_buffer;
|
||||
}
|
||||
|
||||
private static FloatBuffer lookupBuffer(FloatBuffer buffer) {
|
||||
CachedBuffers buffers = getCachedBuffers(buffer.remaining()*4);
|
||||
return buffer.order() == ByteOrder.LITTLE_ENDIAN ? buffers.float_buffer_little : buffers.float_buffer_big;
|
||||
}
|
||||
|
||||
private static FloatBuffer doWrap(FloatBuffer buffer) {
|
||||
FloatBuffer direct_buffer = lookupBuffer(buffer);
|
||||
direct_buffer.clear();
|
||||
int saved_position = buffer.position();
|
||||
direct_buffer.put(buffer);
|
||||
buffer.position(saved_position);
|
||||
direct_buffer.flip();
|
||||
return direct_buffer;
|
||||
}
|
||||
|
||||
private static IntBuffer lookupBuffer(IntBuffer buffer) {
|
||||
CachedBuffers buffers = getCachedBuffers(buffer.remaining()*4);
|
||||
return buffer.order() == ByteOrder.LITTLE_ENDIAN ? buffers.int_buffer_little : buffers.int_buffer_big;
|
||||
}
|
||||
|
||||
private static IntBuffer doWrap(IntBuffer buffer) {
|
||||
IntBuffer direct_buffer = lookupBuffer(buffer);
|
||||
direct_buffer.clear();
|
||||
int saved_position = buffer.position();
|
||||
direct_buffer.put(buffer);
|
||||
buffer.position(saved_position);
|
||||
direct_buffer.flip();
|
||||
return direct_buffer;
|
||||
}
|
||||
|
||||
private static LongBuffer lookupBuffer(LongBuffer buffer) {
|
||||
CachedBuffers buffers = getCachedBuffers(buffer.remaining()*8);
|
||||
return buffer.order() == ByteOrder.LITTLE_ENDIAN ? buffers.long_buffer_little : buffers.long_buffer_big;
|
||||
}
|
||||
|
||||
private static LongBuffer doWrap(LongBuffer buffer) {
|
||||
LongBuffer direct_buffer = lookupBuffer(buffer);
|
||||
direct_buffer.clear();
|
||||
int saved_position = buffer.position();
|
||||
direct_buffer.put(buffer);
|
||||
buffer.position(saved_position);
|
||||
direct_buffer.flip();
|
||||
return direct_buffer;
|
||||
}
|
||||
|
||||
private static DoubleBuffer lookupBuffer(DoubleBuffer buffer) {
|
||||
CachedBuffers buffers = getCachedBuffers(buffer.remaining()*8);
|
||||
return buffer.order() == ByteOrder.LITTLE_ENDIAN ? buffers.double_buffer_little : buffers.double_buffer_big;
|
||||
}
|
||||
|
||||
private static DoubleBuffer doWrap(DoubleBuffer buffer) {
|
||||
DoubleBuffer direct_buffer = lookupBuffer(buffer);
|
||||
direct_buffer.clear();
|
||||
int saved_position = buffer.position();
|
||||
direct_buffer.put(buffer);
|
||||
buffer.position(saved_position);
|
||||
direct_buffer.flip();
|
||||
return direct_buffer;
|
||||
}
|
||||
|
||||
private static final class CachedBuffers {
|
||||
private final ByteBuffer byte_buffer;
|
||||
private final ShortBuffer short_buffer_big;
|
||||
private final IntBuffer int_buffer_big;
|
||||
private final FloatBuffer float_buffer_big;
|
||||
private final LongBuffer long_buffer_big;
|
||||
private final DoubleBuffer double_buffer_big;
|
||||
private final ShortBuffer short_buffer_little;
|
||||
private final IntBuffer int_buffer_little;
|
||||
private final FloatBuffer float_buffer_little;
|
||||
private final LongBuffer long_buffer_little;
|
||||
private final DoubleBuffer double_buffer_little;
|
||||
|
||||
private CachedBuffers(int size) {
|
||||
this.byte_buffer = ByteBuffer.allocateDirect(size);
|
||||
this.short_buffer_big = byte_buffer.asShortBuffer();
|
||||
this.int_buffer_big = byte_buffer.asIntBuffer();
|
||||
this.float_buffer_big = byte_buffer.asFloatBuffer();
|
||||
this.long_buffer_big = byte_buffer.asLongBuffer();
|
||||
this.double_buffer_big = byte_buffer.asDoubleBuffer();
|
||||
this.byte_buffer.order(ByteOrder.LITTLE_ENDIAN);
|
||||
this.short_buffer_little = byte_buffer.asShortBuffer();
|
||||
this.int_buffer_little = byte_buffer.asIntBuffer();
|
||||
this.float_buffer_little = byte_buffer.asFloatBuffer();
|
||||
this.long_buffer_little = byte_buffer.asLongBuffer();
|
||||
this.double_buffer_little = byte_buffer.asDoubleBuffer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -550,9 +550,9 @@ public class PointerBuffer implements Comparable {
|
|||
*/
|
||||
public static void put(final ByteBuffer target, int index, long l) {
|
||||
if ( is64Bit )
|
||||
target.putLong(index * 8, l);
|
||||
target.putLong(index, l);
|
||||
else
|
||||
target.putInt(index * 4, (int)l);
|
||||
target.putInt(index, (int)l);
|
||||
}
|
||||
|
||||
// -- Bulk get operations --
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ public final class Sys {
|
|||
private static final String JNI_LIBRARY_NAME = "lwjgl";
|
||||
|
||||
/** Current version of library */
|
||||
private static final String VERSION = "2.8.1";
|
||||
private static final String VERSION = "2.9.4";
|
||||
|
||||
private static final String POSTFIX64BIT = "64";
|
||||
|
||||
|
|
@ -67,8 +67,7 @@ public final class Sys {
|
|||
public Object run() {
|
||||
String library_path = System.getProperty("org.lwjgl.librarypath");
|
||||
if (library_path != null) {
|
||||
System.load(library_path + File.separator +
|
||||
System.mapLibraryName(lib_name));
|
||||
System.load(library_path + File.separator + LWJGLUtil.mapLibraryName(lib_name));
|
||||
} else {
|
||||
System.loadLibrary(lib_name);
|
||||
}
|
||||
|
|
@ -80,13 +79,15 @@ public final class Sys {
|
|||
private static void loadLibrary(final String lib_name) {
|
||||
// actively try to load 64bit libs on 64bit architectures first
|
||||
String osArch = System.getProperty("os.arch");
|
||||
boolean is64bit = "amd64".equals(osArch) || "x86_64".equals(osArch);
|
||||
if(is64bit) {
|
||||
boolean try64First = LWJGLUtil.getPlatform() != LWJGLUtil.PLATFORM_MACOSX && ("amd64".equals(osArch) || "x86_64".equals(osArch));
|
||||
|
||||
Error err = null;
|
||||
if ( try64First ) {
|
||||
try {
|
||||
doLoadLibrary(lib_name + POSTFIX64BIT);
|
||||
return;
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
LWJGLUtil.log("Failed to load 64 bit library: " + e.getMessage());
|
||||
err = e;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -94,6 +95,9 @@ public final class Sys {
|
|||
try {
|
||||
doLoadLibrary(lib_name);
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
if ( try64First )
|
||||
throw err;
|
||||
|
||||
if (implementation.has64Bit()) {
|
||||
try {
|
||||
doLoadLibrary(lib_name + POSTFIX64BIT);
|
||||
|
|
@ -102,6 +106,7 @@ public final class Sys {
|
|||
LWJGLUtil.log("Failed to load 64 bit library: " + e2.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// Throw original error
|
||||
throw e;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ import org.lwjgl.opengl.Display;
|
|||
* $Id$
|
||||
*/
|
||||
final class WindowsSysImplementation extends DefaultSysImplementation {
|
||||
private static final int JNI_VERSION = 23;
|
||||
private static final int JNI_VERSION = 24;
|
||||
|
||||
static {
|
||||
Sys.initialize();
|
||||
|
|
|
|||
|
|
@ -270,4 +270,21 @@ public interface Controller {
|
|||
* @param zone The dead zone to use for the RZ axis
|
||||
*/
|
||||
void setRZAxisDeadZone(float zone);
|
||||
|
||||
|
||||
/** Returns the number of rumblers this controller supports */
|
||||
int getRumblerCount();
|
||||
|
||||
/** Returns the name of the specified rumbler
|
||||
*
|
||||
* @param index The rumbler index
|
||||
*/
|
||||
String getRumblerName(int index);
|
||||
|
||||
/** Sets the vibration strength of the specified rumbler
|
||||
*
|
||||
* @param index The index of the rumbler
|
||||
* @param strength The strength to vibrate at
|
||||
*/
|
||||
void setRumblerStrength(int index, float strength);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,12 +52,18 @@ class ControllerEvent {
|
|||
private int index;
|
||||
/** Type of control that generated the event */
|
||||
private int type;
|
||||
/** True when a button is pressed, if this event was caused by the button */
|
||||
private boolean buttonState;
|
||||
/** True if this event was caused by the x axis */
|
||||
private boolean xaxis;
|
||||
/** True if this event was caused by the y axis */
|
||||
private boolean yaxis;
|
||||
/** The time stamp of this event */
|
||||
private long timeStamp;
|
||||
/** The value on a specified axis, if this event was caused by the x-axis */
|
||||
private float xaxisValue;
|
||||
/** The value on a specified axis, if this event was caused by the y-axis */
|
||||
private float yaxisValue;
|
||||
|
||||
/**
|
||||
* Create a new event
|
||||
|
|
@ -70,12 +76,32 @@ class ControllerEvent {
|
|||
* @param yaxis True if this event was caused by the y-axis
|
||||
*/
|
||||
ControllerEvent(Controller source,long timeStamp, int type,int index,boolean xaxis,boolean yaxis) {
|
||||
this(source, timeStamp, type, index, false, xaxis, yaxis, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new event
|
||||
*
|
||||
* @param source The source of the event
|
||||
* @param timeStamp The time stamp given for this event
|
||||
* @param type The type of control generating this event
|
||||
* @param index The index of the input that generated the event
|
||||
* @param buttonState True when a button is pressed, if this event was caused by the button
|
||||
* @param xaxis True if this event was caused by the x-axis
|
||||
* @param yaxis True if this event was caused by the y-axis
|
||||
* @param xaxisValue The value on a specified axis, if this event was caused by the x-axis
|
||||
* @param yaxisValue The value on a specified axis, if this event was caused by the y-axis
|
||||
*/
|
||||
ControllerEvent(Controller source,long timeStamp, int type,int index,boolean buttonState,boolean xaxis,boolean yaxis,float xaxisValue,float yaxisValue) {
|
||||
this.source = source;
|
||||
this.timeStamp = timeStamp;
|
||||
this.type = type;
|
||||
this.index = index;
|
||||
this.buttonState = buttonState;
|
||||
this.xaxis = xaxis;
|
||||
this.yaxis = yaxis;
|
||||
this.xaxisValue = xaxisValue;
|
||||
this.yaxisValue = yaxisValue;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -115,6 +141,15 @@ class ControllerEvent {
|
|||
return type == BUTTON;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the button is pressed or not, when this event was caused
|
||||
*
|
||||
* @return True when a button is pressed, if this event was caused by the button
|
||||
*/
|
||||
public boolean getButtonState() {
|
||||
return buttonState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this event was generated by a axis
|
||||
*
|
||||
|
|
@ -159,6 +194,24 @@ class ControllerEvent {
|
|||
public boolean isYAxis() {
|
||||
return yaxis;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value on an X axis when this event was caused
|
||||
*
|
||||
* @return The value on a specified axis, if this event was caused by the x-axis
|
||||
*/
|
||||
public float getXAxisValue() {
|
||||
return xaxisValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value on an Y axis when this event was caused
|
||||
*
|
||||
* @return The value on a specified axis, if this event was caused by the y-axis
|
||||
*/
|
||||
public float getYAxisValue() {
|
||||
return yaxisValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see java.lang.Object#toString()
|
||||
|
|
|
|||
|
|
@ -262,12 +262,39 @@ public class Controllers {
|
|||
/**
|
||||
* Get the timestamp assigned to the current event
|
||||
*
|
||||
* @return The timestamp assigned ot the current event
|
||||
* @return The timestamp assigned to the current event
|
||||
*/
|
||||
public static long getEventNanoseconds() {
|
||||
return event.getTimeStamp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the state of the button that generated the current event
|
||||
*
|
||||
* @return True if button was down, or false if released
|
||||
*/
|
||||
public static boolean getEventButtonState() {
|
||||
return event.getButtonState();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value on an X axis of the current event
|
||||
*
|
||||
* @return The value on a x axis of the current event
|
||||
*/
|
||||
public static float getEventXAxisValue() {
|
||||
return event.getXAxisValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value on an Y axis of the current event
|
||||
*
|
||||
* @return The value on a y axis of the current event
|
||||
*/
|
||||
public static float getEventYAxisValue() {
|
||||
return event.getYAxisValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an event to the stack of events that have been caused
|
||||
*
|
||||
|
|
|
|||
|
|
@ -33,10 +33,10 @@ package org.lwjgl.input;
|
|||
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
import org.lwjgl.BufferChecks;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.LWJGLException;
|
||||
import org.lwjgl.LWJGLUtil;
|
||||
import org.lwjgl.NondirectBufferWrapper;
|
||||
import org.lwjgl.Sys;
|
||||
|
||||
/**
|
||||
|
|
@ -86,9 +86,9 @@ public class Cursor {
|
|||
synchronized (OpenGLPackageAccess.global_lock) {
|
||||
if ((getCapabilities() & CURSOR_ONE_BIT_TRANSPARENCY) == 0)
|
||||
throw new LWJGLException("Native cursors not supported");
|
||||
images = NondirectBufferWrapper.wrapBuffer(images, width*height*numImages);
|
||||
BufferChecks.checkBufferSize(images, width*height*numImages);
|
||||
if (delays != null)
|
||||
delays = NondirectBufferWrapper.wrapBuffer(delays, numImages);
|
||||
BufferChecks.checkBufferSize(delays, numImages);
|
||||
if (!Mouse.isCreated())
|
||||
throw new IllegalStateException("Mouse must be created before creating cursor objects");
|
||||
if (width*height*numImages > images.remaining())
|
||||
|
|
@ -163,17 +163,32 @@ public class Cursor {
|
|||
IntBuffer images_copy = BufferUtils.createIntBuffer(images.remaining());
|
||||
flipImages(width, height, numImages, images, images_copy);
|
||||
|
||||
// Win32 doesn't (afaik) allow for animation based cursors, except when they're
|
||||
// in the .ani format, which we don't support.
|
||||
// Mac and Windows doesn't (afaik) allow for animation based cursors, except in the .ani
|
||||
// format on Windows, which we don't support.
|
||||
// The cursor animation was therefor developed using java side time tracking.
|
||||
// unfortunately X flickers when changing cursor. We therefore check for either
|
||||
// Win32 or X and do accordingly. This hasn't been implemented on Mac, but we
|
||||
// might want to split it into a X/Win/Mac cursor if it gets too cluttered
|
||||
// Windows, Mac or X and do accordingly.
|
||||
// we might want to split it into a X/Win/Mac cursor if it gets too cluttered
|
||||
|
||||
CursorElement[] cursors;
|
||||
switch (LWJGLUtil.getPlatform()) {
|
||||
case LWJGLUtil.PLATFORM_MACOSX:
|
||||
/* Fall through */
|
||||
|
||||
// OS X requires the image format to be in ABGR format
|
||||
convertARGBtoABGR(images_copy);
|
||||
|
||||
// create our cursor elements
|
||||
cursors = new CursorElement[numImages];
|
||||
for(int i=0; i<numImages; i++) {
|
||||
Object handle = Mouse.getImplementation().createCursor(width, height, xHotspot, yHotspot, 1, images_copy, null);
|
||||
long delay = (delays != null) ? delays.get(i) : 0;
|
||||
long timeout = System.currentTimeMillis();
|
||||
cursors[i] = new CursorElement(handle, delay, timeout);
|
||||
|
||||
// offset to next image
|
||||
images_copy.position(width*height*(i+1));
|
||||
}
|
||||
break;
|
||||
case LWJGLUtil.PLATFORM_WINDOWS:
|
||||
// create our cursor elements
|
||||
cursors = new CursorElement[numImages];
|
||||
|
|
@ -209,6 +224,26 @@ public class Cursor {
|
|||
}
|
||||
return cursors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an IntBuffer image of ARGB format into ABGR
|
||||
*
|
||||
* @param imageBuffer image to convert
|
||||
*/
|
||||
private static void convertARGBtoABGR(IntBuffer imageBuffer) {
|
||||
for (int i = 0; i < imageBuffer.limit(); i++) {
|
||||
int argbColor = imageBuffer.get(i);
|
||||
|
||||
byte alpha = (byte)(argbColor >>> 24);
|
||||
byte blue = (byte)(argbColor >>> 16);
|
||||
byte green = (byte)(argbColor >>> 8);
|
||||
byte red = (byte)argbColor;
|
||||
|
||||
int abgrColor = ((alpha & 0xff) << 24 ) + ((red & 0xff) << 16 ) + ((green & 0xff) << 8 ) + ((blue & 0xff) );
|
||||
|
||||
imageBuffer.put(i, abgrColor);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Flips the images so they're oriented according to opengl
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ import net.java.games.input.Component.Identifier.Axis;
|
|||
import net.java.games.input.Component.Identifier.Button;
|
||||
import net.java.games.input.Event;
|
||||
import net.java.games.input.EventQueue;
|
||||
import net.java.games.input.Rumbler;
|
||||
|
||||
/**
|
||||
* A wrapper round a JInput controller that attempts to make the interface
|
||||
|
|
@ -56,6 +57,8 @@ class JInputController implements Controller {
|
|||
private ArrayList<Component> axes = new ArrayList<Component>();
|
||||
/** The POVs that have been detected on the JInput controller */
|
||||
private ArrayList<Component> pov = new ArrayList<Component>();
|
||||
/** The rumblers exposed by the controller */
|
||||
private Rumbler[] rumblers;
|
||||
/** The state of the buttons last check */
|
||||
private boolean[] buttonState;
|
||||
/** The values that were read from the pov last check */
|
||||
|
|
@ -86,7 +89,7 @@ class JInputController implements Controller {
|
|||
* @param index The index this controller has been assigned to
|
||||
* @param target The target JInput controller this class is wrapping
|
||||
*/
|
||||
JInputController(int index,net.java.games.input.Controller target) {
|
||||
JInputController(int index, net.java.games.input.Controller target) {
|
||||
this.target = target;
|
||||
this.index = index;
|
||||
|
||||
|
|
@ -148,6 +151,8 @@ class JInputController implements Controller {
|
|||
axesMax[i] = 1.0f;
|
||||
deadZones[i] = 0.05f;
|
||||
}
|
||||
|
||||
rumblers = target.getRumblers();
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -203,7 +208,8 @@ class JInputController implements Controller {
|
|||
buttonState[buttonIndex] = event.getValue() != 0;
|
||||
|
||||
// fire button pressed event
|
||||
Controllers.addEvent(new ControllerEvent(this,event.getNanos(),ControllerEvent.BUTTON,buttonIndex,false,false));
|
||||
Controllers.addEvent(new ControllerEvent(this,event.getNanos(),ControllerEvent.BUTTON,buttonIndex,
|
||||
buttonState[buttonIndex],false,false,0,0));
|
||||
}
|
||||
|
||||
// handle pov events
|
||||
|
|
@ -227,6 +233,8 @@ class JInputController implements Controller {
|
|||
Component axis = event.getComponent();
|
||||
int axisIndex = axes.indexOf(axis);
|
||||
float value = axis.getPollData();
|
||||
float xaxisValue = 0;
|
||||
float yaxisValue = 0;
|
||||
|
||||
// fixed dead zone since most axis don't report it :(
|
||||
if (Math.abs(value) < deadZones[axisIndex]) {
|
||||
|
|
@ -241,9 +249,17 @@ class JInputController implements Controller {
|
|||
|
||||
// normalize the value based on maximum value read in the past
|
||||
value /= axesMax[axisIndex];
|
||||
|
||||
if (axisIndex == xaxis) {
|
||||
xaxisValue = value;
|
||||
}
|
||||
if (axisIndex == yaxis) {
|
||||
yaxisValue = value;
|
||||
}
|
||||
|
||||
// fire event
|
||||
Controllers.addEvent(new ControllerEvent(this,event.getNanos(),ControllerEvent.AXIS,axisIndex,
|
||||
axisIndex == xaxis,axisIndex == yaxis));
|
||||
Controllers.addEvent(new ControllerEvent(this,event.getNanos(),ControllerEvent.AXIS,axisIndex,false,
|
||||
axisIndex == xaxis,axisIndex == yaxis,xaxisValue,yaxisValue));
|
||||
axesValue[axisIndex] = value;
|
||||
}
|
||||
}
|
||||
|
|
@ -506,5 +522,16 @@ class JInputController implements Controller {
|
|||
return 0;
|
||||
}
|
||||
|
||||
public int getRumblerCount() {
|
||||
return rumblers.length;
|
||||
}
|
||||
|
||||
public String getRumblerName(int index) {
|
||||
return rumblers[index].getAxisName();
|
||||
}
|
||||
|
||||
public void setRumblerStrength(int index, float strength) {
|
||||
rumblers[index].rumble(strength);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ package org.lwjgl.input;
|
|||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.nio.Buffer;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
|
@ -158,7 +159,11 @@ public class Keyboard {
|
|||
public static final int KEY_F13 = 0x64; /* (NEC PC98) */
|
||||
public static final int KEY_F14 = 0x65; /* (NEC PC98) */
|
||||
public static final int KEY_F15 = 0x66; /* (NEC PC98) */
|
||||
public static final int KEY_F16 = 0x67; /* Extended Function keys - (Mac) */
|
||||
public static final int KEY_F17 = 0x68;
|
||||
public static final int KEY_F18 = 0x69;
|
||||
public static final int KEY_KANA = 0x70; /* (Japanese keyboard) */
|
||||
public static final int KEY_F19 = 0x71; /* Extended Function keys - (Mac) */
|
||||
public static final int KEY_CONVERT = 0x79; /* (Japanese keyboard) */
|
||||
public static final int KEY_NOCONVERT = 0x7B; /* (Japanese keyboard) */
|
||||
public static final int KEY_YEN = 0x7D; /* (Japanese keyboard) */
|
||||
|
|
@ -173,10 +178,12 @@ public class Keyboard {
|
|||
public static final int KEY_UNLABELED = 0x97; /* (J3100) */
|
||||
public static final int KEY_NUMPADENTER = 0x9C; /* Enter on numeric keypad */
|
||||
public static final int KEY_RCONTROL = 0x9D;
|
||||
public static final int KEY_SECTION = 0xA7; /* Section symbol (Mac) */
|
||||
public static final int KEY_NUMPADCOMMA = 0xB3; /* , on numeric keypad (NEC PC98) */
|
||||
public static final int KEY_DIVIDE = 0xB5; /* / on numeric keypad */
|
||||
public static final int KEY_SYSRQ = 0xB7;
|
||||
public static final int KEY_RMENU = 0xB8; /* right Alt */
|
||||
public static final int KEY_FUNCTION = 0xC4; /* Function (Mac) */
|
||||
public static final int KEY_PAUSE = 0xC5; /* Pause */
|
||||
public static final int KEY_HOME = 0xC7; /* Home on arrow keypad */
|
||||
public static final int KEY_UP = 0xC8; /* UpArrow on arrow keypad */
|
||||
|
|
@ -188,7 +195,8 @@ public class Keyboard {
|
|||
public static final int KEY_NEXT = 0xD1; /* PgDn on arrow keypad */
|
||||
public static final int KEY_INSERT = 0xD2; /* Insert on arrow keypad */
|
||||
public static final int KEY_DELETE = 0xD3; /* Delete on arrow keypad */
|
||||
public static final int KEY_LMETA = 0xDB; /* Left Windows/Option key */
|
||||
public static final int KEY_CLEAR = 0xDA; /* Clear key (Mac) */
|
||||
public static final int KEY_LMETA = 0xDB; /* Left Windows/Option key */
|
||||
/**
|
||||
* The left windows key, mapped to KEY_LMETA
|
||||
*
|
||||
|
|
@ -216,7 +224,7 @@ public class Keyboard {
|
|||
private static final int BUFFER_SIZE = 50;
|
||||
|
||||
/** Key names */
|
||||
private static final String[] keyName = new String[255];
|
||||
private static final String[] keyName = new String[KEYBOARD_SIZE];
|
||||
private static final Map<String, Integer> keyMap = new HashMap<String, Integer>(253);
|
||||
private static int counter;
|
||||
|
||||
|
|
@ -229,7 +237,8 @@ public class Keyboard {
|
|||
&& Modifier.isPublic(field.getModifiers())
|
||||
&& Modifier.isFinal(field.getModifiers())
|
||||
&& field.getType().equals(int.class)
|
||||
&& field.getName().startsWith("KEY_") ) {
|
||||
&& field.getName().startsWith("KEY_")
|
||||
&& !field.getName().endsWith("WIN") ) { /* Don't use deprecated names */
|
||||
|
||||
int key = field.getInt(null);
|
||||
String name = field.getName().substring(4);
|
||||
|
|
@ -323,7 +332,7 @@ public class Keyboard {
|
|||
}
|
||||
|
||||
private static void reset() {
|
||||
readBuffer.limit(0);
|
||||
((Buffer)readBuffer).limit(0);
|
||||
for (int i = 0; i < keyDownBuffer.remaining(); i++)
|
||||
keyDownBuffer.put(i, (byte)0);
|
||||
current_event.reset();
|
||||
|
|
@ -384,7 +393,7 @@ public class Keyboard {
|
|||
private static void read() {
|
||||
readBuffer.compact();
|
||||
implementation.readKeyboard(readBuffer);
|
||||
readBuffer.flip();
|
||||
((Buffer)readBuffer).flip();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -445,7 +454,7 @@ public class Keyboard {
|
|||
int num_events = 0;
|
||||
while (readNext(tmp_event) && (!tmp_event.repeat || repeat_enabled))
|
||||
num_events++;
|
||||
readBuffer.position(old_position);
|
||||
((Buffer)readBuffer).position(old_position);
|
||||
return num_events;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
*/
|
||||
package org.lwjgl.input;
|
||||
|
||||
import java.nio.Buffer;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import java.security.AccessController;
|
||||
|
|
@ -77,6 +78,12 @@ public class Mouse {
|
|||
|
||||
/** Mouse absolute Y position in pixels */
|
||||
private static int y;
|
||||
|
||||
/** Mouse absolute X position in pixels without any clipping */
|
||||
private static int absolute_x;
|
||||
|
||||
/** Mouse absolute Y position in pixels without any clipping */
|
||||
private static int absolute_y;
|
||||
|
||||
/** Buffer to hold the deltas dx, dy and dwheel */
|
||||
private static IntBuffer coord_buffer;
|
||||
|
|
@ -243,7 +250,7 @@ public class Mouse {
|
|||
|
||||
private static void resetMouse() {
|
||||
dx = dy = dwheel = 0;
|
||||
readBuffer.position(readBuffer.limit());
|
||||
((Buffer)readBuffer).position(readBuffer.limit());
|
||||
}
|
||||
|
||||
static InputImplementation getImplementation() {
|
||||
|
|
@ -273,7 +280,7 @@ public class Mouse {
|
|||
if (currentCursor != null && implementation.getNativeCursorCapabilities() != 0)
|
||||
setNativeCursor(currentCursor);
|
||||
readBuffer = ByteBuffer.allocate(EVENT_SIZE * BUFFER_SIZE);
|
||||
readBuffer.limit(0);
|
||||
((Buffer)readBuffer).limit(0);
|
||||
setGrabbed(isGrabbed);
|
||||
}
|
||||
|
||||
|
|
@ -355,17 +362,21 @@ public class Mouse {
|
|||
dy += poll_coord2;
|
||||
x += poll_coord1;
|
||||
y += poll_coord2;
|
||||
absolute_x += poll_coord1;
|
||||
absolute_y += poll_coord2;
|
||||
} else {
|
||||
dx = poll_coord1 - x;
|
||||
dy = poll_coord2 - y;
|
||||
x = poll_coord1;
|
||||
y = poll_coord2;
|
||||
dx = poll_coord1 - absolute_x;
|
||||
dy = poll_coord2 - absolute_y;
|
||||
absolute_x = x = poll_coord1;
|
||||
absolute_y = y = poll_coord2;
|
||||
}
|
||||
if(clipMouseCoordinatesToWindow) {
|
||||
x = Math.min(Display.getWidth() - 1, Math.max(0, x));
|
||||
y = Math.min(Display.getHeight() - 1, Math.max(0, y));
|
||||
}
|
||||
dwheel += poll_dwheel;
|
||||
|
||||
if(clipMouseCoordinatesToWindow) {
|
||||
x = Math.min(Display.getWidth() - 1, Math.max(0, x));
|
||||
y = Math.min(Display.getHeight() - 1, Math.max(0, y));
|
||||
}
|
||||
|
||||
dwheel += poll_dwheel;
|
||||
read();
|
||||
}
|
||||
}
|
||||
|
|
@ -373,7 +384,7 @@ public class Mouse {
|
|||
private static void read() {
|
||||
readBuffer.compact();
|
||||
implementation.readMouse(readBuffer);
|
||||
readBuffer.flip();
|
||||
((Buffer)readBuffer).flip();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -423,8 +434,8 @@ public class Mouse {
|
|||
/**
|
||||
* Gets the next mouse event. You can query which button caused the event by using
|
||||
* <code>getEventButton()</code> (if any). To get the state of that key, for that event, use
|
||||
* <code>getEventButtonState</code>. To get the current mouse delta values use <code>getEventDX()</code>,
|
||||
* <code>getEventDY()</code> and <code>getEventDZ()</code>.
|
||||
* <code>getEventButtonState</code>. To get the current mouse delta values use <code>getEventDX()</code>
|
||||
* and <code>getEventDY()</code>.
|
||||
* @see org.lwjgl.input.Mouse#getEventButton()
|
||||
* @see org.lwjgl.input.Mouse#getEventButtonState()
|
||||
* @return true if a mouse event was read, false otherwise
|
||||
|
|
|
|||
|
|
@ -115,8 +115,13 @@ public final class AL {
|
|||
String[] library_names;
|
||||
switch (LWJGLUtil.getPlatform()) {
|
||||
case LWJGLUtil.PLATFORM_WINDOWS:
|
||||
libname = "OpenAL32";
|
||||
library_names = new String[]{"OpenAL64.dll", "OpenAL32.dll"};
|
||||
if ( Sys.is64Bit() ) {
|
||||
libname = "OpenAL64";
|
||||
library_names = new String[]{"OpenAL64.dll"};
|
||||
} else {
|
||||
libname = "OpenAL32";
|
||||
library_names = new String[]{"OpenAL32.dll"};
|
||||
}
|
||||
break;
|
||||
case LWJGLUtil.PLATFORM_LINUX:
|
||||
libname = "openal";
|
||||
|
|
|
|||
|
|
@ -152,12 +152,11 @@ public final class ALC10 {
|
|||
* @return String property from device
|
||||
*/
|
||||
public static String alcGetString(ALCdevice device, int pname) {
|
||||
String result;
|
||||
result = nalcGetString(getDevice(device), pname);
|
||||
ByteBuffer buffer = nalcGetString(getDevice(device), pname);
|
||||
Util.checkALCError(device);
|
||||
return result;
|
||||
return MemoryUtil.decodeUTF8(buffer);
|
||||
}
|
||||
static native String nalcGetString(long device, int pname);
|
||||
static native ByteBuffer nalcGetString(long device, int pname);
|
||||
|
||||
/**
|
||||
* The application can query ALC for information using an integer query function.
|
||||
|
|
@ -199,7 +198,7 @@ public final class ALC10 {
|
|||
* @return opened device, or null
|
||||
*/
|
||||
public static ALCdevice alcOpenDevice(String devicename) {
|
||||
ByteBuffer buffer = MemoryUtil.encodeASCII(devicename);
|
||||
ByteBuffer buffer = MemoryUtil.encodeUTF8(devicename);
|
||||
long device_address = nalcOpenDevice(MemoryUtil.getAddressSafe(buffer));
|
||||
if(device_address != 0) {
|
||||
ALCdevice device = new ALCdevice(device_address);
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
*/
|
||||
package org.lwjgl.openal;
|
||||
|
||||
import java.nio.Buffer;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
|
|
@ -93,7 +94,7 @@ public final class ALC11 {
|
|||
*/
|
||||
public static ALCdevice alcCaptureOpenDevice(String devicename, int frequency, int format, int buffersize) {
|
||||
ByteBuffer buffer = MemoryUtil.encodeASCII(devicename);
|
||||
long device_address = nalcCaptureOpenDevice(MemoryUtil.getAddress(buffer), frequency, format, buffersize);
|
||||
long device_address = nalcCaptureOpenDevice(MemoryUtil.getAddressSafe(buffer), frequency, format, buffersize);
|
||||
if(device_address != 0) {
|
||||
ALCdevice device = new ALCdevice(device_address);
|
||||
synchronized (ALC10.devices) {
|
||||
|
|
@ -177,7 +178,7 @@ public final class ALC11 {
|
|||
try {
|
||||
IntBuffer ib = BufferUtils.createIntBuffer(2);
|
||||
ALC10.alcGetInteger(AL.getDevice(), ALC10.ALC_MAJOR_VERSION, ib);
|
||||
ib.position(1);
|
||||
((Buffer)ib).position(1);
|
||||
ALC10.alcGetInteger(AL.getDevice(), ALC10.ALC_MINOR_VERSION, ib);
|
||||
|
||||
int major = ib.get(0);
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ public final class ALCcontext {
|
|||
* @param contextFrequency Frequency to add
|
||||
* @param contextRefresh Refresh rate to add
|
||||
* @param contextSynchronized Whether to synchronize the context
|
||||
* @return
|
||||
* @return attribute list
|
||||
*/
|
||||
static IntBuffer createAttributeList(int contextFrequency, int contextRefresh, int contextSynchronized) {
|
||||
IntBuffer attribList = BufferUtils.createIntBuffer(7);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2002-2010 LWJGL Project
|
||||
* Copyright (c) 2002-2011 LWJGL Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -31,8 +31,6 @@
|
|||
*/
|
||||
package org.lwjgl.opencl;
|
||||
|
||||
import org.lwjgl.PointerWrapperAbstract;
|
||||
|
||||
/**
|
||||
* Instances of this class can be used to receive OpenCL program build notifications.
|
||||
* A single CLBuildProgramCallback instance should only be used with programs created
|
||||
|
|
@ -40,37 +38,6 @@ import org.lwjgl.PointerWrapperAbstract;
|
|||
*
|
||||
* @author Spasi
|
||||
*/
|
||||
public abstract class CLBuildProgramCallback extends PointerWrapperAbstract {
|
||||
|
||||
private CLContext context;
|
||||
|
||||
protected CLBuildProgramCallback() {
|
||||
super(CallbackUtil.getBuildProgramCallback());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the context that contains the CLPrograms to which we're registered.
|
||||
*
|
||||
* @param context the CLContext object
|
||||
*/
|
||||
void setContext(final CLContext context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called from native code.
|
||||
*
|
||||
* @param program_address the CLProgram object pointer
|
||||
*/
|
||||
private void handleMessage(long program_address) {
|
||||
handleMessage(context.getCLProgram(program_address));
|
||||
}
|
||||
|
||||
/**
|
||||
* The callback method.
|
||||
*
|
||||
* @param program the CLProgram object that was built
|
||||
*/
|
||||
protected abstract void handleMessage(CLProgram program);
|
||||
public abstract class CLBuildProgramCallback extends CLProgramCallback {
|
||||
|
||||
}
|
||||
|
|
@ -31,9 +31,11 @@
|
|||
*/
|
||||
package org.lwjgl.opencl;
|
||||
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.LWJGLUtil;
|
||||
import org.lwjgl.PointerBuffer;
|
||||
|
||||
import java.nio.Buffer;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import static org.lwjgl.opencl.CL10.*;
|
||||
|
|
@ -53,23 +55,23 @@ final class CLChecks {
|
|||
/**
|
||||
* Calculates the number of bytes in the specified cl_mem buffer rectangle region.
|
||||
*
|
||||
* @param origin the host origin
|
||||
* @param offset the host offset
|
||||
* @param region the rectangle region
|
||||
* @param row_pitch the host row pitch
|
||||
* @param slice_pitch the host slice pitch
|
||||
*
|
||||
* @return the region size in bytes
|
||||
*/
|
||||
static int calculateBufferRectSize(final PointerBuffer origin, final PointerBuffer region, long row_pitch, long slice_pitch) {
|
||||
static int calculateBufferRectSize(final PointerBuffer offset, final PointerBuffer region, long row_pitch, long slice_pitch) {
|
||||
if ( !LWJGLUtil.CHECKS )
|
||||
return 0;
|
||||
|
||||
final long x = origin.get(0);
|
||||
final long y = origin.get(1);
|
||||
final long z = origin.get(2);
|
||||
final long x = offset.get(0);
|
||||
final long y = offset.get(1);
|
||||
final long z = offset.get(2);
|
||||
|
||||
if ( LWJGLUtil.DEBUG && (x < 0 || y < 0 || z < 0) )
|
||||
throw new IllegalArgumentException("Invalid cl_mem host origin: " + x + ", " + y + ", " + z);
|
||||
throw new IllegalArgumentException("Invalid cl_mem host offset: " + x + ", " + y + ", " + z);
|
||||
|
||||
final long w = region.get(0);
|
||||
final long h = region.get(1);
|
||||
|
|
@ -137,7 +139,7 @@ final class CLChecks {
|
|||
*
|
||||
* @return the 2D image size in bytes
|
||||
*/
|
||||
static int calculateImage2DSize(final ByteBuffer format, final long w, final long h, long row_pitch) {
|
||||
static int calculateImage2DSize(final Buffer host_ptr, final ByteBuffer format, final long w, final long h, long row_pitch) {
|
||||
if ( !LWJGLUtil.CHECKS )
|
||||
return 0;
|
||||
|
||||
|
|
@ -151,7 +153,7 @@ final class CLChecks {
|
|||
else if ( LWJGLUtil.DEBUG && ((row_pitch < w * elementSize) || (row_pitch % elementSize != 0)) )
|
||||
throw new IllegalArgumentException("Invalid image_row_pitch specified: " + row_pitch);
|
||||
|
||||
return (int)(row_pitch * h);
|
||||
return (int)(row_pitch * h) >> BufferUtils.getElementSizeExponent(host_ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -166,7 +168,7 @@ final class CLChecks {
|
|||
*
|
||||
* @return the 3D image size in bytes
|
||||
*/
|
||||
static int calculateImage3DSize(final ByteBuffer format, final long w, final long h, final long d, long row_pitch, long slice_pitch) {
|
||||
static int calculateImage3DSize(final Buffer host_ptr, final ByteBuffer format, final long w, final long h, final long d, long row_pitch, long slice_pitch) {
|
||||
if ( !LWJGLUtil.CHECKS )
|
||||
return 0;
|
||||
|
||||
|
|
@ -185,7 +187,7 @@ final class CLChecks {
|
|||
else if ( LWJGLUtil.DEBUG && ((row_pitch < row_pitch * h) || (slice_pitch % row_pitch != 0)) )
|
||||
throw new IllegalArgumentException("Invalid image_slice_pitch specified: " + row_pitch);
|
||||
|
||||
return (int)(slice_pitch * d);
|
||||
return (int)(slice_pitch * d) >> BufferUtils.getElementSizeExponent(host_ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
43
src/java/org/lwjgl/opencl/CLCompileProgramCallback.java
Normal file
43
src/java/org/lwjgl/opencl/CLCompileProgramCallback.java
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Copyright (c) 2002-2011 LWJGL Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of 'LWJGL' nor the names of
|
||||
* its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.lwjgl.opencl;
|
||||
|
||||
/**
|
||||
* Instances of this class can be used to receive OpenCL program compilation notifications.
|
||||
* A single CLCompileProgramCallback instance should only be used with programs created
|
||||
* in the same CLContext.
|
||||
*
|
||||
* @author Spasi
|
||||
*/
|
||||
public abstract class CLCompileProgramCallback extends CLProgramCallback {
|
||||
|
||||
}
|
||||
|
|
@ -49,10 +49,14 @@ public final class CLContext extends CLObjectChild<CLPlatform> {
|
|||
private static final CLContextUtil util = (CLContextUtil)CLPlatform.getInfoUtilInstance(CLContext.class, "CL_CONTEXT_UTIL");
|
||||
|
||||
private final CLObjectRegistry<CLCommandQueue> clCommandQueues;
|
||||
private final CLObjectRegistry<CLMem> clMems;
|
||||
private final CLObjectRegistry<CLSampler> clSamplers;
|
||||
private final CLObjectRegistry<CLProgram> clPrograms;
|
||||
private final CLObjectRegistry<CLEvent> clEvents;
|
||||
private final CLObjectRegistry<CLMem> clMems;
|
||||
private final CLObjectRegistry<CLSampler> clSamplers;
|
||||
private final CLObjectRegistry<CLProgram> clPrograms;
|
||||
private final CLObjectRegistry<CLEvent> clEvents;
|
||||
|
||||
private long
|
||||
contextCallback,
|
||||
printfCallback;
|
||||
|
||||
CLContext(final long pointer, final CLPlatform platform) {
|
||||
super(pointer, platform);
|
||||
|
|
@ -269,4 +273,50 @@ public final class CLContext extends CLObjectChild<CLPlatform> {
|
|||
|
||||
CLObjectRegistry<CLEvent> getCLEventRegistry() { return clEvents; }
|
||||
|
||||
private boolean checkCallback(final long callback, final int result) {
|
||||
if ( result == 0 && (callback == 0 || isValid()) )
|
||||
return true;
|
||||
|
||||
if ( callback != 0 )
|
||||
CallbackUtil.deleteGlobalRef(callback);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Associates this context with the specified context callback reference. If the context
|
||||
* is invalid, the callback reference is deleted. NO-OP if user_data is 0.
|
||||
*
|
||||
* @param callback the context callback pointer
|
||||
*/
|
||||
void setContextCallback(final long callback) {
|
||||
if ( checkCallback(callback, 0) )
|
||||
this.contextCallback = callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Associates this context with the specified printf callback reference. If the context
|
||||
* is invalid, the callback reference is deleted. NO-OP if user_data is 0.
|
||||
*
|
||||
* @param callback the printf callback pointer
|
||||
*/
|
||||
void setPrintfCallback(final long callback, final int result) {
|
||||
if ( checkCallback(callback, result) )
|
||||
this.printfCallback = callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrements the context's reference count. If the reference
|
||||
* count hits zero, it also deletes
|
||||
* any callback objects associated with it.
|
||||
*/
|
||||
void releaseImpl() {
|
||||
if ( release() > 0 )
|
||||
return;
|
||||
|
||||
if ( contextCallback != 0 )
|
||||
CallbackUtil.deleteGlobalRef(contextCallback);
|
||||
if ( printfCallback != 0 )
|
||||
CallbackUtil.deleteGlobalRef(printfCallback);
|
||||
}
|
||||
|
||||
}
|
||||
43
src/java/org/lwjgl/opencl/CLLinkProgramCallback.java
Normal file
43
src/java/org/lwjgl/opencl/CLLinkProgramCallback.java
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Copyright (c) 2002-2011 LWJGL Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of 'LWJGL' nor the names of
|
||||
* its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.lwjgl.opencl;
|
||||
|
||||
/**
|
||||
* Instances of this class can be used to receive OpenCL program linkage notifications.
|
||||
* A single CLLinkProgramCallback instance should only be used with programs created
|
||||
* in the same CLContext.
|
||||
*
|
||||
* @author Spasi
|
||||
*/
|
||||
public abstract class CLLinkProgramCallback extends CLProgramCallback {
|
||||
|
||||
}
|
||||
51
src/java/org/lwjgl/opencl/CLPrintfCallback.java
Normal file
51
src/java/org/lwjgl/opencl/CLPrintfCallback.java
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* Copyright (c) 2002-2011 LWJGL Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of 'LWJGL' nor the names of
|
||||
* its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.lwjgl.opencl;
|
||||
|
||||
import org.lwjgl.PointerWrapperAbstract;
|
||||
|
||||
/**
|
||||
* Instances of this class can be used to receive OpenCL printf messages.
|
||||
* Different CLContexts should use different CLPrintfCallback instances.
|
||||
*
|
||||
* @author Spasi
|
||||
*/
|
||||
public abstract class CLPrintfCallback extends PointerWrapperAbstract {
|
||||
|
||||
protected CLPrintfCallback() {
|
||||
super(CallbackUtil.getPrintfCallback());
|
||||
}
|
||||
|
||||
/** The callback method. */
|
||||
protected abstract void handleMessage(String data);
|
||||
|
||||
}
|
||||
74
src/java/org/lwjgl/opencl/CLProgramCallback.java
Normal file
74
src/java/org/lwjgl/opencl/CLProgramCallback.java
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* Copyright (c) 2002-2011 LWJGL Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of 'LWJGL' nor the names of
|
||||
* its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.lwjgl.opencl;
|
||||
|
||||
import org.lwjgl.PointerWrapperAbstract;
|
||||
|
||||
/**
|
||||
* Base class for OpenCL program action notifications.
|
||||
*
|
||||
* @author Spasi
|
||||
*/
|
||||
abstract class CLProgramCallback extends PointerWrapperAbstract {
|
||||
|
||||
private CLContext context;
|
||||
|
||||
protected CLProgramCallback() {
|
||||
super(CallbackUtil.getProgramCallback());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the context that contains the CLPrograms to which we're registered.
|
||||
*
|
||||
* @param context the CLContext object
|
||||
*/
|
||||
final void setContext(final CLContext context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called from native code.
|
||||
*
|
||||
* @param program_address the CLProgram object pointer
|
||||
*/
|
||||
private void handleMessage(long program_address) {
|
||||
handleMessage(context.getCLProgram(program_address));
|
||||
}
|
||||
|
||||
/**
|
||||
* The callback method.
|
||||
*
|
||||
* @param program the CLProgram object affected
|
||||
*/
|
||||
protected abstract void handleMessage(CLProgram program);
|
||||
|
||||
}
|
||||
|
|
@ -70,7 +70,7 @@ final class CallbackUtil {
|
|||
*
|
||||
* @param ref the GlobalRef memory address.
|
||||
*/
|
||||
private static native void deleteGlobalRef(long ref);
|
||||
static native void deleteGlobalRef(long ref);
|
||||
|
||||
/**
|
||||
* Deletes the global reference represented by user_data if an OpenCL error occured.
|
||||
|
|
@ -99,40 +99,6 @@ final class CallbackUtil {
|
|||
*/
|
||||
static native long getContextCallback();
|
||||
|
||||
/**
|
||||
* Associates the specified CLContext with the specified global reference. If the context
|
||||
* is invalid, the global reference is deleted. NO-OP if user_data is 0.
|
||||
*
|
||||
* @param context the CLContext to register
|
||||
* @param user_data the global reference pointer
|
||||
*/
|
||||
static void registerCallback(final CLContext context, final long user_data) {
|
||||
if ( user_data == 0 )
|
||||
return;
|
||||
|
||||
if ( context.isValid() )
|
||||
contextUserData.put(context, user_data);
|
||||
else
|
||||
deleteGlobalRef(user_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrements the specified context's reference count, clears its association
|
||||
* with a CLContextCallback object if it exists and deletes the corresponding
|
||||
* global reference.
|
||||
*
|
||||
* @param context the CLContext to unregister
|
||||
*/
|
||||
static void unregisterCallback(final CLContext context) {
|
||||
if ( context.release() > 0 )
|
||||
return;
|
||||
|
||||
final Long user_data = contextUserData.remove(context);
|
||||
|
||||
if ( user_data != null )
|
||||
deleteGlobalRef(user_data);
|
||||
}
|
||||
|
||||
/* [ Other callback functionality ]
|
||||
The other callbacks are simpler. We create the GlobalRef before passing the callback,
|
||||
we delete it when we receive the callback call.
|
||||
|
|
@ -150,7 +116,7 @@ final class CallbackUtil {
|
|||
*
|
||||
* @return the callback function address
|
||||
*/
|
||||
static native long getBuildProgramCallback();
|
||||
static native long getProgramCallback();
|
||||
|
||||
/**
|
||||
* Returns the memory address of the native function we pass to clEnqueueNativeKernel.
|
||||
|
|
@ -166,6 +132,13 @@ final class CallbackUtil {
|
|||
*/
|
||||
static native long getEventCallback();
|
||||
|
||||
/**
|
||||
* Returns the memory address of the native function we pass to clSetPrintfCallback.
|
||||
*
|
||||
* @return the callback function address
|
||||
*/
|
||||
static native long getPrintfCallback();
|
||||
|
||||
/**
|
||||
* Returns the memory address of the native function we pass to clCreateContext(FromType),
|
||||
* when <code>APPLEContextLoggingUtil.SYSTEM_LOG_CALLBACK</code> is used.
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ final class InfoUtilFactory {
|
|||
Util.checkCLError(errcode_ret.get(0));
|
||||
return __result;
|
||||
} finally {
|
||||
CallbackUtil.registerCallback(__result, user_data);
|
||||
if ( __result != null ) __result.setContextCallback(user_data);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -305,7 +305,7 @@ final class InfoUtilFactory {
|
|||
errcode_ret = APIUtil.getBufferInt();
|
||||
|
||||
CLMem __result = new CLMem(nclCreateImage2D(context.getPointer(), flags, MemoryUtil.getAddress(formatBuffer, 0), image_width, image_height, image_row_pitch, MemoryUtil.getAddress0Safe(host_ptr) +
|
||||
(host_ptr != null ? BufferChecks.checkBuffer(host_ptr, CLChecks.calculateImage2DSize(formatBuffer, image_width, image_height, image_row_pitch)) : 0),
|
||||
(host_ptr != null ? BufferChecks.checkBuffer(host_ptr, CLChecks.calculateImage2DSize(host_ptr, formatBuffer, image_width, image_height, image_row_pitch)) : 0),
|
||||
MemoryUtil.getAddressSafe(errcode_ret), function_pointer), context);
|
||||
if ( LWJGLUtil.DEBUG )
|
||||
Util.checkCLError(errcode_ret.get(0));
|
||||
|
|
@ -325,7 +325,7 @@ final class InfoUtilFactory {
|
|||
errcode_ret = APIUtil.getBufferInt();
|
||||
|
||||
CLMem __result = new CLMem(nclCreateImage3D(context.getPointer(), flags, MemoryUtil.getAddress(formatBuffer, 0), image_width, image_height, image_depth, image_row_pitch, image_slice_pitch, MemoryUtil.getAddress0Safe(host_ptr) +
|
||||
(host_ptr != null ? BufferChecks.checkBuffer(host_ptr, CLChecks.calculateImage3DSize(formatBuffer, image_width, image_height, image_depth, image_row_pitch, image_slice_pitch)) : 0),
|
||||
(host_ptr != null ? BufferChecks.checkBuffer(host_ptr, CLChecks.calculateImage3DSize(host_ptr, formatBuffer, image_width, image_height, image_depth, image_row_pitch, image_slice_pitch)) : 0),
|
||||
MemoryUtil.getAddressSafe(errcode_ret), function_pointer), context);
|
||||
if ( LWJGLUtil.DEBUG )
|
||||
Util.checkCLError(errcode_ret.get(0));
|
||||
|
|
@ -547,7 +547,7 @@ final class InfoUtilFactory {
|
|||
|
||||
target = new ByteBuffer[sizes.remaining()];
|
||||
for ( int i = 0; i < sizes.remaining(); i++ )
|
||||
target[i] = BufferUtils.createByteBuffer((int)sizes.get(0));
|
||||
target[i] = BufferUtils.createByteBuffer((int)sizes.get(i));
|
||||
} else if ( LWJGLUtil.DEBUG ) {
|
||||
final PointerBuffer sizes = getSizesBuffer(program, CL_PROGRAM_BINARY_SIZES);
|
||||
|
||||
|
|
@ -603,4 +603,4 @@ final class InfoUtilFactory {
|
|||
}
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ public final class AMDDebugOutputCallback extends PointerWrapperAbstract {
|
|||
description = "OTHER";
|
||||
break;
|
||||
default:
|
||||
description = "Unknown (" + Integer.toHexString(category) + ")";
|
||||
description = printUnknownToken(category);
|
||||
}
|
||||
System.err.println("\tCategory: " + description);
|
||||
|
||||
|
|
@ -125,12 +125,16 @@ public final class AMDDebugOutputCallback extends PointerWrapperAbstract {
|
|||
description = "LOW";
|
||||
break;
|
||||
default:
|
||||
description = "Unknown (" + Integer.toHexString(category) + ")";
|
||||
description = printUnknownToken(severity);
|
||||
}
|
||||
System.err.println("\tSeverity: " + description);
|
||||
|
||||
System.err.println("\tMessage: " + message);
|
||||
}
|
||||
|
||||
private String printUnknownToken(final int token) {
|
||||
return "Unknown (0x" + Integer.toHexString(token).toUpperCase() + ")";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ final class APIUtil {
|
|||
buffer = BufferUtils.createByteBuffer(size);
|
||||
caps.util.buffer = buffer;
|
||||
} else
|
||||
buffer.clear();
|
||||
((Buffer)buffer).clear();
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
|
@ -114,8 +114,8 @@ final class APIUtil {
|
|||
bufferNew.put(buffer);
|
||||
caps.util.buffer = (buffer = bufferNew);
|
||||
} else {
|
||||
buffer.position(buffer.limit());
|
||||
buffer.limit(buffer.capacity());
|
||||
((Buffer)buffer).position(buffer.limit());
|
||||
((Buffer)buffer).limit(buffer.capacity());
|
||||
}
|
||||
|
||||
return buffer;
|
||||
|
|
@ -193,7 +193,7 @@ final class APIUtil {
|
|||
*/
|
||||
static long getBuffer(final ContextCapabilities caps, final CharSequence string) {
|
||||
final ByteBuffer buffer = encode(getBufferByte(caps, string.length()), string);
|
||||
buffer.flip();
|
||||
((Buffer)buffer).flip();
|
||||
return MemoryUtil.getAddress0(buffer);
|
||||
}
|
||||
|
||||
|
|
@ -206,7 +206,7 @@ final class APIUtil {
|
|||
*/
|
||||
static long getBuffer(final ContextCapabilities caps, final CharSequence string, final int offset) {
|
||||
final ByteBuffer buffer = encode(getBufferByteOffset(caps, offset + string.length()), string);
|
||||
buffer.flip();
|
||||
((Buffer)buffer).flip();
|
||||
return MemoryUtil.getAddress(buffer);
|
||||
}
|
||||
|
||||
|
|
@ -220,7 +220,7 @@ final class APIUtil {
|
|||
static long getBufferNT(final ContextCapabilities caps, final CharSequence string) {
|
||||
final ByteBuffer buffer = encode(getBufferByte(caps, string.length() + 1), string);
|
||||
buffer.put((byte)0);
|
||||
buffer.flip();
|
||||
((Buffer)buffer).flip();
|
||||
return MemoryUtil.getAddress0(buffer);
|
||||
}
|
||||
|
||||
|
|
@ -245,7 +245,7 @@ final class APIUtil {
|
|||
for ( CharSequence string : strings )
|
||||
encode(buffer, string);
|
||||
|
||||
buffer.flip();
|
||||
((Buffer)buffer).flip();
|
||||
return MemoryUtil.getAddress0(buffer);
|
||||
}
|
||||
|
||||
|
|
@ -264,7 +264,7 @@ final class APIUtil {
|
|||
buffer.put((byte)0);
|
||||
}
|
||||
|
||||
buffer.flip();
|
||||
((Buffer)buffer).flip();
|
||||
return MemoryUtil.getAddress0(buffer);
|
||||
}
|
||||
|
||||
|
|
@ -281,7 +281,7 @@ final class APIUtil {
|
|||
for ( CharSequence string : strings )
|
||||
buffer.put(string.length());
|
||||
|
||||
buffer.flip();
|
||||
((Buffer)buffer).flip();
|
||||
return MemoryUtil.getAddress0(buffer);
|
||||
}
|
||||
|
||||
|
|
@ -293,4 +293,4 @@ final class APIUtil {
|
|||
return MemoryUtil.getAddress0(getBufferByte(caps, 0));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ public final class ARBDebugOutputCallback extends PointerWrapperAbstract {
|
|||
description = "OTHER";
|
||||
break;
|
||||
default:
|
||||
description = "Unknown (" + Integer.toHexString(source) + ")";
|
||||
description = printUnknownToken(source);
|
||||
}
|
||||
System.err.println("\tSource: " + description);
|
||||
|
||||
|
|
@ -137,7 +137,7 @@ public final class ARBDebugOutputCallback extends PointerWrapperAbstract {
|
|||
description = "OTHER";
|
||||
break;
|
||||
default:
|
||||
description = "Unknown (" + Integer.toHexString(source) + ")";
|
||||
description = printUnknownToken(type);
|
||||
}
|
||||
System.err.println("\tType: " + description);
|
||||
|
||||
|
|
@ -152,12 +152,16 @@ public final class ARBDebugOutputCallback extends PointerWrapperAbstract {
|
|||
description = "LOW";
|
||||
break;
|
||||
default:
|
||||
description = "Unknown (" + Integer.toHexString(source) + ")";
|
||||
description = printUnknownToken(severity);
|
||||
}
|
||||
System.err.println("\tSeverity: " + description);
|
||||
|
||||
System.err.println("\tMessage: " + message);
|
||||
}
|
||||
|
||||
private String printUnknownToken(final int token) {
|
||||
return "Unknown (0x" + Integer.toHexString(token).toUpperCase() + ")";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -184,9 +188,9 @@ public final class ARBDebugOutputCallback extends PointerWrapperAbstract {
|
|||
/**
|
||||
* This method will be called when an ARB_debug_output message is generated.
|
||||
*
|
||||
* @param id the message ID
|
||||
* @param source the message source
|
||||
* @param type the message type
|
||||
* @param id the message ID
|
||||
* @param severity the message severity
|
||||
* @param message the string representation of the message.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@
|
|||
package org.lwjgl.opengl;
|
||||
|
||||
import java.awt.Canvas;
|
||||
import java.awt.Component;
|
||||
import java.applet.Applet;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedActionException;
|
||||
|
|
@ -80,16 +82,13 @@ final class AWTSurfaceLock {
|
|||
// It is only needed on first call, so we avoid it on all subsequent calls
|
||||
// due to performance..
|
||||
|
||||
// Allow the use of a Core Animation Layer only when using non fullscreen Display.setParent() or AWTGLCanvas
|
||||
final boolean allowCALayer = (Display.getParent() != null && !Display.isFullscreen()) || component instanceof AWTGLCanvas;
|
||||
|
||||
if (firstLockSucceeded)
|
||||
return lockAndInitHandle(lock_buffer, component, allowCALayer);
|
||||
return lockAndInitHandle(lock_buffer, component);
|
||||
else
|
||||
try {
|
||||
firstLockSucceeded = AccessController.doPrivileged(new PrivilegedExceptionAction<Boolean>() {
|
||||
public Boolean run() throws LWJGLException {
|
||||
return lockAndInitHandle(lock_buffer, component, allowCALayer);
|
||||
return lockAndInitHandle(lock_buffer, component);
|
||||
}
|
||||
});
|
||||
return firstLockSucceeded;
|
||||
|
|
@ -98,7 +97,7 @@ final class AWTSurfaceLock {
|
|||
}
|
||||
}
|
||||
|
||||
private static native boolean lockAndInitHandle(ByteBuffer lock_buffer, Canvas component, boolean allowCALayer) throws LWJGLException;
|
||||
private static native boolean lockAndInitHandle(ByteBuffer lock_buffer, Canvas component) throws LWJGLException;
|
||||
|
||||
void unlock() throws LWJGLException {
|
||||
nUnlock(lock_buffer);
|
||||
|
|
|
|||
|
|
@ -42,9 +42,11 @@ import java.util.Map;
|
|||
final class CallbackUtil {
|
||||
|
||||
/** Context -> Long */
|
||||
private static final Map<ContextGL, Long> contextUserParamsARB = new HashMap<ContextGL, Long>();
|
||||
private static final Map<ContextCapabilities, Long> contextUserParamsARB = new HashMap<ContextCapabilities, Long>();
|
||||
/** Context -> Long */
|
||||
private static final Map<ContextGL, Long> contextUserParamsAMD = new HashMap<ContextGL, Long>();
|
||||
private static final Map<ContextCapabilities, Long> contextUserParamsAMD = new HashMap<ContextCapabilities, Long>();
|
||||
/** Context -> Long */
|
||||
private static final Map<ContextCapabilities, Long> contextUserParamsKHR = new HashMap<ContextCapabilities, Long>();
|
||||
|
||||
private CallbackUtil() {}
|
||||
|
||||
|
|
@ -84,19 +86,19 @@ final class CallbackUtil {
|
|||
*
|
||||
* @param userParam the global reference pointer
|
||||
*/
|
||||
private static void registerContextCallback(final long userParam, final Map<ContextGL, Long> contextUserData) {
|
||||
ContextGL context = ContextGL.getCurrentContext();
|
||||
if ( context == null ) {
|
||||
private static void registerContextCallback(final long userParam, final Map<ContextCapabilities, Long> contextUserData) {
|
||||
ContextCapabilities caps = GLContext.getCapabilities();
|
||||
if ( caps == null ) {
|
||||
deleteGlobalRef(userParam);
|
||||
throw new IllegalStateException("No context is current.");
|
||||
}
|
||||
|
||||
final Long userParam_old = contextUserData.remove(context);
|
||||
final Long userParam_old = contextUserData.remove(caps);
|
||||
if ( userParam_old != null )
|
||||
deleteGlobalRef(userParam_old);
|
||||
|
||||
if ( userParam != 0 )
|
||||
contextUserData.put(context, userParam);
|
||||
contextUserData.put(caps, userParam);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -104,12 +106,19 @@ final class CallbackUtil {
|
|||
*
|
||||
* @param context the Context to unregister
|
||||
*/
|
||||
static void unregisterCallbacks(final ContextGL context) {
|
||||
Long userParam = contextUserParamsARB.remove(context);
|
||||
static void unregisterCallbacks(final Object context) {
|
||||
// TODO: This is never called for custom contexts. Need to fix for LWJGL 3.0
|
||||
final ContextCapabilities caps = GLContext.getCapabilities(context);
|
||||
|
||||
Long userParam = contextUserParamsARB.remove(caps);
|
||||
if ( userParam != null )
|
||||
deleteGlobalRef(userParam);
|
||||
|
||||
userParam = contextUserParamsAMD.remove(context);
|
||||
userParam = contextUserParamsAMD.remove(caps);
|
||||
if ( userParam != null )
|
||||
deleteGlobalRef(userParam);
|
||||
|
||||
userParam = contextUserParamsKHR.remove(caps);
|
||||
if ( userParam != null )
|
||||
deleteGlobalRef(userParam);
|
||||
}
|
||||
|
|
@ -154,4 +163,24 @@ final class CallbackUtil {
|
|||
registerContextCallback(userParam, contextUserParamsAMD);
|
||||
}
|
||||
|
||||
// --------- [ KHR_debug ] ---------
|
||||
|
||||
/**
|
||||
* Returns the memory address of the native function we pass to glDebugMessageCallback.
|
||||
*
|
||||
* @return the callback function address
|
||||
*/
|
||||
static native long getDebugCallbackKHR();
|
||||
|
||||
/**
|
||||
* Associates the current OpenGL context with the specified global reference. If there
|
||||
* is no context current, the global reference is deleted and an exception is thrown.
|
||||
* Any previous callback registrations will be cleared.
|
||||
*
|
||||
* @param userParam the global reference pointer
|
||||
*/
|
||||
static void registerContextCallbackKHR(final long userParam) {
|
||||
registerContextCallback(userParam, contextUserParamsKHR);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -32,7 +32,6 @@
|
|||
package org.lwjgl.opengl;
|
||||
|
||||
import org.lwjgl.LWJGLException;
|
||||
import org.lwjgl.opengles.PowerManagementEventException;
|
||||
|
||||
/**
|
||||
* @author Spasi
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2002-2008 LWJGL Project
|
||||
* Copyright (c) 2002-2014 LWJGL Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -35,274 +35,399 @@ import org.lwjgl.BufferUtils;
|
|||
import org.lwjgl.LWJGLUtil;
|
||||
|
||||
import java.nio.IntBuffer;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
/**
|
||||
* This class represents the context attributes passed to CreateContextAttribs of the ARB_create_context and
|
||||
* ARB_create_context_profile extensions.
|
||||
* These attributes can be used to indicate at context creation which OpenGL interface will be used. This includes the
|
||||
* OpenGL version, the layer plane on which rendering takes place and also optional debug and forward combatibility modes.
|
||||
* (read the ARB_create_context spec for details)
|
||||
* This class represents the context attributes passed to CreateContextAttribs of the ARB_create_context extension.
|
||||
* <p/>
|
||||
* The attributes supported are described in the following extensions:<br>
|
||||
* <ul>
|
||||
* <li><a href="http://www.opengl.org/registry/specs/ARB/wgl_create_context.txt">WGL_ARB_create_context(_profile)</a> and <a href="http://www.opengl.org/registry/specs/ARB/glx_create_context.txt">GLX_ARB_create_context(_profile)</a></li>
|
||||
* <li><a href="http://www.opengl.org/registry/specs/ARB/wgl_create_context_robustness.txt">WGL_ARB_create_context_robustness</a> and <a href="http://www.opengl.org/registry/specs/ARB/glx_create_context_robustness.txt">GLX_ARB_create_context_robustness</a></li>
|
||||
* <li><a href="http://www.opengl.org/registry/specs/ARB/wgl_robustness_isolation.txt">WGL_ARB_robustness_isolation</a> and <a href="http://www.opengl.org/registry/specs/ARB/glx_robustness_isolation.txt">GLX_ARB_robustness_isolation</a></li>
|
||||
* <li><a href="http://www.opengl.org/registry/specs/ARB/wgl_create_context_es2_profile.txt">WGL_EXT_create_context_es2_profile</a> and <a href="http://www.opengl.org/registry/specs/ARB/glx_create_context_es2_profile.txt">GLX_EXT_create_context_es2_profile</a></li>
|
||||
* <li><a href="http://www.opengl.org/registry/specs/ARB/context_flush_control.txt">KHR_context_flush_control</a></li>
|
||||
* </ul>
|
||||
* <p/>
|
||||
* Use of this class is optional. If an OpenGL context is created without passing an instance of this class
|
||||
* (or ARB_create_context is not supported), the old context creation code will be used. Support for debug and forward
|
||||
* compatible mobes is not guaranteed by the OpenGL implementation. Developers may encounter debug contexts being the same
|
||||
* as non-debug contexts or forward compatible contexts having support for deprecated functionality.
|
||||
* <p/>
|
||||
* If the forwardCompatible
|
||||
* attribute is used, LWJGL will not load the deprecated functionality (as defined in the OpenGL 3.0 specification). This
|
||||
* means that developers can start working on cleaning up their applications without an OpenGL 3.0 complaint driver.
|
||||
* If the {@link #CONTEXT_FORWARD_COMPATIBLE_BIT_ARB} flag is used, LWJGL will not load the deprecated functionality (as defined in the OpenGL 3.0
|
||||
* specification), even if the driver exposes the corresponding entry points.
|
||||
* <p/>
|
||||
* This extension is not supported on MacOS X. However, in order to enable the GL 3.2 context on MacOS X 10.7 or newer, an
|
||||
* instance of this class must be passed to LWJGL. The only valid configuration is <code>new ContextAttribs(3, 2).withProfileCore()</code>,
|
||||
* anything else will be ignored.
|
||||
* This extension is not supported on MacOS X. However, in order to enable the GL 3.2 context on MacOS X 10.7 or newer, an instance of this class must be passed
|
||||
* to LWJGL. The only valid configuration is <code>ContextAttribs(3, 2, CONTEXT_CORE_PROFILE_BIT_ARB)</code>, anything else will be ignored.
|
||||
*
|
||||
* @author spasi <spasi@users.sourceforge.net>
|
||||
*/
|
||||
public final class ContextAttribs {
|
||||
|
||||
// Same values for GLX & WGL
|
||||
private static final int CONTEXT_ES2_PROFILE_BIT_EXT = 0x00000004;
|
||||
// ATTRIBUTES
|
||||
|
||||
private static final int CONTEXT_ROBUST_ACCESS_BIT_ARB = 0x00000004;
|
||||
private static final int CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB = 0x8256;
|
||||
private static final int
|
||||
NO_RESET_NOTIFICATION_ARB = 0x8261,
|
||||
LOSE_CONTEXT_ON_RESET_ARB = 0x8252;
|
||||
public static final int CONTEXT_MAJOR_VERSION_ARB = 0x2091;
|
||||
public static final int CONTEXT_MINOR_VERSION_ARB = 0x2092;
|
||||
|
||||
public static final int CONTEXT_PROFILE_MASK_ARB = 0x9126,
|
||||
CONTEXT_CORE_PROFILE_BIT_ARB = 0x00000001,
|
||||
CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB = 0x00000002,
|
||||
CONTEXT_ES2_PROFILE_BIT_EXT = 0x00000004;
|
||||
|
||||
public static final int CONTEXT_FLAGS_ARB = 0x2094,
|
||||
CONTEXT_DEBUG_BIT_ARB = 0x0001,
|
||||
CONTEXT_FORWARD_COMPATIBLE_BIT_ARB = 0x0002,
|
||||
CONTEXT_ROBUST_ACCESS_BIT_ARB = 0x00000004,
|
||||
CONTEXT_RESET_ISOLATION_BIT_ARB = 0x00000008;
|
||||
|
||||
public static final int CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB = 0x8256,
|
||||
NO_RESET_NOTIFICATION_ARB = 0x8261,
|
||||
LOSE_CONTEXT_ON_RESET_ARB = 0x8252;
|
||||
|
||||
public static final int CONTEXT_RELEASE_BEHABIOR_ARB = 0x2097,
|
||||
CONTEXT_RELEASE_BEHAVIOR_NONE_ARB = 0x0000,
|
||||
CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB = 0x2098;
|
||||
|
||||
public static final int CONTEXT_LAYER_PLANE_ARB = 0x2093; // WGL-only
|
||||
|
||||
// STATE
|
||||
|
||||
private int majorVersion;
|
||||
private int minorVersion;
|
||||
|
||||
private int profileMask;
|
||||
private int contextFlags;
|
||||
|
||||
private int contextResetNotificationStrategy = NO_RESET_NOTIFICATION_ARB;
|
||||
private int contextReleaseBehavior = CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB;
|
||||
|
||||
private int layerPlane;
|
||||
|
||||
private boolean debug;
|
||||
private boolean forwardCompatible;
|
||||
private boolean robustAccess;
|
||||
|
||||
private boolean profileCore;
|
||||
private boolean profileCompatibility;
|
||||
private boolean profileES;
|
||||
|
||||
private boolean loseContextOnReset;
|
||||
// CONSTRUCTORS
|
||||
|
||||
/** Creates the default ContextAttribs instance. No special attributes will be used when creating the OpenGL context. */
|
||||
public ContextAttribs() {
|
||||
this(1, 0);
|
||||
}
|
||||
|
||||
public ContextAttribs(final int majorVersion, final int minorVersion) {
|
||||
/** Creates a ContextAttribs instance for the given OpenGL version. */
|
||||
public ContextAttribs(int majorVersion, int minorVersion) {
|
||||
this(majorVersion, minorVersion, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new ContextAttribs instance with the given attributes.
|
||||
*
|
||||
* @param majorVersion the major OpenGL version
|
||||
* @param minorVersion the minor OpenGL version
|
||||
* @param profileMask the context profile mask. One of:<br>{@link #CONTEXT_CORE_PROFILE_BIT_ARB}, {@link #CONTEXT_FORWARD_COMPATIBLE_BIT_ARB}, {@link #CONTEXT_ES2_PROFILE_BIT_EXT}
|
||||
*/
|
||||
public ContextAttribs(int majorVersion, int minorVersion, int profileMask) {
|
||||
this(majorVersion, minorVersion, 0, profileMask);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new ContextAttribs instance with the given attributes.
|
||||
*
|
||||
* @param majorVersion the major OpenGL version
|
||||
* @param minorVersion the minor OpenGL version
|
||||
* @param profileMask the context profile mask. One of:<br>{@link #CONTEXT_CORE_PROFILE_BIT_ARB}, {@link #CONTEXT_FORWARD_COMPATIBLE_BIT_ARB}, {@link #CONTEXT_ES2_PROFILE_BIT_EXT}
|
||||
* @param contextFlags the context flags, a bitfield value. One or more of:<br>{@link #CONTEXT_DEBUG_BIT_ARB}, {@link #CONTEXT_FORWARD_COMPATIBLE_BIT_ARB}, {@link #CONTEXT_ROBUST_ACCESS_BIT_ARB}, {@link #CONTEXT_RESET_ISOLATION_BIT_ARB}
|
||||
*/
|
||||
public ContextAttribs(int majorVersion, int minorVersion, int profileMask, int contextFlags) {
|
||||
if ( majorVersion < 0 || 4 < majorVersion ||
|
||||
minorVersion < 0 ||
|
||||
(majorVersion == 4 && 2 < minorVersion) ||
|
||||
(majorVersion == 4 && 5 < minorVersion) ||
|
||||
(majorVersion == 3 && 3 < minorVersion) ||
|
||||
(majorVersion == 2 && 1 < minorVersion) ||
|
||||
(majorVersion == 1 && 5 < minorVersion) )
|
||||
throw new IllegalArgumentException("Invalid OpenGL version specified: " + majorVersion + '.' + minorVersion);
|
||||
|
||||
if ( LWJGLUtil.CHECKS ) {
|
||||
if ( 1 < Integer.bitCount(profileMask) || CONTEXT_ES2_PROFILE_BIT_EXT < profileMask )
|
||||
throw new IllegalArgumentException("Invalid profile mask specified: " + Integer.toBinaryString(profileMask));
|
||||
|
||||
if ( 0xF < contextFlags )
|
||||
throw new IllegalArgumentException("Invalid context flags specified: " + Integer.toBinaryString(profileMask));
|
||||
}
|
||||
|
||||
this.majorVersion = majorVersion;
|
||||
this.minorVersion = minorVersion;
|
||||
|
||||
this.profileMask = profileMask;
|
||||
this.contextFlags = contextFlags;
|
||||
}
|
||||
|
||||
private ContextAttribs(final ContextAttribs attribs) {
|
||||
this.majorVersion = attribs.majorVersion;
|
||||
this.minorVersion = attribs.minorVersion;
|
||||
// Copy constructor
|
||||
private ContextAttribs(ContextAttribs other) {
|
||||
this.majorVersion = other.majorVersion;
|
||||
this.minorVersion = other.minorVersion;
|
||||
|
||||
this.layerPlane = attribs.layerPlane;
|
||||
this.profileMask = other.profileMask;
|
||||
this.contextFlags = other.contextFlags;
|
||||
|
||||
this.debug = attribs.debug;
|
||||
this.forwardCompatible = attribs.forwardCompatible;
|
||||
this.robustAccess = attribs.robustAccess;
|
||||
this.contextResetNotificationStrategy = other.contextResetNotificationStrategy;
|
||||
this.contextReleaseBehavior = other.contextReleaseBehavior;
|
||||
|
||||
this.profileCore = attribs.profileCore;
|
||||
this.profileCompatibility = attribs.profileCompatibility;
|
||||
this.profileES = attribs.profileES;
|
||||
|
||||
this.loseContextOnReset = attribs.loseContextOnReset;
|
||||
this.layerPlane = other.layerPlane;
|
||||
}
|
||||
|
||||
// GETTERS
|
||||
|
||||
/** Returns the {@link #CONTEXT_MAJOR_VERSION_ARB} value. */
|
||||
public int getMajorVersion() {
|
||||
return majorVersion;
|
||||
}
|
||||
|
||||
/** Returns the {@link #CONTEXT_MINOR_VERSION_ARB} value. */
|
||||
public int getMinorVersion() {
|
||||
return minorVersion;
|
||||
}
|
||||
|
||||
/** Returns the {@link #CONTEXT_PROFILE_MASK_ARB} value. */
|
||||
public int getProfileMask() {
|
||||
return profileMask;
|
||||
}
|
||||
|
||||
private boolean hasMask(int mask) {
|
||||
return profileMask == mask;
|
||||
}
|
||||
|
||||
/** Returns true if the {@link #CONTEXT_CORE_PROFILE_BIT_ARB} has been set. */
|
||||
public boolean isProfileCore() {
|
||||
return hasMask(CONTEXT_CORE_PROFILE_BIT_ARB);
|
||||
}
|
||||
|
||||
/** Returns true if the {@link #CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB} has been set. */
|
||||
public boolean isProfileCompatibility() {
|
||||
return hasMask(CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB);
|
||||
}
|
||||
|
||||
/** Returns true if the {@link #CONTEXT_ES2_PROFILE_BIT_EXT} has been set. */
|
||||
public boolean isProfileES() {
|
||||
return hasMask(CONTEXT_ES2_PROFILE_BIT_EXT);
|
||||
}
|
||||
|
||||
/** Returns the {@link #CONTEXT_FLAGS_ARB} value. */
|
||||
public int getContextFlags() {
|
||||
return contextFlags;
|
||||
}
|
||||
|
||||
private boolean hasFlag(int flag) {
|
||||
return (contextFlags & flag) != 0;
|
||||
}
|
||||
|
||||
/** Returns true if the {@link #CONTEXT_DEBUG_BIT_ARB} has been set. */
|
||||
public boolean isDebug() {
|
||||
return hasFlag(CONTEXT_DEBUG_BIT_ARB);
|
||||
}
|
||||
|
||||
/** Returns true if the {@link #CONTEXT_FORWARD_COMPATIBLE_BIT_ARB} has been set. */
|
||||
public boolean isForwardCompatible() {
|
||||
return hasFlag(CONTEXT_FORWARD_COMPATIBLE_BIT_ARB);
|
||||
}
|
||||
|
||||
/** Returns true if the {@link #CONTEXT_ROBUST_ACCESS_BIT_ARB} has been set. */
|
||||
public boolean isRobustAccess() { return hasFlag(CONTEXT_ROBUST_ACCESS_BIT_ARB); }
|
||||
|
||||
/** Returns true if the {@link #CONTEXT_RESET_ISOLATION_BIT_ARB} has been set. */
|
||||
public boolean isContextResetIsolation() {
|
||||
return hasFlag(CONTEXT_RESET_ISOLATION_BIT_ARB);
|
||||
}
|
||||
|
||||
/** Returns the {@link #CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB} value. */
|
||||
public int getContextResetNotificationStrategy() {
|
||||
return contextResetNotificationStrategy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the {@link #CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB} has been set to {@link #LOSE_CONTEXT_ON_RESET_ARB}.
|
||||
*
|
||||
* @deprecated use {@link #getContextResetNotificationStrategy} instead
|
||||
*/
|
||||
public boolean isLoseContextOnReset() { return contextResetNotificationStrategy == LOSE_CONTEXT_ON_RESET_ARB; }
|
||||
|
||||
/** Returns the {@link #CONTEXT_RELEASE_BEHABIOR_ARB} value. */
|
||||
public int getContextReleaseBehavior() {
|
||||
return contextReleaseBehavior;
|
||||
}
|
||||
|
||||
/** Returns the {@link #CONTEXT_LAYER_PLANE_ARB} value. */
|
||||
public int getLayerPlane() {
|
||||
return layerPlane;
|
||||
}
|
||||
|
||||
public boolean isDebug() {
|
||||
return debug;
|
||||
}
|
||||
// CHAIN CONFIGURATION PATTERN
|
||||
|
||||
public boolean isForwardCompatible() {
|
||||
return forwardCompatible;
|
||||
}
|
||||
|
||||
public boolean isProfileCore() {
|
||||
return profileCore;
|
||||
}
|
||||
|
||||
public boolean isProfileCompatibility() {
|
||||
return profileCompatibility;
|
||||
}
|
||||
|
||||
public boolean isProfileES() {
|
||||
return profileES;
|
||||
}
|
||||
|
||||
public ContextAttribs withLayer(final int layerPlane) {
|
||||
if ( layerPlane < 0 )
|
||||
throw new IllegalArgumentException("Invalid layer plane specified: " + layerPlane);
|
||||
|
||||
if ( layerPlane == this.layerPlane )
|
||||
private ContextAttribs toggleMask(int mask, boolean value) {
|
||||
if ( value == hasMask(mask) )
|
||||
return this;
|
||||
|
||||
final ContextAttribs attribs = new ContextAttribs(this);
|
||||
attribs.layerPlane = layerPlane;
|
||||
return attribs;
|
||||
}
|
||||
|
||||
public ContextAttribs withDebug(final boolean debug) {
|
||||
if ( debug == this.debug )
|
||||
return this;
|
||||
|
||||
final ContextAttribs attribs = new ContextAttribs(this);
|
||||
attribs.debug = debug;
|
||||
return attribs;
|
||||
}
|
||||
|
||||
public ContextAttribs withForwardCompatible(final boolean forwardCompatible) {
|
||||
if ( forwardCompatible == this.forwardCompatible )
|
||||
return this;
|
||||
|
||||
final ContextAttribs attribs = new ContextAttribs(this);
|
||||
attribs.forwardCompatible = forwardCompatible;
|
||||
return attribs;
|
||||
}
|
||||
|
||||
public ContextAttribs withProfileCore(final boolean profileCore) {
|
||||
if ( majorVersion < 3 || (majorVersion == 3 && minorVersion < 2) )
|
||||
throw new IllegalArgumentException("Profiles are only supported on OpenGL version 3.2 or higher.");
|
||||
|
||||
if ( profileCore == this.profileCore )
|
||||
return this;
|
||||
|
||||
final ContextAttribs attribs = new ContextAttribs(this);
|
||||
attribs.profileCore = profileCore;
|
||||
if ( profileCore )
|
||||
attribs.profileCompatibility = false;
|
||||
|
||||
return attribs;
|
||||
}
|
||||
|
||||
public ContextAttribs withProfileCompatibility(final boolean profileCompatibility) {
|
||||
if ( majorVersion < 3 || (majorVersion == 3 && minorVersion < 2) )
|
||||
throw new IllegalArgumentException("Profiles are only supported on OpenGL version 3.2 or higher.");
|
||||
|
||||
if ( profileCompatibility == this.profileCompatibility )
|
||||
return this;
|
||||
|
||||
final ContextAttribs attribs = new ContextAttribs(this);
|
||||
attribs.profileCompatibility = profileCompatibility;
|
||||
if ( profileCompatibility )
|
||||
attribs.profileCore = false;
|
||||
|
||||
return attribs;
|
||||
}
|
||||
|
||||
public ContextAttribs withProfileES(final boolean profileES) {
|
||||
if ( !(majorVersion == 2 && minorVersion == 0) )
|
||||
throw new IllegalArgumentException("The OpenGL ES profiles is only supported for OpenGL version 2.0.");
|
||||
|
||||
if ( profileES == this.profileES )
|
||||
return this;
|
||||
|
||||
final ContextAttribs attribs = new ContextAttribs(this);
|
||||
attribs.profileES = profileES;
|
||||
|
||||
ContextAttribs attribs = new ContextAttribs(this);
|
||||
attribs.profileMask = value ? mask : 0;
|
||||
return attribs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a ContextAttribs instance with CONTEXT_RESET_NOTIFICATION_STRATEGY set
|
||||
* to LOSE_CONTEXT_ON_RESET if the parameter is true or to NO_RESET_NOTIFICATION
|
||||
* if the parameter is false.
|
||||
*
|
||||
* @param loseContextOnReset
|
||||
*
|
||||
* @return the new ContextAttribs
|
||||
* Returns a new {@code ContextAttribs} instance with the {@link #CONTEXT_CORE_PROFILE_BIT_ARB} bit in {@link #CONTEXT_PROFILE_MASK_ARB} set to the given value.
|
||||
* If {@code profileCore} is true, all other bits in the mask are cleared.
|
||||
*/
|
||||
public ContextAttribs withLoseContextOnReset(final boolean loseContextOnReset) {
|
||||
if ( loseContextOnReset == this.loseContextOnReset )
|
||||
public ContextAttribs withProfileCore(boolean profileCore) {
|
||||
if ( majorVersion < 3 || (majorVersion == 3 && minorVersion < 2) )
|
||||
throw new IllegalArgumentException("Profiles are only supported on OpenGL version 3.2 or higher.");
|
||||
|
||||
return toggleMask(CONTEXT_CORE_PROFILE_BIT_ARB, profileCore);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new {@code ContextAttribs} instance with the {@link #CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB} bit in {@link #CONTEXT_PROFILE_MASK_ARB} set to the given value.
|
||||
* If {@code profileCompatibility} is true, all other bits in the mask are cleared.
|
||||
*/
|
||||
public ContextAttribs withProfileCompatibility(boolean profileCompatibility) {
|
||||
if ( majorVersion < 3 || (majorVersion == 3 && minorVersion < 2) )
|
||||
throw new IllegalArgumentException("Profiles are only supported on OpenGL version 3.2 or higher.");
|
||||
|
||||
return toggleMask(CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, profileCompatibility);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new {@code ContextAttribs} instance with the {@link #CONTEXT_ES2_PROFILE_BIT_EXT} bit in {@link #CONTEXT_PROFILE_MASK_ARB} set to the given value.
|
||||
* If {@code profileES} is true, all other bits in the mask are cleared.
|
||||
*/
|
||||
public ContextAttribs withProfileES(boolean profileES) {
|
||||
if ( !(majorVersion == 2 && minorVersion == 0) )
|
||||
throw new IllegalArgumentException("The OpenGL ES profile is only supported on OpenGL version 2.0.");
|
||||
|
||||
return toggleMask(CONTEXT_ES2_PROFILE_BIT_EXT, profileES);
|
||||
}
|
||||
|
||||
private ContextAttribs toggleFlag(int flag, boolean value) {
|
||||
if ( value == hasFlag(flag) )
|
||||
return this;
|
||||
|
||||
final ContextAttribs attribs = new ContextAttribs(this);
|
||||
attribs.loseContextOnReset = loseContextOnReset;
|
||||
ContextAttribs attribs = new ContextAttribs(this);
|
||||
attribs.contextFlags ^= flag; // toggle bit
|
||||
return attribs;
|
||||
}
|
||||
|
||||
private static ContextAttribsImplementation getImplementation() {
|
||||
switch ( LWJGLUtil.getPlatform() ) {
|
||||
case LWJGLUtil.PLATFORM_LINUX:
|
||||
return new LinuxContextAttribs();
|
||||
case LWJGLUtil.PLATFORM_WINDOWS:
|
||||
return new WindowsContextAttribs();
|
||||
default:
|
||||
throw new IllegalStateException("Unsupported platform");
|
||||
}
|
||||
/** Returns a new {@code ContextAttribs} instance with the {@link #CONTEXT_DEBUG_BIT_ARB} bit in {@link #CONTEXT_FLAGS_ARB} set to the given value. */
|
||||
public ContextAttribs withDebug(boolean debug) { return toggleFlag(CONTEXT_DEBUG_BIT_ARB, debug); }
|
||||
|
||||
/** Returns a new {@code ContextAttribs} instance with the {@link #CONTEXT_FORWARD_COMPATIBLE_BIT_ARB} bit in {@link #CONTEXT_FLAGS_ARB} set to the given value. */
|
||||
public ContextAttribs withForwardCompatible(boolean forwardCompatible) { return toggleFlag(CONTEXT_FORWARD_COMPATIBLE_BIT_ARB, forwardCompatible); }
|
||||
|
||||
/** Returns a new {@code ContextAttribs} instance with the {@link #CONTEXT_ROBUST_ACCESS_BIT_ARB} bit in {@link #CONTEXT_FLAGS_ARB} set to the given value. */
|
||||
public ContextAttribs withRobustAccess(boolean robustAccess) { return toggleFlag(CONTEXT_ROBUST_ACCESS_BIT_ARB, robustAccess); }
|
||||
|
||||
/** Returns a new {@code ContextAttribs} instance with the {@link #CONTEXT_RESET_ISOLATION_BIT_ARB} bit in {@link #CONTEXT_FLAGS_ARB} set to the given value. */
|
||||
public ContextAttribs withContextResetIsolation(boolean contextResetIsolation) { return toggleFlag(CONTEXT_RESET_ISOLATION_BIT_ARB, contextResetIsolation); }
|
||||
|
||||
/**
|
||||
* Returns a ContextAttribs instance with {@link #CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB} set to the given strategy. The default context reset notification
|
||||
* strategy is {@link #NO_RESET_NOTIFICATION_ARB}.
|
||||
*
|
||||
* @param strategy the context reset notification strategy. One of:<br>{@link #NO_RESET_NOTIFICATION_ARB}, {@link #LOSE_CONTEXT_ON_RESET_ARB}
|
||||
*
|
||||
* @return the new ContextAttribs
|
||||
*/
|
||||
public ContextAttribs withResetNotificationStrategy(int strategy) {
|
||||
if ( strategy == contextResetNotificationStrategy )
|
||||
return this;
|
||||
|
||||
if ( LWJGLUtil.CHECKS && !(strategy == NO_RESET_NOTIFICATION_ARB || strategy == LOSE_CONTEXT_ON_RESET_ARB) )
|
||||
throw new IllegalArgumentException("Invalid context reset notification strategy specified: 0x" + LWJGLUtil.toHexString(strategy));
|
||||
|
||||
ContextAttribs attribs = new ContextAttribs(this);
|
||||
attribs.contextResetNotificationStrategy = strategy;
|
||||
return attribs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a ContextAttribs instance with {@link #CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB} set to {@link #LOSE_CONTEXT_ON_RESET_ARB} if the parameter is
|
||||
* true or to {@link #NO_RESET_NOTIFICATION_ARB} if the parameter is false.
|
||||
*
|
||||
* @param loseContextOnReset the context reset notification strategy
|
||||
*
|
||||
* @return the new ContextAttribs
|
||||
*
|
||||
* @deprecated use {@link #withResetNotificationStrategy} instead
|
||||
*/
|
||||
public ContextAttribs withLoseContextOnReset(boolean loseContextOnReset) {
|
||||
return withResetNotificationStrategy(loseContextOnReset ? LOSE_CONTEXT_ON_RESET_ARB : NO_RESET_NOTIFICATION_ARB);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a ContextAttribs instance with {@link #CONTEXT_RELEASE_BEHABIOR_ARB} set to the given behavior. The default context release behavior is
|
||||
* {@link #CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB}.
|
||||
*
|
||||
* @param behavior the context release behavior. One of:<br>{@link #CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB}, {@link #CONTEXT_RELEASE_BEHAVIOR_NONE_ARB}
|
||||
*
|
||||
* @return the new ContextAttribs
|
||||
*/
|
||||
public ContextAttribs withContextReleaseBehavior(int behavior) {
|
||||
if ( behavior == contextReleaseBehavior )
|
||||
return this;
|
||||
|
||||
if ( LWJGLUtil.CHECKS && !(behavior == CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB || behavior == CONTEXT_RELEASE_BEHAVIOR_NONE_ARB) )
|
||||
throw new IllegalArgumentException("Invalid context release behavior specified: 0x" + LWJGLUtil.toHexString(behavior));
|
||||
|
||||
ContextAttribs attribs = new ContextAttribs(this);
|
||||
attribs.contextReleaseBehavior = behavior;
|
||||
return attribs;
|
||||
}
|
||||
|
||||
/** Returns a new {@code ContextAttribs} instance with {@link #CONTEXT_LAYER_PLANE_ARB} set to the given value. */
|
||||
public ContextAttribs withLayer(int layerPlane) {
|
||||
if ( LWJGLUtil.getPlatform() != LWJGLUtil.PLATFORM_WINDOWS )
|
||||
throw new IllegalArgumentException("The CONTEXT_LAYER_PLANE_ARB attribute is supported only on the Windows platform.");
|
||||
|
||||
if ( layerPlane == this.layerPlane )
|
||||
return this;
|
||||
|
||||
if ( layerPlane < 0 )
|
||||
throw new IllegalArgumentException("Invalid layer plane specified: " + layerPlane);
|
||||
|
||||
ContextAttribs attribs = new ContextAttribs(this);
|
||||
attribs.layerPlane = layerPlane;
|
||||
return attribs;
|
||||
}
|
||||
|
||||
IntBuffer getAttribList() {
|
||||
if ( LWJGLUtil.getPlatform() == LWJGLUtil.PLATFORM_MACOSX )
|
||||
return null;
|
||||
|
||||
ContextAttribsImplementation implementation = getImplementation();
|
||||
|
||||
int attribCount = 0;
|
||||
|
||||
if ( !(majorVersion == 1 && minorVersion == 0) )
|
||||
attribCount += 2;
|
||||
if ( 0 < layerPlane )
|
||||
attribCount++;
|
||||
|
||||
int flags = 0;
|
||||
if ( debug )
|
||||
flags |= implementation.getDebugBit();
|
||||
if ( forwardCompatible )
|
||||
flags |= implementation.getForwardCompatibleBit();
|
||||
if ( robustAccess )
|
||||
flags |= CONTEXT_ROBUST_ACCESS_BIT_ARB;
|
||||
if ( 0 < flags )
|
||||
attribCount++;
|
||||
|
||||
int profileMask = 0;
|
||||
if ( profileCore )
|
||||
profileMask |= implementation.getProfileCoreBit();
|
||||
else if ( profileCompatibility )
|
||||
profileMask |= implementation.getProfileCompatibilityBit();
|
||||
else if ( profileES )
|
||||
profileMask |= CONTEXT_ES2_PROFILE_BIT_EXT;
|
||||
if ( 0 < profileMask )
|
||||
attribCount++;
|
||||
|
||||
if ( attribCount == 0 )
|
||||
return null;
|
||||
|
||||
final IntBuffer attribs = BufferUtils.createIntBuffer((attribCount * 2) + 1);
|
||||
LinkedHashMap<Integer, Integer> map = new LinkedHashMap<Integer, Integer>(8);
|
||||
|
||||
if ( !(majorVersion == 1 && minorVersion == 0) ) {
|
||||
attribs.put(implementation.getMajorVersionAttrib()).put(majorVersion);
|
||||
attribs.put(implementation.getMinorVersionAttrib()).put(minorVersion);
|
||||
map.put(CONTEXT_MAJOR_VERSION_ARB, majorVersion);
|
||||
map.put(CONTEXT_MINOR_VERSION_ARB, minorVersion);
|
||||
}
|
||||
if ( 0 < layerPlane )
|
||||
attribs.put(implementation.getLayerPlaneAttrib()).put(layerPlane);
|
||||
if ( 0 < flags )
|
||||
attribs.put(implementation.getFlagsAttrib()).put(flags);
|
||||
if ( 0 < profileMask )
|
||||
attribs.put(implementation.getProfileMaskAttrib()).put(profileMask);
|
||||
if ( loseContextOnReset )
|
||||
attribs.put(CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB).put(LOSE_CONTEXT_ON_RESET_ARB);
|
||||
|
||||
if ( contextFlags != 0 )
|
||||
map.put(CONTEXT_FLAGS_ARB, contextFlags);
|
||||
|
||||
if ( profileMask != 0 )
|
||||
map.put(CONTEXT_PROFILE_MASK_ARB, profileMask);
|
||||
|
||||
if ( contextResetNotificationStrategy != NO_RESET_NOTIFICATION_ARB )
|
||||
map.put(CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, contextResetNotificationStrategy);
|
||||
|
||||
if ( contextReleaseBehavior != CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB )
|
||||
map.put(CONTEXT_RELEASE_BEHABIOR_ARB, contextReleaseBehavior);
|
||||
|
||||
if ( layerPlane != 0 )
|
||||
map.put(CONTEXT_LAYER_PLANE_ARB, layerPlane);
|
||||
|
||||
if ( map.isEmpty() )
|
||||
return null;
|
||||
|
||||
IntBuffer attribs = BufferUtils.createIntBuffer((map.size() * 2) + 1);
|
||||
for ( Entry<Integer, Integer> attrib : map.entrySet() ) {
|
||||
attribs
|
||||
.put(attrib.getKey())
|
||||
.put(attrib.getValue());
|
||||
}
|
||||
attribs.put(0);
|
||||
attribs.rewind();
|
||||
return attribs;
|
||||
|
|
@ -313,19 +438,37 @@ public final class ContextAttribs {
|
|||
|
||||
sb.append("ContextAttribs:");
|
||||
sb.append(" Version=").append(majorVersion).append('.').append(minorVersion);
|
||||
sb.append(" - Layer=").append(layerPlane);
|
||||
sb.append(" - Debug=").append(debug);
|
||||
sb.append(" - ForwardCompatible=").append(forwardCompatible);
|
||||
sb.append(" - RobustAccess=").append(robustAccess);
|
||||
if ( robustAccess )
|
||||
sb.append(" (").append(loseContextOnReset ? "LOSE_CONTEXT_ON_RESET" : "NO_RESET_NOTIFICATION");
|
||||
sb.append(" - Profile=");
|
||||
if ( profileCore )
|
||||
sb.append("Core");
|
||||
else if ( profileCompatibility )
|
||||
sb.append("Compatibility");
|
||||
else
|
||||
sb.append("None");
|
||||
|
||||
if ( profileMask != 0 ) {
|
||||
sb.append(", Profile=");
|
||||
if ( hasMask(CONTEXT_CORE_PROFILE_BIT_ARB) )
|
||||
sb.append("CORE");
|
||||
else if ( hasMask(CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB) )
|
||||
sb.append("COMPATIBLITY");
|
||||
else if ( hasMask(CONTEXT_ES2_PROFILE_BIT_EXT) )
|
||||
sb.append("ES2");
|
||||
else
|
||||
sb.append("*unknown*");
|
||||
}
|
||||
|
||||
if ( contextFlags != 0 ) {
|
||||
if ( hasFlag(CONTEXT_DEBUG_BIT_ARB) )
|
||||
sb.append(", DEBUG");
|
||||
if ( hasFlag(CONTEXT_FORWARD_COMPATIBLE_BIT_ARB) )
|
||||
sb.append(", FORWARD_COMPATIBLE");
|
||||
if ( hasFlag(CONTEXT_ROBUST_ACCESS_BIT_ARB) )
|
||||
sb.append(", ROBUST_ACCESS");
|
||||
if ( hasFlag(CONTEXT_RESET_ISOLATION_BIT_ARB) )
|
||||
sb.append(", RESET_ISOLATION");
|
||||
}
|
||||
|
||||
if ( contextResetNotificationStrategy != NO_RESET_NOTIFICATION_ARB )
|
||||
sb.append(", LOSE_CONTEXT_ON_RESET");
|
||||
if ( contextReleaseBehavior != CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB )
|
||||
sb.append(", RELEASE_BEHAVIOR_NONE");
|
||||
|
||||
if ( layerPlane != 0 )
|
||||
sb.append(", Layer=").append(layerPlane);
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -253,8 +253,12 @@ final class ContextGL implements Context {
|
|||
boolean was_current = isCurrent();
|
||||
int error = GL_NO_ERROR;
|
||||
if ( was_current ) {
|
||||
if ( GLContext.getCapabilities() != null && GLContext.getCapabilities().OpenGL11 )
|
||||
try {
|
||||
// May fail on GLContext.getCapabilities()
|
||||
error = glGetError();
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
releaseCurrent();
|
||||
}
|
||||
checkDestroy();
|
||||
|
|
|
|||
|
|
@ -43,7 +43,10 @@ package org.lwjgl.opengl;
|
|||
* @author foo
|
||||
*/
|
||||
|
||||
import org.lwjgl.*;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.LWJGLException;
|
||||
import org.lwjgl.LWJGLUtil;
|
||||
import org.lwjgl.Sys;
|
||||
import org.lwjgl.input.Controllers;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
|
@ -52,6 +55,7 @@ import java.awt.*;
|
|||
import java.awt.event.ComponentAdapter;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.ComponentListener;
|
||||
import java.nio.Buffer;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.security.AccessController;
|
||||
|
|
@ -79,9 +83,6 @@ public final class Display {
|
|||
/** The current display mode, if created */
|
||||
private static DisplayMode current_mode;
|
||||
|
||||
/** Timer for sync() */
|
||||
private static long timeThen;
|
||||
|
||||
/** X coordinate of the window */
|
||||
private static int x = -1;
|
||||
|
||||
|
|
@ -239,21 +240,21 @@ public final class Display {
|
|||
throw new NullPointerException("mode must be non-null");
|
||||
boolean was_fullscreen = isFullscreen();
|
||||
current_mode = mode;
|
||||
if ( isCreated() ) {
|
||||
destroyWindow();
|
||||
// If mode is not fullscreen capable, make sure we are in windowed mode
|
||||
try {
|
||||
if ( was_fullscreen && !isFullscreen() )
|
||||
display_impl.resetDisplayMode();
|
||||
else if ( isFullscreen() )
|
||||
switchDisplayMode();
|
||||
createWindow();
|
||||
makeCurrentAndSetSwapInterval();
|
||||
} catch (LWJGLException e) {
|
||||
drawable.destroy();
|
||||
if ( !isCreated() || parent != null )
|
||||
return;
|
||||
destroyWindow();
|
||||
// If mode is not fullscreen capable, make sure we are in windowed mode
|
||||
try {
|
||||
if ( was_fullscreen && !isFullscreen() )
|
||||
display_impl.resetDisplayMode();
|
||||
throw e;
|
||||
}
|
||||
else if ( isFullscreen() )
|
||||
switchDisplayMode();
|
||||
createWindow();
|
||||
makeCurrentAndSetSwapInterval();
|
||||
} catch (LWJGLException e) {
|
||||
drawable.destroy();
|
||||
display_impl.resetDisplayMode();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -401,40 +402,14 @@ public final class Display {
|
|||
}
|
||||
}
|
||||
|
||||
private static long timeLate;
|
||||
|
||||
/**
|
||||
* Best sync method that works reliably.
|
||||
* An accurate sync method that will attempt to run at a constant frame rate.
|
||||
* It should be called once every frame.
|
||||
*
|
||||
* @param fps The desired frame rate, in frames per second
|
||||
* @param fps - the desired frame rate, in frames per second
|
||||
*/
|
||||
public static void sync(int fps) {
|
||||
long timeNow;
|
||||
long gapTo;
|
||||
long savedTimeLate;
|
||||
synchronized ( GlobalLock.lock ) {
|
||||
gapTo = Sys.getTimerResolution() / fps + timeThen;
|
||||
timeNow = Sys.getTime();
|
||||
savedTimeLate = timeLate;
|
||||
}
|
||||
|
||||
try {
|
||||
while ( gapTo > timeNow + savedTimeLate ) {
|
||||
Thread.sleep(1);
|
||||
timeNow = Sys.getTime();
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
|
||||
synchronized ( GlobalLock.lock ) {
|
||||
if ( gapTo < timeNow )
|
||||
timeLate = timeNow - gapTo;
|
||||
else
|
||||
timeLate = 0;
|
||||
|
||||
timeThen = timeNow;
|
||||
}
|
||||
Sync.sync(fps);
|
||||
}
|
||||
|
||||
/** @return the title of the window */
|
||||
|
|
@ -685,6 +660,7 @@ public final class Display {
|
|||
if ( parent_resized ) {
|
||||
reshape();
|
||||
parent_resized = false;
|
||||
window_resized = true;
|
||||
}
|
||||
|
||||
if ( processMessages )
|
||||
|
|
@ -1073,6 +1049,15 @@ public final class Display {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** Gets a string property as a privileged action. */
|
||||
static String getPrivilegedString(final String property_name) {
|
||||
return AccessController.doPrivileged(new PrivilegedAction<String>() {
|
||||
public String run() {
|
||||
return System.getProperty(property_name);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void initControls() {
|
||||
// Automatically create mouse, keyboard and controller
|
||||
|
|
@ -1107,7 +1092,9 @@ public final class Display {
|
|||
* regardless of whether the Display was the current rendering context.
|
||||
*/
|
||||
public static void destroy() {
|
||||
drawable.destroy();
|
||||
if(isCreated()) {
|
||||
drawable.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -1216,7 +1203,7 @@ public final class Display {
|
|||
* <li>Linux (and similar platforms) expect one 32x32 icon.</li>
|
||||
* <li>Mac OS X should be supplied one 128x128 icon</li>
|
||||
* </ul>
|
||||
* The implementation will use the supplied ByteBuffers with image data in RGBA and perform any conversions nescesarry for the specific platform.
|
||||
* The implementation will use the supplied ByteBuffers with image data in RGBA (size must be a power of two) and perform any conversions nescesarry for the specific platform.
|
||||
* <p/>
|
||||
* <b>NOTE:</b> The display will make a deep copy of the supplied byte buffer array, for the purpose
|
||||
* of recreating the icons when you go back and forth fullscreen mode. You therefore only need to
|
||||
|
|
@ -1236,8 +1223,8 @@ public final class Display {
|
|||
cached_icons[i] = BufferUtils.createByteBuffer(icons[i].capacity());
|
||||
int old_position = icons[i].position();
|
||||
cached_icons[i].put(icons[i]);
|
||||
icons[i].position(old_position);
|
||||
cached_icons[i].flip();
|
||||
((Buffer)icons[i]).position(old_position);
|
||||
((Buffer)cached_icons[i]).flip();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1279,11 +1266,51 @@ public final class Display {
|
|||
return window_resized;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return this method will return the x position (top-left) of the Display window.
|
||||
*
|
||||
* If running in fullscreen mode it will return 0.
|
||||
* If Display.setParent(Canvas parent) is being used, the x position of
|
||||
* the parent will be returned.
|
||||
*/
|
||||
public static int getX() {
|
||||
|
||||
if (Display.isFullscreen()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (parent != null) {
|
||||
return parent.getX();
|
||||
}
|
||||
|
||||
return display_impl.getX();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return this method will return the y position (top-left) of the Display window.
|
||||
*
|
||||
* If running in fullscreen mode it will return 0.
|
||||
* If Display.setParent(Canvas parent) is being used, the y position of
|
||||
* the parent will be returned.
|
||||
*/
|
||||
public static int getY() {
|
||||
|
||||
if (Display.isFullscreen()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (parent != null) {
|
||||
return parent.getY();
|
||||
}
|
||||
|
||||
return display_impl.getY();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return this method will return the width of the Display window.
|
||||
*
|
||||
* If running in fullscreen mode it will return the width of the current set DisplayMode.
|
||||
* If running Display.setParent(Canvas parent) is being used, the width of the parent
|
||||
* If Display.setParent(Canvas parent) is being used, the width of the parent
|
||||
* will be returned.
|
||||
*
|
||||
* This value will be updated after a call to Display.update().
|
||||
|
|
@ -1305,7 +1332,7 @@ public final class Display {
|
|||
* @return this method will return the height of the Display window.
|
||||
*
|
||||
* If running in fullscreen mode it will return the height of the current set DisplayMode.
|
||||
* If running Display.setParent(Canvas parent) is being used, the height of the parent
|
||||
* If Display.setParent(Canvas parent) is being used, the height of the parent
|
||||
* will be returned.
|
||||
*
|
||||
* This value will be updated after a call to Display.update().
|
||||
|
|
@ -1322,4 +1349,28 @@ public final class Display {
|
|||
|
||||
return height;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return this method will return the pixel scale factor of the Display window.
|
||||
*
|
||||
* This method should be used when running in high DPI mode. In such modes Operating
|
||||
* Systems will scale the Display window to avoid the window shrinking due to high
|
||||
* resolutions. The OpenGL frame buffer will however use the higher resolution and
|
||||
* not be scaled to match the Display window size.
|
||||
*
|
||||
* OpenGL methods that require pixel dependent values e.g. glViewport, glTexImage2D,
|
||||
* glReadPixels, glScissor, glLineWidth, glRenderbufferStorage, etc can convert the
|
||||
* scaled Display and Mouse coordinates to the correct high resolution value by
|
||||
* multiplying them by the pixel scale factor.
|
||||
*
|
||||
* e.g. Display.getWidth() * Display.getPixelScaleFactor() will return the high DPI
|
||||
* width of the OpenGL frame buffer. Whereas Display.getWidth() will be the same as
|
||||
* the OpenGL frame buffer in non high DPI mode.
|
||||
*
|
||||
* Where high DPI mode is not available this method will just return 1.0f therefore
|
||||
* not have any effect on values that are multiplied by it.
|
||||
*/
|
||||
public static float getPixelScaleFactor() {
|
||||
return display_impl.getPixelScaleFactor();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -174,12 +174,27 @@ interface DisplayImplementation extends InputImplementation {
|
|||
boolean wasResized();
|
||||
|
||||
/**
|
||||
* @return this method will return a the width of the Display window.
|
||||
* @return this method will return the width of the Display window.
|
||||
*/
|
||||
int getWidth();
|
||||
|
||||
/**
|
||||
* @return this method will return a the height of the Display window.
|
||||
* @return this method will return the height of the Display window.
|
||||
*/
|
||||
int getHeight();
|
||||
|
||||
/**
|
||||
* @return this method will return the top-left x position of the Display window.
|
||||
*/
|
||||
int getX();
|
||||
|
||||
/**
|
||||
* @return this method will return the top-left y position of the Display window.
|
||||
*/
|
||||
int getY();
|
||||
|
||||
/**
|
||||
* @return this method will return the pixel scale factor of the Display window useful for high resolution modes.
|
||||
*/
|
||||
float getPixelScaleFactor();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ public final class DisplayMode {
|
|||
this.fullscreen = fullscreen;
|
||||
}
|
||||
|
||||
/** True iff this instance can be used for fullscreen modes */
|
||||
/** True if this instance can be used for fullscreen modes */
|
||||
public boolean isFullscreenCapable() {
|
||||
return fullscreen;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ package org.lwjgl.opengl;
|
|||
* @author elias_naur
|
||||
*/
|
||||
|
||||
import java.nio.Buffer;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
class EventQueue {
|
||||
|
|
@ -58,12 +59,12 @@ class EventQueue {
|
|||
* Copy available events into the specified buffer.
|
||||
*/
|
||||
public synchronized void copyEvents(ByteBuffer dest) {
|
||||
queue.flip();
|
||||
((Buffer)queue).flip();
|
||||
int old_limit = queue.limit();
|
||||
if (dest.remaining() < queue.remaining())
|
||||
queue.limit(dest.remaining() + queue.position());
|
||||
((Buffer)queue).limit(dest.remaining() + queue.position());
|
||||
dest.put(queue);
|
||||
queue.limit(old_limit);
|
||||
((Buffer)queue).limit(old_limit);
|
||||
queue.compact();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ import static org.lwjgl.opengl.EXTAbgr.*;
|
|||
import static org.lwjgl.opengl.EXTBgra.*;
|
||||
import static org.lwjgl.opengl.EXTDirectStateAccess.*;
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
import static org.lwjgl.opengl.GL13.*;
|
||||
import static org.lwjgl.opengl.GL15.*;
|
||||
import static org.lwjgl.opengl.NVPathRendering.*;
|
||||
|
||||
|
|
@ -65,22 +66,6 @@ class GLChecks {
|
|||
private GLChecks() {
|
||||
}
|
||||
|
||||
static int getBufferObjectSize(ContextCapabilities caps, int buffer_enum) {
|
||||
return glGetBufferParameter(buffer_enum, GL_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
static int getBufferObjectSizeARB(ContextCapabilities caps, int buffer_enum) {
|
||||
return glGetBufferParameterARB(buffer_enum, GL_BUFFER_SIZE_ARB);
|
||||
}
|
||||
|
||||
static int getBufferObjectSizeATI(ContextCapabilities caps, int buffer) {
|
||||
return glGetObjectBufferATI(buffer, GL_OBJECT_BUFFER_SIZE_ATI);
|
||||
}
|
||||
|
||||
static int getNamedBufferObjectSize(ContextCapabilities caps, int buffer) {
|
||||
return glGetNamedBufferParameterEXT(buffer, GL_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
/** Helper method to ensure that array buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */
|
||||
static void ensureArrayVBOdisabled(ContextCapabilities caps) {
|
||||
if ( LWJGLUtil.CHECKS && StateTracker.getReferences(caps).arrayBuffer != 0 )
|
||||
|
|
@ -310,37 +295,36 @@ class GLChecks {
|
|||
}
|
||||
}
|
||||
|
||||
static int calculatePathColorGenCoeffsCount(int genMode, int colorFormat) {
|
||||
final int coeffsPerComponent = calculatePathGenCoeffsPerComponent(genMode);
|
||||
|
||||
switch ( colorFormat ) {
|
||||
case GL_RGB:
|
||||
return 3 * coeffsPerComponent;
|
||||
case GL_RGBA:
|
||||
return 4 * coeffsPerComponent;
|
||||
default:
|
||||
return coeffsPerComponent;
|
||||
}
|
||||
}
|
||||
|
||||
static int calculatePathTextGenCoeffsPerComponent(FloatBuffer coeffs, int genMode) {
|
||||
if ( genMode == GL_NONE )
|
||||
return 0;
|
||||
|
||||
return coeffs.remaining() / calculatePathGenCoeffsPerComponent(genMode);
|
||||
}
|
||||
|
||||
private static int calculatePathGenCoeffsPerComponent(int genMode) {
|
||||
static int calculatePathColorGenModeElements(int genMode) {
|
||||
switch ( genMode ) {
|
||||
case GL_NONE:
|
||||
return 0;
|
||||
case GL_CONSTANT:
|
||||
return 1;
|
||||
case GL_OBJECT_LINEAR:
|
||||
case GL_PATH_OBJECT_BOUNDING_BOX_NV:
|
||||
return 3;
|
||||
case GL_EYE_LINEAR:
|
||||
return 4;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unsupported gen mode: " + genMode);
|
||||
throw new IllegalArgumentException(String.format("Unsupported genMode specified: 0x%X", genMode));
|
||||
}
|
||||
}
|
||||
|
||||
static int calculatePathColorGenFormatComponents(int colorFormat) {
|
||||
switch ( colorFormat ) {
|
||||
case GL_LUMINANCE:
|
||||
case GL_INTENSITY:
|
||||
case GL_ALPHA:
|
||||
return 1;
|
||||
case GL_LUMINANCE_ALPHA:
|
||||
return 2;
|
||||
case GL_RGB:
|
||||
return 3;
|
||||
case GL_RGBA:
|
||||
return 4;
|
||||
default:
|
||||
throw new IllegalArgumentException(String.format("Unsupported colorFormat specified: 0x%X", colorFormat));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -119,6 +119,14 @@ public final class GLContext {
|
|||
* @return The current capabilities instance.
|
||||
*/
|
||||
public static ContextCapabilities getCapabilities() {
|
||||
ContextCapabilities caps = getCapabilitiesImpl();
|
||||
if ( caps == null )
|
||||
throw new RuntimeException("No OpenGL context found in the current thread.");
|
||||
|
||||
return caps;
|
||||
}
|
||||
|
||||
private static ContextCapabilities getCapabilitiesImpl() {
|
||||
CapabilitiesCacheEntry recent_cache_entry = fast_path_cache;
|
||||
// Check owner of cache entry
|
||||
if ( recent_cache_entry.owner == Thread.currentThread() ) {
|
||||
|
|
@ -130,6 +138,17 @@ public final class GLContext {
|
|||
return getThreadLocalCapabilities();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the capabilities instance associated with the specified context object.
|
||||
*
|
||||
* @param context the context object
|
||||
*
|
||||
* @return the capabilities instance
|
||||
*/
|
||||
static ContextCapabilities getCapabilities(Object context) {
|
||||
return capability_cache.get(context);
|
||||
}
|
||||
|
||||
private static ContextCapabilities getThreadLocalCapabilities() {
|
||||
return current_capabilities.get();
|
||||
}
|
||||
|
|
@ -224,10 +243,10 @@ public final class GLContext {
|
|||
}
|
||||
|
||||
final int[][] GL_VERSIONS = {
|
||||
{ 1, 2, 3, 4, 5 }, // OpenGL 1
|
||||
{ 0, 1 }, // OpenGL 2
|
||||
{ 0, 1, 2, 3 }, // OpenGL 3
|
||||
{ 0, 1, 2 }, // OpenGL 4
|
||||
{ 1, 2, 3, 4, 5 }, // OpenGL 1
|
||||
{ 0, 1 }, // OpenGL 2
|
||||
{ 0, 1, 2, 3 }, // OpenGL 3
|
||||
{ 0, 1, 2, 3, 4, 5 }, // OpenGL 4
|
||||
};
|
||||
|
||||
for ( int major = 1; major <= GL_VERSIONS.length; major++ ) {
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ public interface InputImplementation {
|
|||
void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons);
|
||||
|
||||
/**
|
||||
* Method to read the keyboard buffer
|
||||
* Method to read the mouse buffer
|
||||
*/
|
||||
void readMouse(ByteBuffer buffer);
|
||||
|
||||
|
|
|
|||
209
src/java/org/lwjgl/opengl/KHRDebugCallback.java
Normal file
209
src/java/org/lwjgl/opengl/KHRDebugCallback.java
Normal file
|
|
@ -0,0 +1,209 @@
|
|||
/*
|
||||
* Copyright (c) 2002-2008 LWJGL Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of 'LWJGL' nor the names of
|
||||
* its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.lwjgl.opengl;
|
||||
|
||||
import org.lwjgl.PointerWrapperAbstract;
|
||||
|
||||
/**
|
||||
* Instances of this class are needed to use the callback functionality of the KHR_debug extension.
|
||||
* Users of this class may provide implementations of the {@code Handler} interface to receive notifications.
|
||||
* The same {@code Handler} instance may be used by different contexts but it is not recommended.
|
||||
* Handler notifications are synchronized.
|
||||
*
|
||||
* @author Spasi
|
||||
*/
|
||||
public final class KHRDebugCallback extends PointerWrapperAbstract {
|
||||
|
||||
/** Severity levels. */
|
||||
private static final int
|
||||
GL_DEBUG_SEVERITY_HIGH = 0x9146,
|
||||
GL_DEBUG_SEVERITY_MEDIUM = 0x9147,
|
||||
GL_DEBUG_SEVERITY_LOW = 0x9148,
|
||||
GL_DEBUG_SEVERITY_NOTIFICATION = 0x826B;
|
||||
|
||||
/** Sources. */
|
||||
private static final int
|
||||
GL_DEBUG_SOURCE_API = 0x8246,
|
||||
GL_DEBUG_SOURCE_WINDOW_SYSTEM = 0x8247,
|
||||
GL_DEBUG_SOURCE_SHADER_COMPILER = 0x8248,
|
||||
GL_DEBUG_SOURCE_THIRD_PARTY = 0x8249,
|
||||
GL_DEBUG_SOURCE_APPLICATION = 0x824A,
|
||||
GL_DEBUG_SOURCE_OTHER = 0x824B;
|
||||
|
||||
/** Types. */
|
||||
private static final int
|
||||
GL_DEBUG_TYPE_ERROR = 0x824C,
|
||||
GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR = 0x824D,
|
||||
GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR = 0x824E,
|
||||
GL_DEBUG_TYPE_PORTABILITY = 0x824F,
|
||||
GL_DEBUG_TYPE_PERFORMANCE = 0x8250,
|
||||
GL_DEBUG_TYPE_OTHER = 0x8251,
|
||||
GL_DEBUG_TYPE_MARKER = 0x8268;
|
||||
|
||||
private static final long CALLBACK_POINTER;
|
||||
|
||||
static {
|
||||
long pointer = 0;
|
||||
try {
|
||||
// Call reflectively so that we can compile this class for the Generator.
|
||||
pointer = (Long)Class.forName("org.lwjgl.opengl.CallbackUtil").getDeclaredMethod("getDebugCallbackKHR").invoke(null);
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
CALLBACK_POINTER = pointer;
|
||||
}
|
||||
|
||||
private final Handler handler;
|
||||
|
||||
/**
|
||||
* Creates an KHRebugCallback with a default callback handler.
|
||||
* The default handler will simply print the message on System.err.
|
||||
*/
|
||||
public KHRDebugCallback() {
|
||||
this(new Handler() {
|
||||
public void handleMessage(final int source, final int type, final int id, final int severity, final String message) {
|
||||
System.err.println("[LWJGL] KHR_debug message");
|
||||
System.err.println("\tID: " + id);
|
||||
|
||||
String description;
|
||||
switch ( source ) {
|
||||
case GL_DEBUG_SOURCE_API:
|
||||
description = "API";
|
||||
break;
|
||||
case GL_DEBUG_SOURCE_WINDOW_SYSTEM:
|
||||
description = "WINDOW SYSTEM";
|
||||
break;
|
||||
case GL_DEBUG_SOURCE_SHADER_COMPILER:
|
||||
description = "SHADER COMPILER";
|
||||
break;
|
||||
case GL_DEBUG_SOURCE_THIRD_PARTY:
|
||||
description = "THIRD PARTY";
|
||||
break;
|
||||
case GL_DEBUG_SOURCE_APPLICATION:
|
||||
description = "APPLICATION";
|
||||
break;
|
||||
case GL_DEBUG_SOURCE_OTHER:
|
||||
description = "OTHER";
|
||||
break;
|
||||
default:
|
||||
description = printUnknownToken(source);
|
||||
}
|
||||
System.err.println("\tSource: " + description);
|
||||
|
||||
switch ( type ) {
|
||||
case GL_DEBUG_TYPE_ERROR:
|
||||
description = "ERROR";
|
||||
break;
|
||||
case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR:
|
||||
description = "DEPRECATED BEHAVIOR";
|
||||
break;
|
||||
case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR:
|
||||
description = "UNDEFINED BEHAVIOR";
|
||||
break;
|
||||
case GL_DEBUG_TYPE_PORTABILITY:
|
||||
description = "PORTABILITY";
|
||||
break;
|
||||
case GL_DEBUG_TYPE_PERFORMANCE:
|
||||
description = "PERFORMANCE";
|
||||
break;
|
||||
case GL_DEBUG_TYPE_OTHER:
|
||||
description = "OTHER";
|
||||
break;
|
||||
case GL_DEBUG_TYPE_MARKER:
|
||||
description = "MARKER";
|
||||
break;
|
||||
default:
|
||||
description = printUnknownToken(type);
|
||||
}
|
||||
System.err.println("\tType: " + description);
|
||||
|
||||
switch ( severity ) {
|
||||
case GL_DEBUG_SEVERITY_HIGH:
|
||||
description = "HIGH";
|
||||
break;
|
||||
case GL_DEBUG_SEVERITY_MEDIUM:
|
||||
description = "MEDIUM";
|
||||
break;
|
||||
case GL_DEBUG_SEVERITY_LOW:
|
||||
description = "LOW";
|
||||
break;
|
||||
case GL_DEBUG_SEVERITY_NOTIFICATION:
|
||||
description = "NOTIFICATION";
|
||||
break;
|
||||
default:
|
||||
description = printUnknownToken(severity);
|
||||
}
|
||||
System.err.println("\tSeverity: " + description);
|
||||
|
||||
System.err.println("\tMessage: " + message);
|
||||
}
|
||||
|
||||
private String printUnknownToken(final int token) {
|
||||
return "Unknown (0x" + Integer.toHexString(token).toUpperCase() + ")";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an ARBDebugOutputCallback with the specified callback handler.
|
||||
* The handler's {@code handleMessage} method will be called whenever
|
||||
* debug output is generated by the GL.
|
||||
*
|
||||
* @param handler the callback handler
|
||||
*/
|
||||
public KHRDebugCallback(final Handler handler) {
|
||||
super(CALLBACK_POINTER);
|
||||
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
Handler getHandler() {
|
||||
return handler;
|
||||
}
|
||||
|
||||
/** Implementations of this interface can be used to receive ARB_debug_output notifications. */
|
||||
public interface Handler {
|
||||
|
||||
/**
|
||||
* This method will be called when an ARB_debug_output message is generated.
|
||||
*
|
||||
* @param source the message source
|
||||
* @param type the message type
|
||||
* @param id the message ID
|
||||
* @param severity the message severity
|
||||
* @param message the string representation of the message.
|
||||
*/
|
||||
void handleMessage(int source, int type, int id, int severity, String message);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -143,16 +143,31 @@ final class LinuxContextImplementation implements ContextImplementation {
|
|||
|
||||
public void setSwapInterval(int value) {
|
||||
ContextGL current_context = ContextGL.getCurrentContext();
|
||||
|
||||
if ( current_context == null )
|
||||
throw new IllegalStateException("No context is current");
|
||||
|
||||
PeerInfo peer_info = current_context.getPeerInfo();
|
||||
|
||||
synchronized ( current_context ) {
|
||||
LinuxDisplay.lockAWT();
|
||||
nSetSwapInterval(current_context.getHandle(), value);
|
||||
LinuxDisplay.unlockAWT();
|
||||
try {
|
||||
ByteBuffer peer_handle = peer_info.lockAndGetHandle();
|
||||
try {
|
||||
nSetSwapInterval(peer_handle, current_context.getHandle(), value);
|
||||
} finally {
|
||||
peer_info.unlock();
|
||||
}
|
||||
} catch (LWJGLException e) {
|
||||
// API CHANGE - this methods should throw LWJGLException
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
LinuxDisplay.unlockAWT();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static native void nSetSwapInterval(ByteBuffer context_handle, int value);
|
||||
private static native void nSetSwapInterval(ByteBuffer peer_handle, ByteBuffer context_handle, int value);
|
||||
|
||||
public void destroy(PeerInfo peer_info, ByteBuffer handle) throws LWJGLException {
|
||||
LinuxDisplay.lockAWT();
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ import java.awt.event.FocusEvent;
|
|||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
|
|
@ -128,7 +129,6 @@ final class LinuxDisplay implements DisplayImplementation {
|
|||
private DisplayMode saved_mode;
|
||||
private DisplayMode current_mode;
|
||||
|
||||
private Screen[] savedXrandrConfig;
|
||||
|
||||
private boolean keyboard_grabbed;
|
||||
private boolean pointer_grabbed;
|
||||
|
|
@ -144,6 +144,8 @@ final class LinuxDisplay implements DisplayImplementation {
|
|||
private boolean resizable;
|
||||
private boolean resized;
|
||||
|
||||
private int window_x;
|
||||
private int window_y;
|
||||
private int window_width;
|
||||
private int window_height;
|
||||
|
||||
|
|
@ -152,20 +154,25 @@ final class LinuxDisplay implements DisplayImplementation {
|
|||
private static boolean xembedded;
|
||||
private long parent_proxy_focus_window;
|
||||
private boolean parent_focused;
|
||||
private boolean parent_focus_changed;
|
||||
private long last_window_focus = 0;
|
||||
|
||||
private LinuxKeyboard keyboard;
|
||||
private LinuxMouse mouse;
|
||||
|
||||
private String wm_class;
|
||||
|
||||
private final FocusListener focus_listener = new FocusListener() {
|
||||
public void focusGained(FocusEvent e) {
|
||||
synchronized (GlobalLock.lock) {
|
||||
parent_focused = true;
|
||||
parent_focus_changed = true;
|
||||
}
|
||||
}
|
||||
public void focusLost(FocusEvent e) {
|
||||
synchronized (GlobalLock.lock) {
|
||||
parent_focused = false;
|
||||
parent_focus_changed = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -455,22 +462,43 @@ final class LinuxDisplay implements DisplayImplementation {
|
|||
ByteBuffer handle = peer_info.lockAndGetHandle();
|
||||
try {
|
||||
current_window_mode = getWindowMode(Display.isFullscreen());
|
||||
|
||||
// Try to enable Lecagy FullScreen Support in Compiz, else
|
||||
// we may have trouble with stuff overlapping our fullscreen window.
|
||||
if ( current_window_mode != WINDOWED )
|
||||
Compiz.setLegacyFullscreenSupport(true);
|
||||
|
||||
// Setting _MOTIF_WM_HINTS in fullscreen mode is problematic for certain window
|
||||
// managers. We do not set MWM_HINTS_DECORATIONS in fullscreen mode anymore,
|
||||
// unless org.lwjgl.opengl.Window.undecorated_fs has been specified.
|
||||
// See native/linux/org_lwjgl_opengl_Display.c, createWindow function.
|
||||
boolean undecorated = Display.getPrivilegedBoolean("org.lwjgl.opengl.Window.undecorated") || (current_window_mode != WINDOWED && Display.getPrivilegedBoolean("org.lwjgl.opengl.Window.undecorated_fs"));
|
||||
|
||||
this.parent = parent;
|
||||
parent_window = parent != null ? getHandle(parent) : getRootWindow(getDisplay(), getDefaultScreen());
|
||||
resizable = Display.isResizable();
|
||||
resized = false;
|
||||
window_x = x;
|
||||
window_y = y;
|
||||
window_width = mode.getWidth();
|
||||
window_height = mode.getHeight();
|
||||
|
||||
// overwrite arguments x and y - superclass always uses 0,0 for fullscreen windows
|
||||
// use the coordinates of XRandRs primary screen instead
|
||||
// this is required to let the fullscreen window appear on the primary screen
|
||||
if (mode.isFullscreenCapable() && current_displaymode_extension == XRANDR) {
|
||||
Screen primaryScreen = XRandR.DisplayModetoScreen(Display.getDisplayMode());
|
||||
x = primaryScreen.xPos;
|
||||
y = primaryScreen.yPos;
|
||||
}
|
||||
|
||||
current_window = nCreateWindow(getDisplay(), getDefaultScreen(), handle, mode, current_window_mode, x, y, undecorated, parent_window, resizable);
|
||||
|
||||
// Set the WM_CLASS hint which is needed by some WM's e.g. Gnome Shell
|
||||
wm_class = Display.getPrivilegedString("LWJGL_WM_CLASS");
|
||||
if (wm_class == null) wm_class = Display.getTitle();
|
||||
setClassHint(Display.getTitle(), wm_class);
|
||||
|
||||
mapRaised(getDisplay(), current_window);
|
||||
xembedded = parent != null && isAncestorXEmbedded(parent_window);
|
||||
blank_cursor = createBlankCursor();
|
||||
|
|
@ -489,9 +517,8 @@ final class LinuxDisplay implements DisplayImplementation {
|
|||
|
||||
if (parent != null) {
|
||||
parent.addFocusListener(focus_listener);
|
||||
if (parent.isFocusOwner()) {
|
||||
parent_focused = true;
|
||||
}
|
||||
parent_focused = parent.isFocusOwner();
|
||||
parent_focus_changed = true;
|
||||
}
|
||||
} finally {
|
||||
peer_info.unlock();
|
||||
|
|
@ -514,6 +541,8 @@ final class LinuxDisplay implements DisplayImplementation {
|
|||
private static native long nGetInputFocus(long display) throws LWJGLException;
|
||||
private static native void nSetInputFocus(long display, long window, long time);
|
||||
private static native void nSetWindowSize(long display, long window, int width, int height, boolean resizable);
|
||||
private static native int nGetX(long display, long window);
|
||||
private static native int nGetY(long display, long window);
|
||||
private static native int nGetWidth(long display, long window);
|
||||
private static native int nGetHeight(long display, long window);
|
||||
|
||||
|
|
@ -549,6 +578,9 @@ final class LinuxDisplay implements DisplayImplementation {
|
|||
public void destroyWindow() {
|
||||
lockAWT();
|
||||
try {
|
||||
if (parent != null) {
|
||||
parent.removeFocusListener(focus_listener);
|
||||
}
|
||||
try {
|
||||
setNativeCursor(null);
|
||||
} catch (LWJGLException e) {
|
||||
|
|
@ -579,12 +611,17 @@ final class LinuxDisplay implements DisplayImplementation {
|
|||
}
|
||||
|
||||
private void switchDisplayModeOnTmpDisplay(DisplayMode mode) throws LWJGLException {
|
||||
incDisplay();
|
||||
try {
|
||||
nSwitchDisplayMode(getDisplay(), getDefaultScreen(), current_displaymode_extension, mode);
|
||||
} finally {
|
||||
decDisplay();
|
||||
}
|
||||
if (current_displaymode_extension == XRANDR) {
|
||||
// let Xrandr set the display mode
|
||||
XRandR.setConfiguration(false, XRandR.DisplayModetoScreen(mode));
|
||||
} else {
|
||||
incDisplay();
|
||||
try {
|
||||
nSwitchDisplayMode(getDisplay(), getDefaultScreen(), current_displaymode_extension, mode);
|
||||
} finally {
|
||||
decDisplay();
|
||||
}
|
||||
}
|
||||
}
|
||||
private static native void nSwitchDisplayMode(long display, int screen, int extension, DisplayMode mode) throws LWJGLException;
|
||||
|
||||
|
|
@ -601,11 +638,11 @@ final class LinuxDisplay implements DisplayImplementation {
|
|||
public void resetDisplayMode() {
|
||||
lockAWT();
|
||||
try {
|
||||
if( current_displaymode_extension == XRANDR && savedXrandrConfig.length > 0 )
|
||||
if( current_displaymode_extension == XRANDR )
|
||||
{
|
||||
AccessController.doPrivileged(new PrivilegedAction<Object>() {
|
||||
public Object run() {
|
||||
XRandR.setConfiguration( savedXrandrConfig );
|
||||
XRandR.restoreConfiguration();
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
|
@ -703,12 +740,11 @@ final class LinuxDisplay implements DisplayImplementation {
|
|||
throw new LWJGLException("No modes available");
|
||||
switch (current_displaymode_extension) {
|
||||
case XRANDR:
|
||||
savedXrandrConfig = AccessController.doPrivileged(new PrivilegedAction<Screen[]>() {
|
||||
public Screen[] run() {
|
||||
return XRandR.getConfiguration();
|
||||
saved_mode = AccessController.doPrivileged(new PrivilegedAction<DisplayMode>() {
|
||||
public DisplayMode run() {
|
||||
return XRandR.ScreentoDisplayMode(XRandR.getConfiguration());
|
||||
}
|
||||
});
|
||||
saved_mode = getCurrentXRandrMode();
|
||||
break;
|
||||
case XF86VIDMODE:
|
||||
saved_mode = modes[0];
|
||||
|
|
@ -752,6 +788,20 @@ final class LinuxDisplay implements DisplayImplementation {
|
|||
}
|
||||
}
|
||||
private static native void nSetTitle(long display, long window, long title, int len);
|
||||
|
||||
/** the WM_CLASS hint is needed by some WM's e.g. gnome shell */
|
||||
private void setClassHint(String wm_name, String wm_class) {
|
||||
lockAWT();
|
||||
try {
|
||||
final ByteBuffer nameText = MemoryUtil.encodeUTF8(wm_name);
|
||||
final ByteBuffer classText = MemoryUtil.encodeUTF8(wm_class);
|
||||
|
||||
nSetClassHint(getDisplay(), getWindow(), MemoryUtil.getAddress(nameText), MemoryUtil.getAddress(classText));
|
||||
} finally {
|
||||
unlockAWT();
|
||||
}
|
||||
}
|
||||
private static native void nSetClassHint(long display, long window, long wm_name, long wm_class);
|
||||
|
||||
public boolean isCloseRequested() {
|
||||
boolean result = close_requested;
|
||||
|
|
@ -795,10 +845,10 @@ final class LinuxDisplay implements DisplayImplementation {
|
|||
relayEventToParent(event_buffer, KeyPressMask);
|
||||
break;
|
||||
case LinuxEvent.ButtonPress:
|
||||
relayEventToParent(event_buffer, KeyPressMask);
|
||||
if (xembedded || !focused) relayEventToParent(event_buffer, KeyPressMask);
|
||||
break;
|
||||
case LinuxEvent.ButtonRelease:
|
||||
relayEventToParent(event_buffer, KeyPressMask);
|
||||
if (xembedded || !focused) relayEventToParent(event_buffer, KeyPressMask);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
@ -835,10 +885,17 @@ final class LinuxDisplay implements DisplayImplementation {
|
|||
break;
|
||||
case LinuxEvent.Expose:
|
||||
dirty = true;
|
||||
break;
|
||||
case LinuxEvent.ConfigureNotify:
|
||||
int x = nGetX(getDisplay(), getWindow());
|
||||
int y = nGetY(getDisplay(), getWindow());
|
||||
|
||||
int width = nGetWidth(getDisplay(), getWindow());
|
||||
int height = nGetHeight(getDisplay(), getWindow());
|
||||
|
||||
window_x = x;
|
||||
window_y = y;
|
||||
|
||||
if (window_width != width || window_height != height) {
|
||||
resized = true;
|
||||
window_width = width;
|
||||
|
|
@ -881,13 +938,29 @@ final class LinuxDisplay implements DisplayImplementation {
|
|||
public DisplayMode[] getAvailableDisplayModes() throws LWJGLException {
|
||||
lockAWT();
|
||||
try {
|
||||
incDisplay();
|
||||
try {
|
||||
DisplayMode[] modes = nGetAvailableDisplayModes(getDisplay(), getDefaultScreen(), current_displaymode_extension);
|
||||
return modes;
|
||||
} finally {
|
||||
decDisplay();
|
||||
}
|
||||
incDisplay();
|
||||
if (current_displaymode_extension == XRANDR) {
|
||||
// nGetAvailableDisplayModes cannot be trusted. Use it only for bitsPerPixel
|
||||
DisplayMode[] nDisplayModes = nGetAvailableDisplayModes(getDisplay(), getDefaultScreen(), current_displaymode_extension);
|
||||
int bpp = 24;
|
||||
if (nDisplayModes.length > 0) {
|
||||
bpp = nDisplayModes[0].getBitsPerPixel();
|
||||
}
|
||||
// get the resolutions and frequencys from XRandR
|
||||
Screen[] resolutions = XRandR.getResolutions(XRandR.getScreenNames()[0]);
|
||||
DisplayMode[] modes = new DisplayMode[resolutions.length];
|
||||
for (int i = 0; i < modes.length; i++) {
|
||||
modes[i] = new DisplayMode(resolutions[i].width, resolutions[i].height, bpp, resolutions[i].freq);
|
||||
}
|
||||
return modes;
|
||||
} else {
|
||||
try {
|
||||
DisplayMode[] modes = nGetAvailableDisplayModes(getDisplay(), getDefaultScreen(), current_displaymode_extension);
|
||||
return modes;
|
||||
} finally {
|
||||
decDisplay();
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
unlockAWT();
|
||||
}
|
||||
|
|
@ -971,20 +1044,24 @@ final class LinuxDisplay implements DisplayImplementation {
|
|||
}
|
||||
}
|
||||
else {
|
||||
if (parent_focused != keyboard_grabbed) {
|
||||
if (parent_focused) {
|
||||
grabKeyboard();
|
||||
input_released = false;
|
||||
focused = true;
|
||||
}
|
||||
else {
|
||||
ungrabKeyboard();
|
||||
input_released = true;
|
||||
focused = false;
|
||||
}
|
||||
if (parent_focus_changed && parent_focused) {
|
||||
setInputFocusUnsafe(getWindow());
|
||||
parent_focus_changed = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setInputFocusUnsafe(long window) {
|
||||
try {
|
||||
nSetInputFocus(getDisplay(), window, CurrentTime);
|
||||
nSync(getDisplay(), false);
|
||||
} catch (LWJGLException e) {
|
||||
// Since we don't have any event timings for XSetInputFocus, a race condition might give a BadMatch, which we'll catch and ignore
|
||||
LWJGLUtil.log("Got exception while trying to focus: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
private static native void nSync(long display, boolean throw_away_events) throws LWJGLException;
|
||||
|
||||
/**
|
||||
* This method will check if the parent window is active when running
|
||||
|
|
@ -1029,7 +1106,7 @@ final class LinuxDisplay implements DisplayImplementation {
|
|||
}
|
||||
|
||||
private void setFocused(boolean got_focus, int focus_detail) {
|
||||
if (focused == got_focus || focus_detail == NotifyDetailNone || focus_detail == NotifyPointer || focus_detail == NotifyPointerRoot || parent != null)
|
||||
if (focused == got_focus || focus_detail == NotifyDetailNone || focus_detail == NotifyPointer || focus_detail == NotifyPointerRoot || xembedded)
|
||||
return;
|
||||
focused = got_focus;
|
||||
|
||||
|
|
@ -1044,16 +1121,18 @@ final class LinuxDisplay implements DisplayImplementation {
|
|||
private void releaseInput() {
|
||||
if (isLegacyFullscreen() || input_released)
|
||||
return;
|
||||
if ( keyboard != null )
|
||||
keyboard.releaseAll();
|
||||
input_released = true;
|
||||
updateInputGrab();
|
||||
if (current_window_mode == FULLSCREEN_NETWM) {
|
||||
nIconifyWindow(getDisplay(), getWindow(), getDefaultScreen());
|
||||
try {
|
||||
if( current_displaymode_extension == XRANDR && savedXrandrConfig.length > 0 )
|
||||
if( current_displaymode_extension == XRANDR )
|
||||
{
|
||||
AccessController.doPrivileged(new PrivilegedAction<Object>() {
|
||||
public Object run() {
|
||||
XRandR.setConfiguration( savedXrandrConfig );
|
||||
XRandR.restoreConfiguration();
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
|
@ -1280,50 +1359,58 @@ final class LinuxDisplay implements DisplayImplementation {
|
|||
public void releaseTexImageFromPbuffer(PeerInfo handle, int buffer) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
private static ByteBuffer convertIcon(ByteBuffer icon, int width, int height) {
|
||||
ByteBuffer icon_rgb = BufferUtils.createByteBuffer(icon.capacity());
|
||||
int x;
|
||||
int y;
|
||||
byte r,g,b;
|
||||
|
||||
int depth = 4;
|
||||
|
||||
for (y = 0; y < height; y++) {
|
||||
for (x = 0; x < width; x++) {
|
||||
r = icon.get((x*4)+(y*width*4));
|
||||
g = icon.get((x*4)+(y*width*4)+1);
|
||||
b = icon.get((x*4)+(y*width*4)+2);
|
||||
|
||||
icon_rgb.put((x*depth)+(y*width*depth), b); // blue
|
||||
icon_rgb.put((x*depth)+(y*width*depth)+1, g); // green
|
||||
icon_rgb.put((x*depth)+(y*width*depth)+2, r);
|
||||
|
||||
/**
|
||||
* This method will convert icon bytebuffers into a single bytebuffer
|
||||
* as the icon format required by _NET_WM_ICON should be in a cardinal
|
||||
* 32 bit ARGB format i.e. all icons in a single buffer the data starting
|
||||
* with 32 bit width & height followed by the color data as 32bit ARGB.
|
||||
*
|
||||
* @param icons Array of icons in RGBA format
|
||||
*/
|
||||
private static ByteBuffer convertIcons(ByteBuffer[] icons) {
|
||||
|
||||
int bufferSize = 0;
|
||||
|
||||
// calculate size of bytebuffer
|
||||
for ( ByteBuffer icon : icons ) {
|
||||
int size = icon.limit() / 4;
|
||||
int dimension = (int)Math.sqrt(size);
|
||||
if ( dimension > 0 ) {
|
||||
bufferSize += 2 * 4; // add 32 bit width & height, 4 bytes each
|
||||
bufferSize += dimension * dimension * 4;
|
||||
}
|
||||
}
|
||||
return icon_rgb;
|
||||
}
|
||||
|
||||
private static ByteBuffer convertIconMask(ByteBuffer icon, int width, int height) {
|
||||
ByteBuffer icon_mask = BufferUtils.createByteBuffer((icon.capacity()/4)/8);
|
||||
int x;
|
||||
int y;
|
||||
byte a;
|
||||
|
||||
int depth = 4;
|
||||
|
||||
for (y = 0; y < height; y++) {
|
||||
for (x = 0; x < width; x++) {
|
||||
a = icon.get((x*4)+(y*width*4)+3);
|
||||
|
||||
int mask_index = x + y*width;
|
||||
int mask_byte_index = mask_index/8;
|
||||
int mask_bit_index = mask_index%8;
|
||||
byte bit = (((int)a) & 0xff) >= 127 ? (byte)1 : (byte)0;
|
||||
byte new_byte = (byte)((icon_mask.get(mask_byte_index) | (bit<<mask_bit_index)) & 0xff);
|
||||
icon_mask.put(mask_byte_index, new_byte);
|
||||
|
||||
if (bufferSize == 0) return null;
|
||||
|
||||
ByteBuffer icon_argb = BufferUtils.createByteBuffer(bufferSize);//icon.capacity()+(2*4));
|
||||
icon_argb.order(ByteOrder.BIG_ENDIAN);
|
||||
|
||||
for ( ByteBuffer icon : icons ) {
|
||||
int size = icon.limit() / 4;
|
||||
int dimension = (int)Math.sqrt(size);
|
||||
|
||||
icon_argb.putInt(dimension); // width
|
||||
icon_argb.putInt(dimension); // height
|
||||
|
||||
for (int y = 0; y < dimension; y++) {
|
||||
for (int x = 0; x < dimension; x++) {
|
||||
|
||||
byte r = icon.get((x*4)+(y*dimension*4));
|
||||
byte g = icon.get((x*4)+(y*dimension*4)+1);
|
||||
byte b = icon.get((x*4)+(y*dimension*4)+2);
|
||||
byte a = icon.get((x*4)+(y*dimension*4)+3);
|
||||
|
||||
icon_argb.put(a);
|
||||
icon_argb.put(r);
|
||||
icon_argb.put(g);
|
||||
icon_argb.put(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
return icon_mask;
|
||||
|
||||
return icon_argb;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1343,17 +1430,11 @@ final class LinuxDisplay implements DisplayImplementation {
|
|||
try {
|
||||
incDisplay();
|
||||
try {
|
||||
for ( ByteBuffer icon : icons ) {
|
||||
int size = icon.limit() / 4;
|
||||
int dimension = (int)Math.sqrt(size);
|
||||
if ( dimension > 0 ) {
|
||||
ByteBuffer icon_rgb = convertIcon(icon, dimension, dimension);
|
||||
ByteBuffer icon_mask = convertIconMask(icon, dimension, dimension);
|
||||
nSetWindowIcon(getDisplay(), getWindow(), icon_rgb, icon_rgb.capacity(), icon_mask, icon_mask.capacity(), dimension, dimension);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
// get icons as cardinal ARGB format
|
||||
ByteBuffer icons_data = convertIcons(icons);
|
||||
if (icons_data == null) return 0;
|
||||
nSetWindowIcon(getDisplay(), getWindow(), icons_data, icons_data.capacity());//, icon_mask, icon_mask.capacity(), dimension, dimension);
|
||||
return icons.length;
|
||||
} finally {
|
||||
decDisplay();
|
||||
}
|
||||
|
|
@ -1365,8 +1446,16 @@ final class LinuxDisplay implements DisplayImplementation {
|
|||
}
|
||||
}
|
||||
|
||||
private static native void nSetWindowIcon(long display, long window, ByteBuffer icon_rgb, int icon_rgb_size, ByteBuffer icon_mask, int icon_mask_size, int width, int height);
|
||||
private static native void nSetWindowIcon(long display, long window, ByteBuffer icons_data, int icons_size);
|
||||
|
||||
public int getX() {
|
||||
return window_x;
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return window_y;
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return window_width;
|
||||
}
|
||||
|
|
@ -1397,6 +1486,10 @@ final class LinuxDisplay implements DisplayImplementation {
|
|||
return false;
|
||||
}
|
||||
|
||||
public float getPixelScaleFactor() {
|
||||
return 1f;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper class for managing Compiz's workarounds. We need this to enable Legacy
|
||||
* Fullscreen Support in Compiz, else we'll have trouble with fullscreen windows
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ final class LinuxEvent {
|
|||
public static final int UnmapNotify = 18;
|
||||
public static final int MapNotify = 19;
|
||||
public static final int Expose = 12;
|
||||
public static final int ConfigureNotify = 22;
|
||||
public static final int ClientMessage = 33;
|
||||
|
||||
private final ByteBuffer event_buffer;
|
||||
|
|
|
|||
|
|
@ -257,46 +257,22 @@ final class LinuxKeyboard {
|
|||
private static native long lookupKeysym(long event_ptr, int index);
|
||||
private static native long toUpper(long keysym);
|
||||
|
||||
private long mapEventToKeySym(long event_ptr, int event_state) {
|
||||
int group;
|
||||
long keysym;
|
||||
if ((event_state & modeswitch_mask) != 0)
|
||||
group = 1;
|
||||
else
|
||||
group = 0;
|
||||
if ((event_state & numlock_mask) != 0 && isKeypadKeysym(keysym = getKeySym(event_ptr, group, 1))) {
|
||||
if ((event_state & (ShiftMask | shift_lock_mask)) != 0) {
|
||||
return getKeySym(event_ptr, group, 0);
|
||||
} else {
|
||||
return keysym;
|
||||
}
|
||||
} else if ((event_state & (ShiftMask | LockMask)) == 0) {
|
||||
return getKeySym(event_ptr, group, 0);
|
||||
} else if ((event_state & ShiftMask) == 0) {
|
||||
keysym = getKeySym(event_ptr, group, 0);
|
||||
if ((event_state & caps_lock_mask) != 0)
|
||||
keysym = toUpper(keysym);
|
||||
return keysym;
|
||||
} else {
|
||||
keysym = getKeySym(event_ptr, group, 1);
|
||||
if ((event_state & caps_lock_mask) != 0)
|
||||
keysym = toUpper(keysym);
|
||||
return keysym;
|
||||
}
|
||||
}
|
||||
|
||||
private int getKeycode(long event_ptr, int event_state) {
|
||||
long keysym = mapEventToKeySym(event_ptr, event_state);
|
||||
int keycode = LinuxKeycodes.mapKeySymToLWJGLKeyCode(keysym);
|
||||
if (keycode == Keyboard.KEY_NONE) {
|
||||
// Try unshifted keysym mapping
|
||||
keysym = lookupKeysym(event_ptr, 0);
|
||||
keycode = LinuxKeycodes.mapKeySymToLWJGLKeyCode(keysym);
|
||||
boolean shift = (event_state & (ShiftMask | shift_lock_mask)) != 0;
|
||||
int group = (event_state & modeswitch_mask) != 0 ? 1 : 0;
|
||||
long keysym;
|
||||
if ((event_state & numlock_mask) != 0 && isKeypadKeysym(keysym = getKeySym(event_ptr, group, 1))) {
|
||||
if ( shift )
|
||||
keysym = getKeySym(event_ptr, group, 0);
|
||||
} else {
|
||||
keysym = getKeySym(event_ptr, group, 0);
|
||||
if ( shift ^ ((event_state & caps_lock_mask) != 0) )
|
||||
keysym = toUpper(keysym);
|
||||
}
|
||||
return keycode;
|
||||
return LinuxKeycodes.mapKeySymToLWJGLKeyCode(keysym);
|
||||
}
|
||||
|
||||
private byte getKeyState(int event_type) {
|
||||
private static byte getKeyState(int event_type) {
|
||||
switch (event_type) {
|
||||
case LinuxEvent.KeyPress:
|
||||
return 1;
|
||||
|
|
@ -307,10 +283,22 @@ final class LinuxKeyboard {
|
|||
}
|
||||
}
|
||||
|
||||
/** This is called when the window loses focus: we release all currently pressed keys. */
|
||||
void releaseAll() {
|
||||
for ( int i = 0; i < key_down_buffer.length; i++ ) {
|
||||
if ( key_down_buffer[i] != 0 ) {
|
||||
key_down_buffer[i] = 0;
|
||||
putKeyboardEvent(i, (byte)0, 0, 0L, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleKeyEvent(long event_ptr, long millis, int event_type, int event_keycode, int event_state) {
|
||||
int keycode = getKeycode(event_ptr, event_state);
|
||||
byte key_state = getKeyState(event_type);
|
||||
boolean repeat = key_state == key_down_buffer[keycode];
|
||||
if ( repeat && event_type == LinuxEvent.KeyRelease ) // This can happen for modifier keys after losing and regaining focus.
|
||||
return;
|
||||
key_down_buffer[keycode] = key_state;
|
||||
long nanos = millis*1000000;
|
||||
if (event_type == LinuxEvent.KeyPress) {
|
||||
|
|
|
|||
|
|
@ -43,17 +43,23 @@ import org.lwjgl.LWJGLException;
|
|||
import org.lwjgl.input.Mouse;
|
||||
|
||||
final class LinuxMouse {
|
||||
private static final int NUM_BUTTONS = 3;
|
||||
private static final int POINTER_WARP_BORDER = 10;
|
||||
// scale the mouse wheel according to DirectInput
|
||||
private static final int WHEEL_SCALE = 120;
|
||||
|
||||
private int button_count;
|
||||
|
||||
/* X11 constants */
|
||||
private static final int Button1 = 1;
|
||||
private static final int Button2 = 2;
|
||||
private static final int Button3 = 3;
|
||||
private static final int Button4 = 4;
|
||||
private static final int Button5 = 5;
|
||||
|
||||
private static final int Button6 = 6; // wheel tilt left *rare*
|
||||
private static final int Button7 = 7; // wheel tilt right *rare*
|
||||
private static final int Button8 = 8; // back button
|
||||
private static final int Button9 = 9; // forward button
|
||||
|
||||
private static final int ButtonPress = 4;
|
||||
private static final int ButtonRelease = 5;
|
||||
|
|
@ -70,7 +76,7 @@ final class LinuxMouse {
|
|||
private int accum_dx;
|
||||
private int accum_dy;
|
||||
private int accum_dz;
|
||||
private byte[] buttons = new byte[NUM_BUTTONS];
|
||||
private byte[] buttons;
|
||||
private EventQueue event_queue;
|
||||
private long last_event_nanos;
|
||||
|
||||
|
|
@ -79,6 +85,8 @@ final class LinuxMouse {
|
|||
this.window = window;
|
||||
this.input_window = input_window;
|
||||
this.warp_atom = LinuxDisplay.nInternAtom(display, "_LWJGL", false);
|
||||
button_count = nGetButtonCount(display);
|
||||
buttons = new byte[button_count];
|
||||
reset(false, false);
|
||||
}
|
||||
|
||||
|
|
@ -189,6 +197,8 @@ final class LinuxMouse {
|
|||
}
|
||||
private static native int nGetWindowHeight(long display, long window);
|
||||
private static native int nGetWindowWidth(long display, long window);
|
||||
|
||||
private static native int nGetButtonCount(long display);
|
||||
|
||||
private static native long nQueryPointer(long display, long window, IntBuffer result);
|
||||
|
||||
|
|
@ -213,7 +223,23 @@ final class LinuxMouse {
|
|||
case Button3:
|
||||
button_num = (byte)1;
|
||||
break;
|
||||
case Button6:
|
||||
button_num = (byte)5;
|
||||
break;
|
||||
case Button7:
|
||||
button_num = (byte)6;
|
||||
break;
|
||||
case Button8:
|
||||
button_num = (byte)3; // back button
|
||||
break;
|
||||
case Button9:
|
||||
button_num = (byte)4; // forward button
|
||||
break;
|
||||
default:
|
||||
if (button > Button9 && button <= button_count) {
|
||||
button_num = (byte)(button-1);
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
buttons[button_num] = state;
|
||||
|
|
|
|||
|
|
@ -32,32 +32,151 @@
|
|||
package org.lwjgl.opengl;
|
||||
|
||||
import java.awt.Canvas;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.ComponentListener;
|
||||
import java.awt.Insets;
|
||||
import java.awt.Container;
|
||||
import java.awt.Component;
|
||||
import java.awt.Point;
|
||||
import java.awt.Window;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import org.lwjgl.LWJGLException;
|
||||
import org.lwjgl.LWJGLUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author elias_naur <elias_naur@users.sourceforge.net>
|
||||
* @author kappaOne <one.kappa@gmail.com>
|
||||
* @version $Revision$
|
||||
* $Id$
|
||||
*/
|
||||
abstract class MacOSXCanvasPeerInfo extends MacOSXPeerInfo {
|
||||
private final AWTSurfaceLock awt_surface = new AWTSurfaceLock();
|
||||
|
||||
public ByteBuffer window_handle;
|
||||
|
||||
protected MacOSXCanvasPeerInfo(PixelFormat pixel_format, ContextAttribs attribs, boolean support_pbuffer) throws LWJGLException {
|
||||
super(pixel_format, attribs, true, true, support_pbuffer, true);
|
||||
}
|
||||
|
||||
protected void initHandle(Canvas component) throws LWJGLException {
|
||||
// Allow the use of a Core Animation Layer only when using non fullscreen Display.setParent() or AWTGLCanvas
|
||||
final boolean allowCALayer = (Display.getParent() != null && !Display.isFullscreen()) || component instanceof AWTGLCanvas;
|
||||
boolean forceCALayer = true;
|
||||
boolean autoResizable = true; // set the CALayer to autoResize
|
||||
|
||||
nInitHandle(awt_surface.lockAndGetHandle(component), getHandle(), allowCALayer);
|
||||
String javaVersion = System.getProperty("java.version");
|
||||
|
||||
if (javaVersion.startsWith("1.5") || javaVersion.startsWith("1.6")) {
|
||||
// On Java 7 and newer CALayer mode is the only way to use OpenGL with AWT
|
||||
// therefore force it on all JVM's except for the older Java 5 and Java 6
|
||||
// where the older cocoaViewRef NSView method maybe be available.
|
||||
forceCALayer = false;
|
||||
}
|
||||
else if (javaVersion.startsWith("1.7")) {
|
||||
autoResizable = false;
|
||||
}
|
||||
|
||||
Insets insets = getInsets(component);
|
||||
|
||||
int top = insets != null ? insets.top : 0;
|
||||
int left = insets != null ? insets.left : 0;
|
||||
|
||||
window_handle = nInitHandle(awt_surface.lockAndGetHandle(component), getHandle(), window_handle, forceCALayer, autoResizable, component.getX()-left, component.getY()-top);
|
||||
|
||||
if (javaVersion.startsWith("1.7")) {
|
||||
// fix for CALayer position not covering Canvas due to a Java 7 bug
|
||||
// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7172187
|
||||
addComponentListener(component);
|
||||
|
||||
reSetLayerBounds(component, getHandle());
|
||||
}
|
||||
}
|
||||
private static native void nInitHandle(ByteBuffer surface_buffer, ByteBuffer peer_info_handle, boolean allowCALayer) throws LWJGLException;
|
||||
|
||||
private void addComponentListener(final Canvas component) {
|
||||
|
||||
ComponentListener[] components = component.getComponentListeners();
|
||||
|
||||
// avoid adding duplicate listners by checking if one has already been added
|
||||
for (int i = 0; i < components.length; i++) {
|
||||
ComponentListener c = components[i];
|
||||
if (c.toString() == "CanvasPeerInfoListener") {
|
||||
return; // already contains the listner below return without adding
|
||||
}
|
||||
}
|
||||
|
||||
ComponentListener comp = new ComponentListener() {
|
||||
public void componentHidden(ComponentEvent e) {
|
||||
|
||||
}
|
||||
|
||||
public void componentMoved(ComponentEvent e) {
|
||||
|
||||
//nSetLayerPosition(getHandle(), component.getX() - left, component.getY() - top);
|
||||
reSetLayerBounds(component, getHandle());
|
||||
}
|
||||
|
||||
public void componentResized(ComponentEvent e) {
|
||||
|
||||
//nSetLayerPosition(getHandle(), component.getX() - left, component.getY() - top);
|
||||
reSetLayerBounds(component, getHandle());
|
||||
}
|
||||
|
||||
public void componentShown(ComponentEvent e) {
|
||||
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "CanvasPeerInfoListener";
|
||||
}
|
||||
};
|
||||
|
||||
component.addComponentListener(comp);
|
||||
}
|
||||
|
||||
private static native ByteBuffer nInitHandle(ByteBuffer surface_buffer, ByteBuffer peer_info_handle, ByteBuffer window_handle, boolean forceCALayer, boolean autoResizable, int x, int y) throws LWJGLException;
|
||||
|
||||
private static native void nSetLayerPosition(ByteBuffer peer_info_handle, int x, int y);
|
||||
|
||||
private static native void nSetLayerBounds(ByteBuffer peer_info_handle, int x, int y, int width, int height);
|
||||
|
||||
/**
|
||||
* fix for CALayer position not covering Canvas due to a Java 7 bug
|
||||
* {@link http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7172187}
|
||||
* @param component
|
||||
* @param peer_info_handle
|
||||
*/
|
||||
private static void reSetLayerBounds(Canvas component, ByteBuffer peer_info_handle) {
|
||||
// report the root parent (peer).
|
||||
Component peer = SwingUtilities.getRoot(component);
|
||||
|
||||
Point rtLoc = SwingUtilities.convertPoint(component.getParent(), component.getLocation(), peer);
|
||||
int x = (int) rtLoc.getX(), y = (int) rtLoc.getY();
|
||||
|
||||
Insets insets = getInsets(component);
|
||||
x -= insets != null ? insets.left : 0;
|
||||
y -= insets != null ? insets.top : 0;
|
||||
|
||||
// http://hg.openjdk.java.net/jdk8/awt/jdk/rev/65d874d16d59
|
||||
y = (int) peer.getHeight() - y - (int) component.getHeight();
|
||||
|
||||
nSetLayerBounds(peer_info_handle, x, y, component.getWidth(), component.getHeight());
|
||||
}
|
||||
|
||||
protected void doUnlock() throws LWJGLException {
|
||||
awt_surface.unlock();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return rootpane insets (peer insets) values.
|
||||
*/
|
||||
private static Insets getInsets(Canvas component) {
|
||||
Container c = SwingUtilities.getRootPane(component);
|
||||
|
||||
if(c != null) {
|
||||
return c.getInsets();
|
||||
} else {
|
||||
return new Insets(0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,11 +35,13 @@ package org.lwjgl.opengl;
|
|||
* This is the Display implementation interface. Display delegates
|
||||
* to implementors of this interface. There is one DisplayImplementation
|
||||
* for each supported platform.
|
||||
* @author elias_naur
|
||||
*
|
||||
* @author elias_naur <elias_naur@users.sourceforge.net>
|
||||
* @author mojang
|
||||
* @author kappaOne <one.kappa@gmail.com>
|
||||
*/
|
||||
|
||||
import java.awt.Canvas;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.Robot;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
|
|
@ -50,96 +52,171 @@ import java.security.PrivilegedExceptionAction;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.lwjgl.input.Cursor;
|
||||
import org.lwjgl.opengl.Display;
|
||||
import org.lwjgl.opengl.DisplayMode;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.MemoryUtil;
|
||||
import org.lwjgl.LWJGLException;
|
||||
import org.lwjgl.LWJGLUtil;
|
||||
|
||||
import com.apple.eawt.Application;
|
||||
import com.apple.eawt.ApplicationAdapter;
|
||||
import com.apple.eawt.ApplicationEvent;
|
||||
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
|
||||
final class MacOSXDisplay implements DisplayImplementation {
|
||||
private static final int PBUFFER_HANDLE_SIZE = 24;
|
||||
private static final int GAMMA_LENGTH = 256;
|
||||
|
||||
private MacOSXCanvasListener canvas_listener;
|
||||
private MacOSXFrame frame;
|
||||
//private MacOSXCanvasListener canvas_listener;
|
||||
private Canvas canvas;
|
||||
private Robot robot;
|
||||
private MacOSXMouseEventQueue mouse_queue;
|
||||
private KeyboardEventQueue keyboard_queue;
|
||||
private java.awt.DisplayMode requested_mode;
|
||||
|
||||
/* States */
|
||||
private DisplayMode requested_mode;
|
||||
|
||||
/* Members for native window use */
|
||||
private MacOSXNativeMouse mouse;
|
||||
private MacOSXNativeKeyboard keyboard;
|
||||
private ByteBuffer window;
|
||||
private ByteBuffer context;
|
||||
|
||||
private boolean skipViewportValue = false;
|
||||
private static final IntBuffer current_viewport = BufferUtils.createIntBuffer(16);
|
||||
|
||||
private boolean mouseInsideWindow;
|
||||
|
||||
private boolean close_requested;
|
||||
|
||||
private boolean native_mode = true;
|
||||
|
||||
private boolean updateNativeCursor = false;
|
||||
|
||||
private long currentNativeCursor = 0;
|
||||
|
||||
private boolean enableHighDPI = false;
|
||||
|
||||
private float scaleFactor = 1.0f;
|
||||
|
||||
MacOSXDisplay() {
|
||||
try {
|
||||
AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
|
||||
public Object run() throws Exception {
|
||||
Application.getApplication().addApplicationListener(new ApplicationAdapter() {
|
||||
public void handleQuit(ApplicationEvent event) {
|
||||
doHandleQuit();
|
||||
}
|
||||
});
|
||||
return null;
|
||||
}
|
||||
});
|
||||
} catch (Throwable e) {
|
||||
/**
|
||||
* In an applet environment, referencing com.apple.eawt.Application can fail with
|
||||
* a native exception. So log any exceptions instead of re-throwing.
|
||||
*/
|
||||
LWJGLUtil.log("Failed to register quit handler: " + e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private native ByteBuffer nCreateWindow(int x, int y, int width, int height, boolean fullscreen, boolean undecorated, boolean resizable, boolean parented, boolean enableFullscreenModeAPI, boolean enableHighDPI, ByteBuffer peer_info_handle, ByteBuffer window_handle) throws LWJGLException;
|
||||
|
||||
private native Object nGetCurrentDisplayMode();
|
||||
|
||||
private native void nGetDisplayModes(Object modesList);
|
||||
|
||||
private native boolean nIsMiniaturized(ByteBuffer window_handle);
|
||||
|
||||
private native boolean nIsFocused(ByteBuffer window_handle);
|
||||
|
||||
private native void nSetResizable(ByteBuffer window_handle, boolean resizable);
|
||||
|
||||
private native void nResizeWindow(ByteBuffer window_handle, int x, int y, int width, int height);
|
||||
|
||||
private native boolean nWasResized(ByteBuffer window_handle);
|
||||
|
||||
private native int nGetX(ByteBuffer window_handle);
|
||||
|
||||
private native int nGetY(ByteBuffer window_handle);
|
||||
|
||||
private native int nGetWidth(ByteBuffer window_handle);
|
||||
|
||||
private native int nGetHeight(ByteBuffer window_handle);
|
||||
|
||||
private native boolean nIsNativeMode(ByteBuffer peer_info_handle);
|
||||
|
||||
private static boolean isUndecorated() {
|
||||
return Display.getPrivilegedBoolean("org.lwjgl.opengl.Window.undecorated");
|
||||
}
|
||||
|
||||
public void createWindow(final DrawableLWJGL drawable, DisplayMode mode, Canvas parent, int x, int y) throws LWJGLException {
|
||||
boolean fullscreen = Display.isFullscreen();
|
||||
hideUI(fullscreen);
|
||||
boolean resizable = Display.isResizable();
|
||||
boolean parented = (parent != null) && !fullscreen;
|
||||
|
||||
// OS X fullscreen mode API is only available on OS X 10.7+
|
||||
boolean enableFullscreenModeAPI = LWJGLUtil.isMacOSXEqualsOrBetterThan(10, 7) && parent == null &&
|
||||
!Display.getPrivilegedBoolean("org.lwjgl.opengl.Display.disableOSXFullscreenModeAPI");
|
||||
|
||||
// OS X high DPI mode is only available on OS X 10.7+
|
||||
enableHighDPI = LWJGLUtil.isMacOSXEqualsOrBetterThan(10, 7) && parent == null &&
|
||||
(Display.getPrivilegedBoolean("org.lwjgl.opengl.Display.enableHighDPI") || fullscreen);
|
||||
|
||||
if (parented) this.canvas = parent;
|
||||
else this.canvas = null;
|
||||
|
||||
close_requested = false;
|
||||
|
||||
DrawableGL gl_drawable = (DrawableGL)Display.getDrawable();
|
||||
PeerInfo peer_info = gl_drawable.peer_info;
|
||||
ByteBuffer peer_handle = peer_info.lockAndGetHandle();
|
||||
ByteBuffer window_handle = parented ? ((MacOSXCanvasPeerInfo)peer_info).window_handle : window;
|
||||
|
||||
try {
|
||||
if (parent == null) {
|
||||
frame = new MacOSXFrame(mode, requested_mode, fullscreen, x, y);
|
||||
canvas = frame.getCanvas();
|
||||
} else {
|
||||
frame = null;
|
||||
canvas = parent;
|
||||
|
||||
window = nCreateWindow(x, y, mode.getWidth(), mode.getHeight(),
|
||||
fullscreen, isUndecorated(), resizable,
|
||||
parented, enableFullscreenModeAPI, enableHighDPI, peer_handle, window_handle);
|
||||
|
||||
if (fullscreen) {
|
||||
// when going to fullscreen viewport is set to screen size by Cocoa, ignore this value
|
||||
skipViewportValue = true;
|
||||
// if starting in fullscreen then set initial viewport to displaymode size
|
||||
current_viewport.put(2, mode.getWidth());
|
||||
current_viewport.put(3, mode.getHeight());
|
||||
}
|
||||
canvas_listener = new MacOSXCanvasListener(canvas);
|
||||
robot = AWTUtil.createRobot(canvas);
|
||||
|
||||
native_mode = nIsNativeMode(peer_handle);
|
||||
|
||||
if (!native_mode) {
|
||||
robot = AWTUtil.createRobot(canvas);
|
||||
}
|
||||
|
||||
} catch (LWJGLException e) {
|
||||
destroyWindow();
|
||||
throw e;
|
||||
} finally {
|
||||
peer_info.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
private void doHandleQuit() {
|
||||
public void doHandleQuit() {
|
||||
synchronized (this) {
|
||||
close_requested = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void mouseInsideWindow(boolean inside) {
|
||||
synchronized (this) {
|
||||
mouseInsideWindow = inside;
|
||||
}
|
||||
updateNativeCursor = true;
|
||||
}
|
||||
|
||||
public void setScaleFactor(float scale) {
|
||||
synchronized (this) {
|
||||
scaleFactor = scale;
|
||||
}
|
||||
}
|
||||
|
||||
public native void nDestroyCALayer(ByteBuffer peer_info_handle);
|
||||
|
||||
public native void nDestroyWindow(ByteBuffer window_handle);
|
||||
|
||||
public void destroyWindow() {
|
||||
if (canvas_listener != null) {
|
||||
canvas_listener.disableListeners();
|
||||
canvas_listener = null;
|
||||
|
||||
if (!native_mode) {
|
||||
DrawableGL gl_drawable = (DrawableGL)Display.getDrawable();
|
||||
PeerInfo peer_info = gl_drawable.peer_info;
|
||||
if (peer_info != null) {
|
||||
ByteBuffer peer_handle = peer_info.getHandle();
|
||||
nDestroyCALayer(peer_handle);
|
||||
}
|
||||
robot = null;
|
||||
}
|
||||
if (frame != null) {
|
||||
AccessController.doPrivileged(new PrivilegedAction<Object>() {
|
||||
public Object run() {
|
||||
if (MacOSXFrame.getDevice().getFullScreenWindow() == frame)
|
||||
MacOSXFrame.getDevice().setFullScreenWindow(null);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
if (frame.isDisplayable())
|
||||
frame.dispose();
|
||||
frame = null;
|
||||
}
|
||||
hideUI(false);
|
||||
|
||||
nDestroyWindow(window);
|
||||
}
|
||||
|
||||
public int getGammaRampLength() {
|
||||
|
|
@ -155,81 +232,80 @@ final class MacOSXDisplay implements DisplayImplementation {
|
|||
public String getVersion() {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static boolean equals(java.awt.DisplayMode awt_mode, DisplayMode mode) {
|
||||
return awt_mode.getWidth() == mode.getWidth() && awt_mode.getHeight() == mode.getHeight()
|
||||
&& awt_mode.getBitDepth() == mode.getBitsPerPixel() && awt_mode.getRefreshRate() == mode.getFrequency();
|
||||
|
||||
private static boolean equals(DisplayMode mode1, DisplayMode mode2) {
|
||||
return mode1.getWidth() == mode2.getWidth() && mode1.getHeight() == mode2.getHeight()
|
||||
&& mode1.getBitsPerPixel() == mode2.getBitsPerPixel() && mode1.getFrequency() == mode2.getFrequency();
|
||||
}
|
||||
|
||||
public void switchDisplayMode(DisplayMode mode) throws LWJGLException {
|
||||
java.awt.DisplayMode[] awt_modes = MacOSXFrame.getDevice().getDisplayModes();
|
||||
for ( java.awt.DisplayMode awt_mode : awt_modes ) {
|
||||
if (equals(awt_mode, mode)) {
|
||||
requested_mode = awt_mode;
|
||||
DisplayMode[] modes = getAvailableDisplayModes();
|
||||
|
||||
for (DisplayMode available_mode : modes) {
|
||||
if (equals(available_mode, mode)) {
|
||||
requested_mode = available_mode;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
throw new LWJGLException(mode + " is not supported");
|
||||
}
|
||||
|
||||
public void resetDisplayMode() {
|
||||
if (MacOSXFrame.getDevice().getFullScreenWindow() != null)
|
||||
MacOSXFrame.getDevice().setFullScreenWindow(null);
|
||||
requested_mode = null;
|
||||
requested_mode = null;
|
||||
restoreGamma();
|
||||
}
|
||||
|
||||
private native void restoreGamma();
|
||||
|
||||
private static DisplayMode createLWJGLDisplayMode(java.awt.DisplayMode awt_mode) {
|
||||
int bit_depth;
|
||||
int refresh_rate;
|
||||
int awt_bit_depth = awt_mode.getBitDepth();
|
||||
int awt_refresh_rate = awt_mode.getRefreshRate();
|
||||
if (awt_bit_depth != java.awt.DisplayMode.BIT_DEPTH_MULTI)
|
||||
bit_depth = awt_bit_depth;
|
||||
else
|
||||
bit_depth = 32; // Assume the best bit depth
|
||||
if (awt_refresh_rate != java.awt.DisplayMode.REFRESH_RATE_UNKNOWN)
|
||||
refresh_rate = awt_refresh_rate;
|
||||
else
|
||||
refresh_rate = 0;
|
||||
return new DisplayMode(awt_mode.getWidth(), awt_mode.getHeight(), bit_depth, refresh_rate);
|
||||
public Object createDisplayMode(int width, int height, int bitsPerPixel, int refreshRate) {
|
||||
return new DisplayMode(width, height, bitsPerPixel, refreshRate);
|
||||
}
|
||||
|
||||
|
||||
public DisplayMode init() throws LWJGLException {
|
||||
return createLWJGLDisplayMode(MacOSXFrame.getDevice().getDisplayMode());
|
||||
return (DisplayMode) nGetCurrentDisplayMode();
|
||||
}
|
||||
|
||||
public void addDisplayMode(Object modesList, int width, int height, int bitsPerPixel, int refreshRate) {
|
||||
List<DisplayMode> modes = (List<DisplayMode>) modesList;
|
||||
DisplayMode displayMode = new DisplayMode(width, height, bitsPerPixel, refreshRate);
|
||||
modes.add(displayMode);
|
||||
}
|
||||
|
||||
public DisplayMode[] getAvailableDisplayModes() throws LWJGLException {
|
||||
java.awt.DisplayMode[] awt_modes = MacOSXFrame.getDevice().getDisplayModes();
|
||||
List<DisplayMode> modes = new ArrayList<DisplayMode>();
|
||||
for ( java.awt.DisplayMode awt_mode : awt_modes )
|
||||
if ( awt_mode.getBitDepth() >= 16 )
|
||||
modes.add(createLWJGLDisplayMode(awt_mode));
|
||||
nGetDisplayModes(modes); // will populate the above list
|
||||
modes.add(Display.getDesktopDisplayMode()); // add desktop resolution as scaled resolutions do not appear
|
||||
return modes.toArray(new DisplayMode[modes.size()]);
|
||||
}
|
||||
|
||||
private native void nSetTitle(ByteBuffer window_handle, ByteBuffer title_buffer);
|
||||
|
||||
public void setTitle(String title) {
|
||||
if (frame != null)
|
||||
frame.setTitle(title);
|
||||
ByteBuffer buffer = MemoryUtil.encodeUTF8(title);
|
||||
nSetTitle(window, buffer);
|
||||
}
|
||||
|
||||
public boolean isCloseRequested() {
|
||||
boolean result;
|
||||
synchronized (this) {
|
||||
result = close_requested || (frame != null && frame.syncIsCloseRequested());
|
||||
result = close_requested;
|
||||
close_requested = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
return frame == null || frame.syncIsVisible();
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return canvas.isFocusOwner();
|
||||
if (native_mode) {
|
||||
return nIsFocused(window);
|
||||
}
|
||||
else {
|
||||
return Display.getParent().hasFocus();
|
||||
}
|
||||
}
|
||||
|
||||
public Canvas getCanvas() {
|
||||
|
|
@ -237,7 +313,7 @@ final class MacOSXDisplay implements DisplayImplementation {
|
|||
}
|
||||
|
||||
public boolean isDirty() {
|
||||
return frame != null && frame.getCanvas().syncIsDirty();
|
||||
return false;
|
||||
}
|
||||
|
||||
public PeerInfo createPeerInfo(PixelFormat pixel_format, ContextAttribs attribs) throws LWJGLException {
|
||||
|
|
@ -248,71 +324,37 @@ final class MacOSXDisplay implements DisplayImplementation {
|
|||
}
|
||||
}
|
||||
|
||||
private static final IntBuffer current_viewport = BufferUtils.createIntBuffer(16);
|
||||
public void update() {
|
||||
boolean should_update = canvas_listener.syncShouldUpdateContext();
|
||||
/*
|
||||
* Workaround for the "white screen in fullscreen mode" problem
|
||||
*
|
||||
* Sometimes, switching from windowed mode to fullscreen or simply creating the Display
|
||||
* in fullscreen mode will result in the context not being bound to the window correctly.
|
||||
* The program runs fine, but the canvas background (white) is shown instead of the context
|
||||
* front buffer.
|
||||
*
|
||||
* I've discovered that re-binding the context with another setView() won't fix the problem, while a
|
||||
* clearDrawable() followed by a setView() does work. A straightforward workaround would be
|
||||
* to simply run the combination at every update(). This is not sufficient, since the clearDrawable()
|
||||
* call makes the the background appear shortly, causing visual artifacts.
|
||||
* What we really need is a way to detect that a setView() failed, and then do the magic combo. I've not
|
||||
* been able to find such a detection so alternatively I'm triggering the combo if the display is fullscreen
|
||||
* (I've not seen the white screen problem in windowed mode) and if the canvas has gotten a paint message or
|
||||
* if its update flag was set.
|
||||
*
|
||||
* My testing seems to indicate that the workaround works, since I've not seen the problem after the fix.
|
||||
*
|
||||
* - elias
|
||||
*/
|
||||
boolean should_update = true;
|
||||
|
||||
DrawableGL drawable = (DrawableGL)Display.getDrawable();
|
||||
if (Display.isFullscreen() && (frame != null && frame.getCanvas().syncCanvasPainted() || should_update)) {
|
||||
try {
|
||||
MacOSXContextImplementation.resetView(drawable.peer_info, drawable.context);
|
||||
} catch (LWJGLException e) {
|
||||
LWJGLUtil.log("Failed to reset context: " + e);
|
||||
}
|
||||
}
|
||||
if (should_update) {
|
||||
|
||||
// Save the current viewport size as cocoa will automatically
|
||||
// set the viewport size to the window size on context update
|
||||
if (skipViewportValue) skipViewportValue = false;
|
||||
else glGetInteger(GL_VIEWPORT, current_viewport);
|
||||
|
||||
drawable.context.update();
|
||||
/* This is necessary to make sure the context won't "forget" about the view size */
|
||||
glGetInteger(GL_VIEWPORT, current_viewport);
|
||||
|
||||
// restore the original viewport size that was set before the update
|
||||
glViewport(current_viewport.get(0), current_viewport.get(1), current_viewport.get(2), current_viewport.get(3));
|
||||
}
|
||||
if (frame != null && mouse_queue != null) {
|
||||
if (frame.syncShouldReleaseCursor())
|
||||
MacOSXMouseEventQueue.nGrabMouse(false);
|
||||
if (frame.syncShouldWarpCursor())
|
||||
mouse_queue.warpCursor();
|
||||
|
||||
if (native_mode && updateNativeCursor) {
|
||||
updateNativeCursor = false;
|
||||
try {
|
||||
setNativeCursor(currentNativeCursor);
|
||||
} catch (LWJGLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This is an interface to the native Carbon call
|
||||
* SetSystemUIMode. It is used to hide the dock in a way
|
||||
* that will prevent AWT from shifting the fullscreen window
|
||||
*
|
||||
* The workaround is not necessary on 10.4, and since 10.4 shows
|
||||
* instability problems calling SetSystemUIMode, we'll only call it
|
||||
* when the OS version is 10.3 or lower.
|
||||
*/
|
||||
private void hideUI(boolean hide) {
|
||||
if (!LWJGLUtil.isMacOSXEqualsOrBetterThan(10, 4))
|
||||
nHideUI(hide);
|
||||
}
|
||||
|
||||
private native void nHideUI(boolean hide);
|
||||
|
||||
public void reshape(int x, int y, int width, int height) {
|
||||
if (frame != null)
|
||||
frame.resize(x, y, width, height);
|
||||
//if (native_mode) {
|
||||
// nResizeWindow(window, x, y, width, height);
|
||||
//}
|
||||
}
|
||||
|
||||
/* Mouse */
|
||||
|
|
@ -325,109 +367,180 @@ final class MacOSXDisplay implements DisplayImplementation {
|
|||
}
|
||||
|
||||
public void createMouse() throws LWJGLException {
|
||||
this.mouse_queue = new MacOSXMouseEventQueue(canvas);
|
||||
mouse_queue.register();
|
||||
if (native_mode) {
|
||||
mouse = new MacOSXNativeMouse(this, window);
|
||||
mouse.register();
|
||||
}
|
||||
else {
|
||||
this.mouse_queue = new MacOSXMouseEventQueue(canvas);
|
||||
mouse_queue.register();
|
||||
}
|
||||
}
|
||||
|
||||
public void destroyMouse() {
|
||||
if (mouse_queue != null) {
|
||||
MacOSXMouseEventQueue.nGrabMouse(false);
|
||||
mouse_queue.unregister();
|
||||
if (native_mode) {
|
||||
// restore default native cursor
|
||||
try {
|
||||
MacOSXNativeMouse.setCursor(0);
|
||||
} catch (LWJGLException e) {};
|
||||
|
||||
// release any mouse grab
|
||||
grabMouse(false);
|
||||
|
||||
if (mouse != null) {
|
||||
mouse.unregister();
|
||||
}
|
||||
mouse = null;
|
||||
}
|
||||
else {
|
||||
if (mouse_queue != null) {
|
||||
MacOSXMouseEventQueue.nGrabMouse(false);
|
||||
mouse_queue.unregister();
|
||||
}
|
||||
this.mouse_queue = null;
|
||||
}
|
||||
this.mouse_queue = null;
|
||||
}
|
||||
|
||||
public void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons_buffer) {
|
||||
mouse_queue.poll(coord_buffer, buttons_buffer);
|
||||
if (native_mode) {
|
||||
mouse.poll(coord_buffer, buttons_buffer);
|
||||
}
|
||||
else {
|
||||
mouse_queue.poll(coord_buffer, buttons_buffer);
|
||||
}
|
||||
}
|
||||
|
||||
public void readMouse(ByteBuffer buffer) {
|
||||
mouse_queue.copyEvents(buffer);
|
||||
if (native_mode) {
|
||||
mouse.copyEvents(buffer);
|
||||
}
|
||||
else {
|
||||
mouse_queue.copyEvents(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
public void grabMouse(boolean grab) {
|
||||
mouse_queue.setGrabbed(grab);
|
||||
if (native_mode) {
|
||||
mouse.setGrabbed(grab);
|
||||
}
|
||||
else {
|
||||
mouse_queue.setGrabbed(grab);
|
||||
}
|
||||
}
|
||||
|
||||
public int getNativeCursorCapabilities() {
|
||||
if (native_mode) {
|
||||
return Cursor.CURSOR_ONE_BIT_TRANSPARENCY | Cursor.CURSOR_8_BIT_ALPHA | Cursor.CURSOR_ANIMATION;
|
||||
}
|
||||
|
||||
return AWTUtil.getNativeCursorCapabilities();
|
||||
}
|
||||
|
||||
public void setCursorPosition(int x, int y) {
|
||||
AWTUtil.setCursorPosition(canvas, robot, x, y);
|
||||
if (native_mode) {
|
||||
if (mouse != null) {
|
||||
mouse.setCursorPosition(x, y);
|
||||
}
|
||||
}
|
||||
//else {
|
||||
//MacOSXMouseEventQueue.nWarpCursor(x, y);
|
||||
//}
|
||||
}
|
||||
|
||||
public void setNativeCursor(Object handle) throws LWJGLException {
|
||||
Cursor awt_cursor = (Cursor)handle;
|
||||
if (frame != null)
|
||||
frame.setCursor(awt_cursor);
|
||||
if (native_mode) {
|
||||
currentNativeCursor = getCursorHandle(handle);
|
||||
if (Display.isCreated()) {
|
||||
if (mouseInsideWindow) MacOSXNativeMouse.setCursor(currentNativeCursor);
|
||||
else MacOSXNativeMouse.setCursor(0); // restore default cursor if outside Display
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getMinCursorSize() {
|
||||
return AWTUtil.getMinCursorSize();
|
||||
return 1;
|
||||
}
|
||||
|
||||
public int getMaxCursorSize() {
|
||||
return AWTUtil.getMaxCursorSize();
|
||||
// as there is no max cursor size limit on OS X
|
||||
// return the max cursor size as half the screen resolution
|
||||
DisplayMode dm = Display.getDesktopDisplayMode();
|
||||
return Math.min(dm.getWidth(), dm.getHeight()) / 2;
|
||||
}
|
||||
|
||||
/* Keyboard */
|
||||
public void createKeyboard() throws LWJGLException {
|
||||
this.keyboard_queue = new KeyboardEventQueue(canvas);
|
||||
keyboard_queue.register();
|
||||
if (native_mode) {
|
||||
this.keyboard = new MacOSXNativeKeyboard(window);
|
||||
keyboard.register();
|
||||
}
|
||||
else {
|
||||
this.keyboard_queue = new KeyboardEventQueue(canvas);
|
||||
keyboard_queue.register();
|
||||
}
|
||||
}
|
||||
|
||||
public void destroyKeyboard() {
|
||||
if (keyboard_queue != null)
|
||||
keyboard_queue.unregister();
|
||||
this.keyboard_queue = null;
|
||||
if (native_mode) {
|
||||
if (keyboard != null) {
|
||||
keyboard.unregister();
|
||||
}
|
||||
keyboard = null;
|
||||
}
|
||||
else {
|
||||
if (keyboard_queue != null) {
|
||||
keyboard_queue.unregister();
|
||||
}
|
||||
this.keyboard_queue = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void pollKeyboard(ByteBuffer keyDownBuffer) {
|
||||
keyboard_queue.poll(keyDownBuffer);
|
||||
if (native_mode) {
|
||||
keyboard.poll(keyDownBuffer);
|
||||
}
|
||||
else {
|
||||
keyboard_queue.poll(keyDownBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
public void readKeyboard(ByteBuffer buffer) {
|
||||
keyboard_queue.copyEvents(buffer);
|
||||
}
|
||||
|
||||
/* public int isStateKeySet(int key) {
|
||||
int awt_key;
|
||||
switch (key) {
|
||||
case Keyboard.KEY_CAPITAL:
|
||||
awt_key = KeyEvent.VK_CAPS_LOCK;
|
||||
break;
|
||||
case Keyboard.KEY_NUMLOCK:
|
||||
awt_key = KeyEvent.VK_NUM_LOCK;
|
||||
break;
|
||||
case Keyboard.KEY_SYSRQ:
|
||||
awt_key = KeyEvent.VK_SCROLL_LOCK;
|
||||
break;
|
||||
default:
|
||||
return Keyboard.STATE_UNKNOWN;
|
||||
if (native_mode) {
|
||||
keyboard.copyEvents(buffer);
|
||||
}
|
||||
try {
|
||||
boolean state = Toolkit.getDefaultToolkit().getLockingKeyState(awt_key);
|
||||
return state ? Keyboard.STATE_ON : Keyboard.STATE_OFF;
|
||||
} catch (Exception e) {
|
||||
LWJGLUtil.log("Failed to query key state: " + e);
|
||||
return Keyboard.STATE_UNKNOWN;
|
||||
else {
|
||||
keyboard_queue.copyEvents(buffer);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/** Native cursor handles */
|
||||
public Object createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException {
|
||||
return AWTUtil.createCursor(width, height, xHotspot, yHotspot, numImages, images, delays);
|
||||
if (native_mode) {
|
||||
long cursor = MacOSXNativeMouse.createCursor(width, height, xHotspot, yHotspot, numImages, images, delays);
|
||||
return cursor;
|
||||
}
|
||||
else {
|
||||
return AWTUtil.createCursor(width, height, xHotspot, yHotspot, numImages, images, delays);
|
||||
}
|
||||
}
|
||||
|
||||
public void destroyCursor(Object cursor_handle) {
|
||||
long handle = getCursorHandle(cursor_handle);
|
||||
|
||||
// reset current cursor if same
|
||||
if (currentNativeCursor == handle) {
|
||||
currentNativeCursor = 0;
|
||||
}
|
||||
|
||||
MacOSXNativeMouse.destroyCursor(handle);
|
||||
}
|
||||
|
||||
private static long getCursorHandle(Object cursor_handle) {
|
||||
return cursor_handle != null ? (Long)cursor_handle : 0;
|
||||
}
|
||||
|
||||
public int getPbufferCapabilities() {
|
||||
if (LWJGLUtil.isMacOSXEqualsOrBetterThan(10, 3))
|
||||
return Pbuffer.PBUFFER_SUPPORTED;
|
||||
else
|
||||
return 0;
|
||||
return Pbuffer.PBUFFER_SUPPORTED;
|
||||
}
|
||||
|
||||
public boolean isBufferLost(PeerInfo handle) {
|
||||
|
|
@ -465,7 +578,7 @@ final class MacOSXDisplay implements DisplayImplementation {
|
|||
* @return number of icons used.
|
||||
*/
|
||||
public int setIcon(ByteBuffer[] icons) {
|
||||
/* int size = 0;
|
||||
/*int size = 0;
|
||||
int biggest = -1;
|
||||
|
||||
for (int i=0;i<icons.length;i++) {
|
||||
|
|
@ -495,25 +608,37 @@ final class MacOSXDisplay implements DisplayImplementation {
|
|||
// Don't use any icon, since Mac OS X windows don't have window icons
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return nGetX(window);
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return nGetY(window);
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return frame.getWidth();
|
||||
return nGetWidth(window);
|
||||
}
|
||||
|
||||
|
||||
public int getHeight() {
|
||||
return frame.getHeight();
|
||||
return nGetHeight(window);
|
||||
}
|
||||
|
||||
public boolean isInsideWindow() {
|
||||
return true;
|
||||
}
|
||||
public boolean isInsideWindow() {
|
||||
return mouseInsideWindow;
|
||||
}
|
||||
|
||||
public void setResizable(boolean resizable) {
|
||||
frame.setResizable(resizable);
|
||||
public void setResizable(boolean resizable) {
|
||||
nSetResizable(window, resizable);
|
||||
}
|
||||
|
||||
public boolean wasResized() {
|
||||
return canvas_listener.wasResized();
|
||||
return nWasResized(window);
|
||||
}
|
||||
|
||||
public float getPixelScaleFactor() {
|
||||
return (enableHighDPI && !Display.isFullscreen()) ? scaleFactor : 1f;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,228 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2002-2008 LWJGL Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of 'LWJGL' nor the names of
|
||||
* its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.lwjgl.opengl;
|
||||
|
||||
/**
|
||||
* This is the Mac OS X AWT Frame. It contains thread safe
|
||||
* methods to manipulateit from non-AWT threads
|
||||
* @author elias_naur
|
||||
*/
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Frame;
|
||||
import java.awt.GraphicsDevice;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.Insets;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.ComponentListener;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.event.WindowListener;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedActionException;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
|
||||
import org.lwjgl.LWJGLException;
|
||||
|
||||
final class MacOSXFrame extends Frame implements WindowListener, ComponentListener {
|
||||
|
||||
private static final long serialVersionUID = -5823294716668988777L;
|
||||
|
||||
private final MacOSXGLCanvas canvas;
|
||||
private boolean close_requested;
|
||||
|
||||
/* States */
|
||||
private Rectangle bounds;
|
||||
private boolean active;
|
||||
private boolean minimized;
|
||||
private boolean should_warp_cursor;
|
||||
private boolean should_release_cursor;
|
||||
|
||||
MacOSXFrame(DisplayMode mode, final java.awt.DisplayMode requested_mode, boolean fullscreen, int x, int y) throws LWJGLException {
|
||||
setResizable(Display.isResizable());
|
||||
addWindowListener(this);
|
||||
addComponentListener(this);
|
||||
canvas = new MacOSXGLCanvas();
|
||||
canvas.setFocusTraversalKeysEnabled(false);
|
||||
add(canvas, BorderLayout.CENTER);
|
||||
boolean undecorated = Display.getPrivilegedBoolean("org.lwjgl.opengl.Window.undecorated");
|
||||
setUndecorated(fullscreen || undecorated);
|
||||
if ( fullscreen ) {
|
||||
try {
|
||||
AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
|
||||
public Object run() throws Exception {
|
||||
getDevice().setFullScreenWindow(MacOSXFrame.this);
|
||||
getDevice().setDisplayMode(requested_mode);
|
||||
java.awt.DisplayMode real_mode = getDevice().getDisplayMode();
|
||||
/** For some strange reason, the display mode is sometimes silently capped even though the mode is reported as supported */
|
||||
if ( requested_mode.getWidth() != real_mode.getWidth() || requested_mode.getHeight() != real_mode.getHeight() ) {
|
||||
getDevice().setFullScreenWindow(null);
|
||||
if (isDisplayable())
|
||||
dispose();
|
||||
throw new LWJGLException("AWT capped mode: requested mode = " + requested_mode.getWidth() + "x" + requested_mode.getHeight() +
|
||||
" but got " + real_mode.getWidth() + " " + real_mode.getHeight());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
} catch (PrivilegedActionException e) {
|
||||
throw new LWJGLException(e);
|
||||
}
|
||||
}
|
||||
pack();
|
||||
resize(x, y, mode.getWidth(), mode.getHeight());
|
||||
setVisible(true);
|
||||
requestFocus();
|
||||
canvas.requestFocus();
|
||||
updateBounds();
|
||||
}
|
||||
|
||||
public void resize(int x, int y, int width, int height) {
|
||||
Insets insets = getInsets();
|
||||
setBounds(x, y, width + insets.left + insets.right, height + insets.top + insets.bottom);
|
||||
}
|
||||
|
||||
public Rectangle syncGetBounds() {
|
||||
synchronized ( this ) {
|
||||
return bounds;
|
||||
}
|
||||
}
|
||||
|
||||
public void componentShown(ComponentEvent e) {
|
||||
}
|
||||
|
||||
public void componentHidden(ComponentEvent e) {
|
||||
}
|
||||
|
||||
private void updateBounds() {
|
||||
synchronized ( this ) {
|
||||
bounds = getBounds();
|
||||
}
|
||||
}
|
||||
|
||||
public void componentResized(ComponentEvent e) {
|
||||
updateBounds();
|
||||
}
|
||||
|
||||
public void componentMoved(ComponentEvent e) {
|
||||
updateBounds();
|
||||
}
|
||||
|
||||
public static GraphicsDevice getDevice() {
|
||||
GraphicsEnvironment g_env = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
GraphicsDevice device = g_env.getDefaultScreenDevice();
|
||||
return device;
|
||||
}
|
||||
|
||||
public void windowIconified(WindowEvent e) {
|
||||
synchronized ( this ) {
|
||||
minimized = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void windowDeiconified(WindowEvent e) {
|
||||
synchronized ( this ) {
|
||||
minimized = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void windowOpened(WindowEvent e) {
|
||||
}
|
||||
|
||||
public void windowClosed(WindowEvent e) {
|
||||
}
|
||||
|
||||
public void windowClosing(WindowEvent e) {
|
||||
synchronized ( this ) {
|
||||
close_requested = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void windowDeactivated(WindowEvent e) {
|
||||
synchronized ( this ) {
|
||||
active = false;
|
||||
should_release_cursor = true;
|
||||
should_warp_cursor = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void windowActivated(WindowEvent e) {
|
||||
synchronized ( this ) {
|
||||
active = true;
|
||||
should_warp_cursor = true;
|
||||
should_release_cursor = false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean syncIsCloseRequested() {
|
||||
boolean result;
|
||||
synchronized ( this ) {
|
||||
result = close_requested;
|
||||
close_requested = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean syncIsVisible() {
|
||||
synchronized ( this ) {
|
||||
return !minimized;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean syncIsActive() {
|
||||
synchronized ( this ) {
|
||||
return active;
|
||||
}
|
||||
}
|
||||
|
||||
public MacOSXGLCanvas getCanvas() {
|
||||
return canvas;
|
||||
}
|
||||
|
||||
public boolean syncShouldReleaseCursor() {
|
||||
boolean result;
|
||||
synchronized ( this ) {
|
||||
result = should_release_cursor;
|
||||
should_release_cursor = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean syncShouldWarpCursor() {
|
||||
boolean result;
|
||||
synchronized ( this ) {
|
||||
result = should_warp_cursor;
|
||||
should_warp_cursor = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
@ -96,13 +96,13 @@ final class MacOSXMouseEventQueue extends MouseEventQueue {
|
|||
// If we're going to warp the cursor position, we'll skip the next event to avoid bogus delta values
|
||||
skip_event = isGrabbed();
|
||||
}
|
||||
/* if (isGrabbed()) {
|
||||
if (isGrabbed()) {
|
||||
Rectangle bounds = getComponent().getBounds();
|
||||
Point location_on_screen = getComponent().getLocationOnScreen();
|
||||
int x = location_on_screen.x + bounds.width/2;
|
||||
int y = location_on_screen.y + bounds.height/2;
|
||||
nWarpCursor(x, y);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
private static native void getMouseDeltas(IntBuffer delta_buffer);
|
||||
|
|
@ -110,4 +110,4 @@ final class MacOSXMouseEventQueue extends MouseEventQueue {
|
|||
private static native void nWarpCursor(int x, int y);
|
||||
|
||||
static native void nGrabMouse(boolean grab);
|
||||
}
|
||||
}
|
||||
297
src/java/org/lwjgl/opengl/MacOSXNativeKeyboard.java
Normal file
297
src/java/org/lwjgl/opengl/MacOSXNativeKeyboard.java
Normal file
|
|
@ -0,0 +1,297 @@
|
|||
/*
|
||||
* Copyright (c) 2002-2008 LWJGL Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of 'LWJGL' nor the names of
|
||||
* its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.lwjgl.opengl;
|
||||
|
||||
/**
|
||||
* A native implementation of a LWJGL compatible Keyboard event queue.
|
||||
* @author elias_naur
|
||||
* @author mojang
|
||||
*/
|
||||
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.util.HashMap;
|
||||
import java.nio.Buffer;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
final class MacOSXNativeKeyboard extends EventQueue {
|
||||
private final byte[] key_states = new byte[Keyboard.KEYBOARD_SIZE];
|
||||
|
||||
/** Event scratch array */
|
||||
private final ByteBuffer event = ByteBuffer.allocate(Keyboard.EVENT_SIZE);
|
||||
|
||||
private ByteBuffer window_handle;
|
||||
|
||||
private boolean has_deferred_event;
|
||||
private long deferred_nanos;
|
||||
private int deferred_key_code;
|
||||
private byte deferred_key_state;
|
||||
private int deferred_character;
|
||||
|
||||
private HashMap<Short, Integer> nativeToLwjglMap;
|
||||
|
||||
MacOSXNativeKeyboard(ByteBuffer window_handle) {
|
||||
super(Keyboard.EVENT_SIZE);
|
||||
nativeToLwjglMap = new HashMap<Short, Integer>();
|
||||
initKeyboardMappings();
|
||||
this.window_handle = window_handle;
|
||||
}
|
||||
|
||||
private native void nRegisterKeyListener(ByteBuffer window_handle);
|
||||
|
||||
private native void nUnregisterKeyListener(ByteBuffer window_handle);
|
||||
|
||||
// These are from: <HIToolbox/Events.h>
|
||||
private void initKeyboardMappings() {
|
||||
nativeToLwjglMap.put((short)0x1D, Keyboard.KEY_0);
|
||||
nativeToLwjglMap.put((short)0x12, Keyboard.KEY_1);
|
||||
nativeToLwjglMap.put((short)0x13, Keyboard.KEY_2);
|
||||
nativeToLwjglMap.put((short)0x14, Keyboard.KEY_3);
|
||||
nativeToLwjglMap.put((short)0x15, Keyboard.KEY_4);
|
||||
nativeToLwjglMap.put((short)0x17, Keyboard.KEY_5);
|
||||
nativeToLwjglMap.put((short)0x16, Keyboard.KEY_6);
|
||||
nativeToLwjglMap.put((short)0x1A, Keyboard.KEY_7);
|
||||
nativeToLwjglMap.put((short)0x1C, Keyboard.KEY_8);
|
||||
nativeToLwjglMap.put((short)0x19, Keyboard.KEY_9);
|
||||
nativeToLwjglMap.put((short)0x00, Keyboard.KEY_A);
|
||||
nativeToLwjglMap.put((short)0x0B, Keyboard.KEY_B);
|
||||
nativeToLwjglMap.put((short)0x08, Keyboard.KEY_C);
|
||||
nativeToLwjglMap.put((short)0x02, Keyboard.KEY_D);
|
||||
nativeToLwjglMap.put((short)0x0E, Keyboard.KEY_E);
|
||||
nativeToLwjglMap.put((short)0x03, Keyboard.KEY_F);
|
||||
nativeToLwjglMap.put((short)0x05, Keyboard.KEY_G);
|
||||
nativeToLwjglMap.put((short)0x04, Keyboard.KEY_H);
|
||||
nativeToLwjglMap.put((short)0x22, Keyboard.KEY_I);
|
||||
nativeToLwjglMap.put((short)0x26, Keyboard.KEY_J);
|
||||
nativeToLwjglMap.put((short)0x28, Keyboard.KEY_K);
|
||||
nativeToLwjglMap.put((short)0x25, Keyboard.KEY_L);
|
||||
nativeToLwjglMap.put((short)0x2E, Keyboard.KEY_M);
|
||||
nativeToLwjglMap.put((short)0x2D, Keyboard.KEY_N);
|
||||
nativeToLwjglMap.put((short)0x1F, Keyboard.KEY_O);
|
||||
nativeToLwjglMap.put((short)0x23, Keyboard.KEY_P);
|
||||
nativeToLwjglMap.put((short)0x0C, Keyboard.KEY_Q);
|
||||
nativeToLwjglMap.put((short)0x0F, Keyboard.KEY_R);
|
||||
nativeToLwjglMap.put((short)0x01, Keyboard.KEY_S);
|
||||
nativeToLwjglMap.put((short)0x11, Keyboard.KEY_T);
|
||||
nativeToLwjglMap.put((short)0x20, Keyboard.KEY_U);
|
||||
nativeToLwjglMap.put((short)0x09, Keyboard.KEY_V);
|
||||
nativeToLwjglMap.put((short)0x0D, Keyboard.KEY_W);
|
||||
nativeToLwjglMap.put((short)0x07, Keyboard.KEY_X);
|
||||
nativeToLwjglMap.put((short)0x10, Keyboard.KEY_Y);
|
||||
nativeToLwjglMap.put((short)0x06, Keyboard.KEY_Z);
|
||||
|
||||
nativeToLwjglMap.put((short)0x2A, Keyboard.KEY_BACKSLASH);
|
||||
nativeToLwjglMap.put((short)0x2B, Keyboard.KEY_COMMA);
|
||||
nativeToLwjglMap.put((short)0x18, Keyboard.KEY_EQUALS);
|
||||
nativeToLwjglMap.put((short)0x21, Keyboard.KEY_LBRACKET);
|
||||
nativeToLwjglMap.put((short)0x1B, Keyboard.KEY_MINUS);
|
||||
nativeToLwjglMap.put((short)0x27, Keyboard.KEY_APOSTROPHE);
|
||||
nativeToLwjglMap.put((short)0x1E, Keyboard.KEY_RBRACKET);
|
||||
nativeToLwjglMap.put((short)0x29, Keyboard.KEY_SEMICOLON);
|
||||
nativeToLwjglMap.put((short)0x2C, Keyboard.KEY_SLASH);
|
||||
nativeToLwjglMap.put((short)0x2F, Keyboard.KEY_PERIOD);
|
||||
nativeToLwjglMap.put((short)0x32, Keyboard.KEY_GRAVE);
|
||||
|
||||
nativeToLwjglMap.put((short)0x41, Keyboard.KEY_DECIMAL);
|
||||
nativeToLwjglMap.put((short)0x43, Keyboard.KEY_MULTIPLY);
|
||||
nativeToLwjglMap.put((short)0x45, Keyboard.KEY_ADD);
|
||||
nativeToLwjglMap.put((short)0x47, Keyboard.KEY_CLEAR);
|
||||
nativeToLwjglMap.put((short)0x4B, Keyboard.KEY_DIVIDE);
|
||||
nativeToLwjglMap.put((short)0x4C, Keyboard.KEY_NUMPADENTER);
|
||||
nativeToLwjglMap.put((short)0x4E, Keyboard.KEY_SUBTRACT);
|
||||
nativeToLwjglMap.put((short)0x51, Keyboard.KEY_NUMPADEQUALS);
|
||||
|
||||
nativeToLwjglMap.put((short)0x52, Keyboard.KEY_NUMPAD0);
|
||||
nativeToLwjglMap.put((short)0x53, Keyboard.KEY_NUMPAD1);
|
||||
nativeToLwjglMap.put((short)0x54, Keyboard.KEY_NUMPAD2);
|
||||
nativeToLwjglMap.put((short)0x55, Keyboard.KEY_NUMPAD3);
|
||||
nativeToLwjglMap.put((short)0x56, Keyboard.KEY_NUMPAD4);
|
||||
nativeToLwjglMap.put((short)0x57, Keyboard.KEY_NUMPAD5);
|
||||
nativeToLwjglMap.put((short)0x58, Keyboard.KEY_NUMPAD6);
|
||||
nativeToLwjglMap.put((short)0x59, Keyboard.KEY_NUMPAD7);
|
||||
nativeToLwjglMap.put((short)0x5B, Keyboard.KEY_NUMPAD8);
|
||||
nativeToLwjglMap.put((short)0x5C, Keyboard.KEY_NUMPAD9);
|
||||
|
||||
|
||||
nativeToLwjglMap.put((short)0x24, Keyboard.KEY_RETURN);
|
||||
nativeToLwjglMap.put((short)0x30, Keyboard.KEY_TAB);
|
||||
nativeToLwjglMap.put((short)0x31, Keyboard.KEY_SPACE);
|
||||
nativeToLwjglMap.put((short)0x33, Keyboard.KEY_BACK);
|
||||
nativeToLwjglMap.put((short)0x35, Keyboard.KEY_ESCAPE);
|
||||
nativeToLwjglMap.put((short)0x36, Keyboard.KEY_RMETA); // not in Events.h - works on MBP
|
||||
nativeToLwjglMap.put((short)0x37, Keyboard.KEY_LMETA);
|
||||
nativeToLwjglMap.put((short)0x38, Keyboard.KEY_LSHIFT);
|
||||
nativeToLwjglMap.put((short)0x39, Keyboard.KEY_CAPITAL);
|
||||
nativeToLwjglMap.put((short)0x3A, Keyboard.KEY_LMENU);
|
||||
nativeToLwjglMap.put((short)0x3B, Keyboard.KEY_LCONTROL);
|
||||
nativeToLwjglMap.put((short)0x3C, Keyboard.KEY_RSHIFT);
|
||||
nativeToLwjglMap.put((short)0x3D, Keyboard.KEY_RMENU);
|
||||
nativeToLwjglMap.put((short)0x3E, Keyboard.KEY_RCONTROL);
|
||||
|
||||
nativeToLwjglMap.put((short)0x3F, Keyboard.KEY_FUNCTION);
|
||||
nativeToLwjglMap.put((short)0x77, Keyboard.KEY_END);
|
||||
|
||||
nativeToLwjglMap.put((short)0x7A, Keyboard.KEY_F1);
|
||||
nativeToLwjglMap.put((short)0x78, Keyboard.KEY_F2);
|
||||
nativeToLwjglMap.put((short)0x63, Keyboard.KEY_F3);
|
||||
nativeToLwjglMap.put((short)0x76, Keyboard.KEY_F4);
|
||||
nativeToLwjglMap.put((short)0x60, Keyboard.KEY_F5);
|
||||
nativeToLwjglMap.put((short)0x61, Keyboard.KEY_F6);
|
||||
nativeToLwjglMap.put((short)0x62, Keyboard.KEY_F7);
|
||||
nativeToLwjglMap.put((short)0x64, Keyboard.KEY_F8);
|
||||
nativeToLwjglMap.put((short)0x65, Keyboard.KEY_F9);
|
||||
nativeToLwjglMap.put((short)0x6D, Keyboard.KEY_F10);
|
||||
nativeToLwjglMap.put((short)0x67, Keyboard.KEY_F11);
|
||||
nativeToLwjglMap.put((short)0x6F, Keyboard.KEY_F12);
|
||||
nativeToLwjglMap.put((short)0x69, Keyboard.KEY_F13);
|
||||
nativeToLwjglMap.put((short)0x6B, Keyboard.KEY_F14);
|
||||
nativeToLwjglMap.put((short)0x71, Keyboard.KEY_F15);
|
||||
nativeToLwjglMap.put((short)0x6A, Keyboard.KEY_F16);
|
||||
nativeToLwjglMap.put((short)0x40, Keyboard.KEY_F17);
|
||||
nativeToLwjglMap.put((short)0x4F, Keyboard.KEY_F18);
|
||||
nativeToLwjglMap.put((short)0x50, Keyboard.KEY_F19);
|
||||
// nativeToLwjglMap.put((short)0x5A, Keyboard.KEY_F20);
|
||||
|
||||
nativeToLwjglMap.put((short)0x75, Keyboard.KEY_DELETE);
|
||||
nativeToLwjglMap.put((short)0x72, Keyboard.KEY_INSERT); // 'Help' in Events.h
|
||||
nativeToLwjglMap.put((short)0x73, Keyboard.KEY_HOME);
|
||||
// nativeToLwjglMap.put((short)0xA4, Keyboard.KEY_MUTE);
|
||||
nativeToLwjglMap.put((short)0x79, Keyboard.KEY_NEXT);
|
||||
nativeToLwjglMap.put((short)0x74, Keyboard.KEY_PRIOR);
|
||||
// nativeToLwjglMap.put((short)0x49, Keyboard.KEY_VOLUMEDOWN);
|
||||
// nativeToLwjglMap.put((short)0x48, Keyboard.KEY_VOLUMEUP);
|
||||
nativeToLwjglMap.put((short)0x7B, Keyboard.KEY_LEFT);
|
||||
nativeToLwjglMap.put((short)0x7C, Keyboard.KEY_RIGHT);
|
||||
nativeToLwjglMap.put((short)0x7D, Keyboard.KEY_DOWN);
|
||||
nativeToLwjglMap.put((short)0x7E, Keyboard.KEY_UP);
|
||||
|
||||
nativeToLwjglMap.put((short)0x0A, Keyboard.KEY_SECTION);
|
||||
|
||||
nativeToLwjglMap.put((short)0x6E, Keyboard.KEY_APPS); // not in Events.h
|
||||
nativeToLwjglMap.put((short)0x129, Keyboard.KEY_COLON); // not in Events.h -- do we need it?
|
||||
}
|
||||
|
||||
public void register() {
|
||||
nRegisterKeyListener(window_handle);
|
||||
}
|
||||
|
||||
public void unregister() {
|
||||
nUnregisterKeyListener(window_handle);
|
||||
}
|
||||
|
||||
public void putKeyboardEvent(int key_code, byte state, int character, long nanos, boolean repeat) {
|
||||
((Buffer)event).clear();
|
||||
event.putInt(key_code).put(state).putInt(character).putLong(nanos).put(repeat ? (byte)1 : (byte)0);
|
||||
((Buffer)event).flip();
|
||||
putEvent(event);
|
||||
}
|
||||
|
||||
public synchronized void poll(ByteBuffer key_down_buffer) {
|
||||
flushDeferredEvent();
|
||||
int old_position = key_down_buffer.position();
|
||||
key_down_buffer.put(key_states);
|
||||
((Buffer)key_down_buffer).position(old_position);
|
||||
}
|
||||
|
||||
public synchronized void copyEvents(ByteBuffer dest) {
|
||||
flushDeferredEvent();
|
||||
super.copyEvents(dest);
|
||||
}
|
||||
|
||||
private synchronized void handleKey(int key_code, byte state, int character, long nanos) {
|
||||
if (character == KeyEvent.CHAR_UNDEFINED)
|
||||
character = Keyboard.CHAR_NONE;
|
||||
if (state == 1) {
|
||||
boolean repeat = false;
|
||||
if (has_deferred_event) {
|
||||
if ((nanos == deferred_nanos && deferred_key_code == key_code)) {
|
||||
has_deferred_event = false;
|
||||
repeat = true; // Repeat event
|
||||
} else
|
||||
flushDeferredEvent();
|
||||
}
|
||||
putKeyEvent(key_code, state, character, nanos, repeat);
|
||||
} else {
|
||||
flushDeferredEvent();
|
||||
has_deferred_event = true;
|
||||
deferred_nanos = nanos;
|
||||
deferred_key_code = key_code;
|
||||
deferred_key_state = state;
|
||||
deferred_character = character;
|
||||
}
|
||||
}
|
||||
|
||||
private void flushDeferredEvent() {
|
||||
if (has_deferred_event) {
|
||||
putKeyEvent(deferred_key_code, deferred_key_state, deferred_character, deferred_nanos, false);
|
||||
has_deferred_event = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void putKeyEvent(int key_code, byte state, int character, long nanos, boolean repeat) {
|
||||
/* Ignore repeating presses */
|
||||
int mapped_code = getMappedKeyCode((short)key_code);
|
||||
if (mapped_code < 0) {
|
||||
System.out.println("Unrecognized keycode: " + key_code);
|
||||
/* Unrecognized / unmapped code, do nothing */
|
||||
return;
|
||||
}
|
||||
if ( key_states[mapped_code] == state )
|
||||
repeat = true;
|
||||
key_states[mapped_code] = state;
|
||||
int key_int_char = character & 0xffff;
|
||||
putKeyboardEvent(mapped_code, state, key_int_char, nanos, repeat);
|
||||
}
|
||||
|
||||
private int getMappedKeyCode(short key_code) {
|
||||
if (nativeToLwjglMap.containsKey(key_code)) {
|
||||
return nativeToLwjglMap.get(key_code);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void keyPressed(int key_code, String chars, long nanos) {
|
||||
// use only first character of chars returned for key press
|
||||
int character = (chars == null || chars.length() == 0) ? 0 : (int)chars.charAt(0);
|
||||
handleKey(key_code, (byte)1, character, nanos);
|
||||
}
|
||||
|
||||
public void keyReleased(int key_code, String chars, long nanos) {
|
||||
// use only first character of chars returned for key release
|
||||
int character = (chars == null || chars.length() == 0) ? 0 : (int)chars.charAt(0);
|
||||
handleKey(key_code, (byte)0, character, nanos);
|
||||
}
|
||||
|
||||
public void keyTyped(KeyEvent e) {
|
||||
}
|
||||
}
|
||||
229
src/java/org/lwjgl/opengl/MacOSXNativeMouse.java
Normal file
229
src/java/org/lwjgl/opengl/MacOSXNativeMouse.java
Normal file
|
|
@ -0,0 +1,229 @@
|
|||
/*
|
||||
* Copyright (c) 2002-2008 LWJGL Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of 'LWJGL' nor the names of
|
||||
* its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.lwjgl.opengl;
|
||||
|
||||
/**
|
||||
* A Cocoa implementation of a LWJGL compatible Mouse.
|
||||
* @author mojang
|
||||
* @author kappaOne <one.kappa@gmail.com>
|
||||
*/
|
||||
|
||||
import java.nio.Buffer;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.LWJGLException;
|
||||
|
||||
import java.lang.reflect.*;
|
||||
import java.lang.Integer;
|
||||
import java.lang.Long;
|
||||
|
||||
import org.lwjgl.BufferUtils;
|
||||
|
||||
final class MacOSXNativeMouse extends EventQueue {
|
||||
private static final int WHEEL_SCALE = 120;
|
||||
private static final int NUM_BUTTONS = 3;
|
||||
|
||||
private ByteBuffer window_handle;
|
||||
private MacOSXDisplay display;
|
||||
|
||||
private boolean grabbed;
|
||||
|
||||
/** The accumulated mouse deltas returned by poll() */
|
||||
private float accum_dx;
|
||||
private float accum_dy;
|
||||
private int accum_dz;
|
||||
|
||||
/** The last mouse position */
|
||||
private float last_x;
|
||||
private float last_y;
|
||||
|
||||
/** Saved control key state for ctrl-click right button emulation */
|
||||
private boolean saved_control_state;
|
||||
|
||||
private final ByteBuffer event = ByteBuffer.allocate(Mouse.EVENT_SIZE);
|
||||
private IntBuffer delta_buffer = BufferUtils.createIntBuffer(2);
|
||||
private int skip_event;
|
||||
|
||||
private final byte[] buttons = new byte[NUM_BUTTONS];
|
||||
|
||||
MacOSXNativeMouse(MacOSXDisplay display, ByteBuffer window_handle) {
|
||||
super(Mouse.EVENT_SIZE);
|
||||
this.display = display;
|
||||
this.window_handle = window_handle;
|
||||
}
|
||||
|
||||
private native void nSetCursorPosition(ByteBuffer window_handle, int x, int y);
|
||||
|
||||
public static native void nGrabMouse(boolean grab);
|
||||
|
||||
private native void nRegisterMouseListener(ByteBuffer window_handle);
|
||||
|
||||
private native void nUnregisterMouseListener(ByteBuffer window_handle);
|
||||
|
||||
private static native long nCreateCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, int images_offset, IntBuffer delays, int delays_offset) throws LWJGLException;
|
||||
|
||||
private static native void nDestroyCursor(long cursor_handle);
|
||||
|
||||
private static native void nSetCursor(long cursor_handle) throws LWJGLException;
|
||||
|
||||
public synchronized void register() {
|
||||
nRegisterMouseListener(window_handle);
|
||||
}
|
||||
|
||||
public static long createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException {
|
||||
try {
|
||||
return nCreateCursor(width, height, xHotspot, yHotspot, numImages, images, images.position(), delays, delays != null ? delays.position() : -1);
|
||||
} catch (LWJGLException e) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
public static void destroyCursor(long cursor_handle) {
|
||||
nDestroyCursor(cursor_handle);
|
||||
}
|
||||
|
||||
public static void setCursor(long cursor_handle) throws LWJGLException {
|
||||
try {
|
||||
nSetCursor(cursor_handle);
|
||||
} catch (LWJGLException e) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void setCursorPosition(int x, int y) {
|
||||
nSetCursorPosition(window_handle, x, y);
|
||||
}
|
||||
|
||||
public synchronized void unregister() {
|
||||
nUnregisterMouseListener(window_handle);
|
||||
}
|
||||
|
||||
public synchronized void setGrabbed(boolean grabbed) {
|
||||
this.grabbed = grabbed;
|
||||
nGrabMouse(grabbed);
|
||||
skip_event = 1;
|
||||
accum_dx = accum_dy = 0;
|
||||
}
|
||||
|
||||
public synchronized boolean isGrabbed() {
|
||||
return grabbed;
|
||||
}
|
||||
|
||||
protected void resetCursorToCenter() {
|
||||
clearEvents();
|
||||
accum_dx = accum_dy = 0;
|
||||
if (display != null) {
|
||||
last_x = display.getWidth() / 2;
|
||||
last_y = display.getHeight() / 2;
|
||||
}
|
||||
}
|
||||
|
||||
private void putMouseEvent(byte button, byte state, int dz, long nanos) {
|
||||
if (grabbed)
|
||||
putMouseEventWithCoords(button, state, 0, 0, dz, nanos);
|
||||
else
|
||||
putMouseEventWithCoords(button, state, (int)last_x, (int)last_y, dz, nanos);
|
||||
}
|
||||
|
||||
protected void putMouseEventWithCoords(byte button, byte state, int coord1, int coord2, int dz, long nanos) {
|
||||
((Buffer)event).clear();
|
||||
event.put(button).put(state).putInt(coord1).putInt(coord2).putInt(dz).putLong(nanos);
|
||||
((Buffer)event).flip();
|
||||
putEvent(event);
|
||||
}
|
||||
|
||||
public synchronized void poll(IntBuffer coord_buffer, ByteBuffer buttons_buffer) {
|
||||
if (grabbed) {
|
||||
coord_buffer.put(0, (int)accum_dx);
|
||||
coord_buffer.put(1, (int)accum_dy);
|
||||
} else {
|
||||
coord_buffer.put(0, (int)last_x);
|
||||
coord_buffer.put(1, (int)last_y);
|
||||
}
|
||||
coord_buffer.put(2, accum_dz);
|
||||
accum_dx = accum_dy = accum_dz = 0;
|
||||
int old_position = buttons_buffer.position();
|
||||
buttons_buffer.put(buttons, 0, buttons.length);
|
||||
((Buffer)buttons_buffer).position(old_position);
|
||||
}
|
||||
|
||||
private void setCursorPos(float x, float y, long nanos) {
|
||||
if ( grabbed )
|
||||
return;
|
||||
float dx = x - last_x;
|
||||
float dy = y - last_y;
|
||||
addDelta(dx, dy);
|
||||
last_x = x;
|
||||
last_y = y;
|
||||
putMouseEventWithCoords((byte)-1, (byte)0, (int)x, (int)y, 0, nanos);
|
||||
}
|
||||
|
||||
protected void addDelta(float dx, float dy) {
|
||||
accum_dx += dx;
|
||||
accum_dy += -dy;
|
||||
}
|
||||
|
||||
public synchronized void setButton(int button, int state, long nanos) {
|
||||
buttons[button] = (byte)state;
|
||||
putMouseEvent((byte)button, (byte)state, 0, nanos);
|
||||
}
|
||||
|
||||
public synchronized void mouseMoved(float x, float y, float dx, float dy, float dz, long nanos) {
|
||||
if (skip_event > 0) {
|
||||
skip_event--;
|
||||
if (skip_event == 0) {
|
||||
last_x = x;
|
||||
last_y = y;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if ( dz != 0 ) { // if scroll wheel event
|
||||
// if no vertical wheel events, then map the horizontal wheel event to it
|
||||
if (dy == 0) dy = dx;
|
||||
|
||||
int wheel_amount = (int)(dy * WHEEL_SCALE);
|
||||
accum_dz += wheel_amount;
|
||||
putMouseEvent((byte)-1, (byte)0, wheel_amount, nanos);
|
||||
}
|
||||
else if (grabbed) {
|
||||
if ( dx != 0 || dy != 0 ) {
|
||||
putMouseEventWithCoords((byte)-1, (byte)0, (int)dx, (int)-dy, 0, nanos);
|
||||
addDelta(dx, dy);
|
||||
}
|
||||
} else {
|
||||
setCursorPos(x, y, nanos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -45,12 +45,10 @@ import org.lwjgl.LWJGLUtil;
|
|||
abstract class MacOSXPeerInfo extends PeerInfo {
|
||||
MacOSXPeerInfo(PixelFormat pixel_format, ContextAttribs attribs, boolean use_display_bpp, boolean support_window, boolean support_pbuffer, boolean double_buffered) throws LWJGLException {
|
||||
super(createHandle());
|
||||
if (pixel_format.isFloatingPoint() && !LWJGLUtil.isMacOSXEqualsOrBetterThan(10, 4))
|
||||
throw new LWJGLException("Floating point pixel format requested, but it requires MacOS X 10.4 or newer");
|
||||
|
||||
boolean gl32 = attribs != null && attribs.getMajorVersion() == 3 && attribs.getMinorVersion() == 2 && attribs.isProfileCore();
|
||||
boolean gl32 = attribs != null && (3 < attribs.getMajorVersion() || (attribs.getMajorVersion() == 3 && 2 <= attribs.getMinorVersion())) && attribs.isProfileCore();
|
||||
if ( gl32 && !LWJGLUtil.isMacOSXEqualsOrBetterThan(10, 7) )
|
||||
throw new LWJGLException("OpenGL 3.2 requested, but it requires MacOS X 10.7 or newer");
|
||||
throw new LWJGLException("OpenGL 3.2+ requested, but it requires MacOS X 10.7 or newer");
|
||||
|
||||
choosePixelFormat(pixel_format, gl32, use_display_bpp, support_window, support_pbuffer, double_buffered);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,15 +81,19 @@ class MouseEventQueue extends EventQueue implements MouseListener, MouseMotionLi
|
|||
|
||||
public synchronized void register() {
|
||||
resetCursorToCenter();
|
||||
component.addMouseListener(this);
|
||||
component.addMouseMotionListener(this);
|
||||
component.addMouseWheelListener(this);
|
||||
if (component != null) {
|
||||
component.addMouseListener(this);
|
||||
component.addMouseMotionListener(this);
|
||||
component.addMouseWheelListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void unregister() {
|
||||
component.removeMouseListener(this);
|
||||
component.removeMouseMotionListener(this);
|
||||
component.removeMouseWheelListener(this);
|
||||
if (component != null) {
|
||||
component.removeMouseListener(this);
|
||||
component.removeMouseMotionListener(this);
|
||||
component.removeMouseWheelListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
protected Component getComponent() {
|
||||
|
|
@ -105,18 +109,23 @@ class MouseEventQueue extends EventQueue implements MouseListener, MouseMotionLi
|
|||
return grabbed;
|
||||
}
|
||||
|
||||
private int transformY(int y) {
|
||||
return component.getHeight() - 1 - y;
|
||||
protected int transformY(int y) {
|
||||
if (component != null) {
|
||||
return component.getHeight() - 1 - y;
|
||||
}
|
||||
return y;
|
||||
}
|
||||
|
||||
protected void resetCursorToCenter() {
|
||||
clearEvents();
|
||||
accum_dx = accum_dy = 0;
|
||||
Point cursor_location = AWTUtil.getCursorPosition(component);
|
||||
if (cursor_location != null) {
|
||||
last_x = cursor_location.x;
|
||||
last_y = cursor_location.y;
|
||||
}
|
||||
if (component != null) {
|
||||
Point cursor_location = AWTUtil.getCursorPosition(component);
|
||||
if (cursor_location != null) {
|
||||
last_x = cursor_location.x;
|
||||
last_y = cursor_location.y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void putMouseEvent(byte button, byte state, int dz, long nanos) {
|
||||
|
|
|
|||
175
src/java/org/lwjgl/opengl/Sync.java
Normal file
175
src/java/org/lwjgl/opengl/Sync.java
Normal file
|
|
@ -0,0 +1,175 @@
|
|||
/*
|
||||
* Copyright (c) 2002-2012 LWJGL Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of 'LWJGL' nor the names of
|
||||
* its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.lwjgl.opengl;
|
||||
|
||||
import org.lwjgl.Sys;
|
||||
|
||||
/**
|
||||
* A highly accurate sync method that continually adapts to the system
|
||||
* it runs on to provide reliable results.
|
||||
*
|
||||
* @author Riven
|
||||
* @author kappaOne
|
||||
*/
|
||||
class Sync {
|
||||
|
||||
/** number of nano seconds in a second */
|
||||
private static final long NANOS_IN_SECOND = 1000L * 1000L * 1000L;
|
||||
|
||||
/** The time to sleep/yield until the next frame */
|
||||
private static long nextFrame = 0;
|
||||
|
||||
/** whether the initialisation code has run */
|
||||
private static boolean initialised = false;
|
||||
|
||||
/** for calculating the averages the previous sleep/yield times are stored */
|
||||
private static RunningAvg sleepDurations = new RunningAvg(10);
|
||||
private static RunningAvg yieldDurations = new RunningAvg(10);
|
||||
|
||||
|
||||
/**
|
||||
* An accurate sync method that will attempt to run at a constant frame rate.
|
||||
* It should be called once every frame.
|
||||
*
|
||||
* @param fps - the desired frame rate, in frames per second
|
||||
*/
|
||||
public static void sync(int fps) {
|
||||
if (fps <= 0) return;
|
||||
if (!initialised) initialise();
|
||||
|
||||
try {
|
||||
// sleep until the average sleep time is greater than the time remaining till nextFrame
|
||||
for (long t0 = getTime(), t1; (nextFrame - t0) > sleepDurations.avg(); t0 = t1) {
|
||||
Thread.sleep(1);
|
||||
sleepDurations.add((t1 = getTime()) - t0); // update average sleep time
|
||||
}
|
||||
|
||||
// slowly dampen sleep average if too high to avoid yielding too much
|
||||
sleepDurations.dampenForLowResTicker();
|
||||
|
||||
// yield until the average yield time is greater than the time remaining till nextFrame
|
||||
for (long t0 = getTime(), t1; (nextFrame - t0) > yieldDurations.avg(); t0 = t1) {
|
||||
Thread.yield();
|
||||
yieldDurations.add((t1 = getTime()) - t0); // update average yield time
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
|
||||
}
|
||||
|
||||
// schedule next frame, drop frame(s) if already too late for next frame
|
||||
nextFrame = Math.max(nextFrame + NANOS_IN_SECOND / fps, getTime());
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will initialise the sync method by setting initial
|
||||
* values for sleepDurations/yieldDurations and nextFrame.
|
||||
*
|
||||
* If running on windows it will start the sleep timer fix.
|
||||
*/
|
||||
private static void initialise() {
|
||||
initialised = true;
|
||||
|
||||
sleepDurations.init(1000 * 1000);
|
||||
yieldDurations.init((int) (-(getTime() - getTime()) * 1.333));
|
||||
|
||||
nextFrame = getTime();
|
||||
|
||||
String osName = System.getProperty("os.name");
|
||||
|
||||
if (osName.startsWith("Win")) {
|
||||
// On windows the sleep functions can be highly inaccurate by
|
||||
// over 10ms making in unusable. However it can be forced to
|
||||
// be a bit more accurate by running a separate sleeping daemon
|
||||
// thread.
|
||||
Thread timerAccuracyThread = new Thread(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
Thread.sleep(Long.MAX_VALUE);
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
});
|
||||
|
||||
timerAccuracyThread.setName("LWJGL Timer");
|
||||
timerAccuracyThread.setDaemon(true);
|
||||
timerAccuracyThread.start();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the system time in nano seconds
|
||||
*
|
||||
* @return will return the current time in nano's
|
||||
*/
|
||||
private static long getTime() {
|
||||
return (Sys.getTime() * NANOS_IN_SECOND) / Sys.getTimerResolution();
|
||||
}
|
||||
|
||||
private static class RunningAvg {
|
||||
private final long[] slots;
|
||||
private int offset;
|
||||
|
||||
private static final long DAMPEN_THRESHOLD = 10 * 1000L * 1000L; // 10ms
|
||||
private static final float DAMPEN_FACTOR = 0.9f; // don't change: 0.9f is exactly right!
|
||||
|
||||
public RunningAvg(int slotCount) {
|
||||
this.slots = new long[slotCount];
|
||||
this.offset = 0;
|
||||
}
|
||||
|
||||
public void init(long value) {
|
||||
while (this.offset < this.slots.length) {
|
||||
this.slots[this.offset++] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public void add(long value) {
|
||||
this.slots[this.offset++ % this.slots.length] = value;
|
||||
this.offset %= this.slots.length;
|
||||
}
|
||||
|
||||
public long avg() {
|
||||
long sum = 0;
|
||||
for (int i = 0; i < this.slots.length; i++) {
|
||||
sum += this.slots[i];
|
||||
}
|
||||
return sum / this.slots.length;
|
||||
}
|
||||
|
||||
public void dampenForLowResTicker() {
|
||||
if (this.avg() > DAMPEN_THRESHOLD) {
|
||||
for (int i = 0; i < this.slots.length; i++) {
|
||||
this.slots[i] *= DAMPEN_FACTOR;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -38,8 +38,12 @@ package org.lwjgl.opengl;
|
|||
* @author elias_naur
|
||||
*/
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.FocusAdapter;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.lang.reflect.Method;
|
||||
import java.nio.*;
|
||||
import java.awt.Canvas;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.lwjgl.LWJGLException;
|
||||
import org.lwjgl.LWJGLUtil;
|
||||
|
|
@ -49,9 +53,13 @@ import org.lwjgl.input.Cursor;
|
|||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengles.EGL;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
final class WindowsDisplay implements DisplayImplementation {
|
||||
private static final int GAMMA_LENGTH = 256;
|
||||
|
||||
private static final int WM_WINDOWPOSCHANGED = 0x0047;
|
||||
private static final int WM_MOVE = 0x0003;
|
||||
private static final int WM_CANCELMODE = 0x001F;
|
||||
private static final int WM_MOUSEMOVE = 0x0200;
|
||||
private static final int WM_LBUTTONDOWN = 0x0201;
|
||||
|
|
@ -63,6 +71,9 @@ final class WindowsDisplay implements DisplayImplementation {
|
|||
private static final int WM_MBUTTONDOWN = 0x0207;
|
||||
private static final int WM_MBUTTONUP = 0x0208;
|
||||
private static final int WM_MBUTTONDBLCLK = 0x0209;
|
||||
private static final int WM_XBUTTONDOWN = 0x020B;
|
||||
private static final int WM_XBUTTONUP = 0x020C;
|
||||
private static final int WM_XBUTTONDBLCLK = 0x020D;
|
||||
private static final int WM_MOUSEWHEEL = 0x020A;
|
||||
private static final int WM_CAPTURECHANGED = 0x0215;
|
||||
private static final int WM_MOUSELEAVE = 0x02A3;
|
||||
|
|
@ -75,7 +86,10 @@ final class WindowsDisplay implements DisplayImplementation {
|
|||
private static final int WM_SYSKEYDOWN = 260;
|
||||
private static final int WM_SYSCHAR = 262;
|
||||
private static final int WM_CHAR = 258;
|
||||
private static final int WM_GETICON = 0x007F;
|
||||
private static final int WM_SETICON = 0x0080;
|
||||
private static final int WM_SETCURSOR = 0x0020;
|
||||
private static final int WM_MOUSEACTIVATE = 0x0021;
|
||||
|
||||
private static final int WM_QUIT = 0x0012;
|
||||
private static final int WM_SYSCOMMAND = 0x0112;
|
||||
|
|
@ -121,6 +135,7 @@ final class WindowsDisplay implements DisplayImplementation {
|
|||
private static final int SW_SHOWMINNOACTIVE = 7;
|
||||
private static final int SW_SHOWDEFAULT = 10;
|
||||
private static final int SW_RESTORE = 9;
|
||||
private static final int SW_MAXIMIZE = 3;
|
||||
|
||||
private static final int ICON_SMALL = 0;
|
||||
private static final int ICON_BIG = 1;
|
||||
|
|
@ -142,16 +157,28 @@ final class WindowsDisplay implements DisplayImplementation {
|
|||
private static final int GWL_EXSTYLE = -20;
|
||||
|
||||
private static final int WS_THICKFRAME = 0x00040000;
|
||||
private static final int WS_MAXIMIZEBOX = 0x00010000;
|
||||
|
||||
private static final int HTCLIENT = 0x01;
|
||||
|
||||
private static final int MK_XBUTTON1 = 0x0020;
|
||||
private static final int MK_XBUTTON2 = 0x0040;
|
||||
private static final int XBUTTON1 = 0x0001;
|
||||
private static final int XBUTTON2 = 0x0002;
|
||||
|
||||
private static WindowsDisplay current_display;
|
||||
|
||||
private static boolean cursor_clipped;
|
||||
private WindowsDisplayPeerInfo peer_info;
|
||||
private Object current_cursor;
|
||||
private Canvas parent;
|
||||
|
||||
private static boolean hasParent;
|
||||
|
||||
private Canvas parent;
|
||||
private long parent_hwnd;
|
||||
private FocusAdapter parent_focus_tracker;
|
||||
private AtomicBoolean parent_focused;
|
||||
|
||||
private WindowsKeyboard keyboard;
|
||||
private WindowsMouse mouse;
|
||||
|
||||
|
|
@ -165,10 +192,12 @@ final class WindowsDisplay implements DisplayImplementation {
|
|||
private boolean mode_set;
|
||||
private boolean isMinimized;
|
||||
private boolean isFocused;
|
||||
private boolean did_maximize;
|
||||
private boolean redoMakeContextCurrent;
|
||||
private boolean inAppActivate;
|
||||
private boolean resized;
|
||||
private boolean resizable;
|
||||
private int x;
|
||||
private int y;
|
||||
private int width;
|
||||
private int height;
|
||||
|
||||
|
|
@ -177,25 +206,33 @@ final class WindowsDisplay implements DisplayImplementation {
|
|||
|
||||
private long small_icon;
|
||||
private long large_icon;
|
||||
private boolean iconsLoaded;
|
||||
|
||||
private int captureMouse = -1;
|
||||
private boolean trackingMouse;
|
||||
private boolean mouseInside;
|
||||
|
||||
static {
|
||||
try {
|
||||
Method windowProc = WindowsDisplay.class.getDeclaredMethod("handleMessage", long.class, int.class, long.class, long.class, long.class);
|
||||
setWindowProc(windowProc);
|
||||
} catch (NoSuchMethodException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
WindowsDisplay() {
|
||||
current_display = this;
|
||||
}
|
||||
|
||||
public void createWindow(DrawableLWJGL drawable, DisplayMode mode, Canvas parent, int x, int y) throws LWJGLException {
|
||||
close_requested = false;
|
||||
is_dirty = false;
|
||||
isMinimized = false;
|
||||
isFocused = false;
|
||||
did_maximize = false;
|
||||
this.parent = parent;
|
||||
hasParent = parent != null;
|
||||
long parent_hwnd = parent != null ? getHwnd(parent) : 0;
|
||||
parent_hwnd = parent != null ? getHwnd(parent) : 0;
|
||||
this.hwnd = nCreateWindow(x, y, mode.getWidth(), mode.getHeight(), Display.isFullscreen() || isUndecorated(), parent != null, parent_hwnd);
|
||||
if ( Display.isResizable() && parent == null ) {
|
||||
setResizable(true);
|
||||
}
|
||||
|
||||
if (hwnd == 0) {
|
||||
throw new LWJGLException("Failed to create window");
|
||||
}
|
||||
|
|
@ -219,12 +256,22 @@ final class WindowsDisplay implements DisplayImplementation {
|
|||
updateWidthAndHeight();
|
||||
|
||||
if ( parent == null ) {
|
||||
if(Display.isResizable()) {
|
||||
setResizable(true);
|
||||
}
|
||||
setForegroundWindow(getHwnd());
|
||||
setFocus(getHwnd());
|
||||
} else {
|
||||
parent_focused = new AtomicBoolean(false);
|
||||
parent.addFocusListener(parent_focus_tracker = new FocusAdapter() {
|
||||
public void focusGained(FocusEvent e) {
|
||||
parent_focused.set(true);
|
||||
clearAWTFocus();
|
||||
}
|
||||
});
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
clearAWTFocus();
|
||||
}
|
||||
});
|
||||
}
|
||||
grabFocus();
|
||||
} catch (LWJGLException e) {
|
||||
nReleaseDC(hwnd, hdc);
|
||||
nDestroyWindow(hwnd);
|
||||
|
|
@ -257,11 +304,25 @@ final class WindowsDisplay implements DisplayImplementation {
|
|||
}
|
||||
|
||||
public void destroyWindow() {
|
||||
if ( parent != null ) {
|
||||
parent.removeFocusListener(parent_focus_tracker);
|
||||
parent_focus_tracker = null;
|
||||
}
|
||||
|
||||
nReleaseDC(hwnd, hdc);
|
||||
nDestroyWindow(hwnd);
|
||||
freeLargeIcon();
|
||||
freeSmallIcon();
|
||||
resetCursorClipping();
|
||||
|
||||
// reset state
|
||||
close_requested = false;
|
||||
is_dirty = false;
|
||||
isMinimized = false;
|
||||
isFocused = false;
|
||||
redoMakeContextCurrent = false;
|
||||
resizable = false;
|
||||
mouseInside = false;
|
||||
}
|
||||
private static native void nReleaseDC(long hwnd, long hdc);
|
||||
private static native void nDestroyWindow(long hwnd);
|
||||
|
|
@ -304,7 +365,7 @@ final class WindowsDisplay implements DisplayImplementation {
|
|||
/*
|
||||
* Called when the application is alt-tabbed to or from
|
||||
*/
|
||||
private void appActivate(boolean active) {
|
||||
private void appActivate(boolean active, long millis) {
|
||||
if (inAppActivate) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -315,18 +376,18 @@ final class WindowsDisplay implements DisplayImplementation {
|
|||
restoreDisplayMode();
|
||||
}
|
||||
if (parent == null) {
|
||||
showWindow(getHwnd(), SW_RESTORE);
|
||||
setForegroundWindow(getHwnd());
|
||||
setFocus(getHwnd());
|
||||
}
|
||||
did_maximize = true;
|
||||
if (Display.isFullscreen())
|
||||
updateClipping();
|
||||
} else if (Display.isFullscreen()) {
|
||||
showWindow(getHwnd(), SW_SHOWMINNOACTIVE);
|
||||
resetDisplayMode();
|
||||
} else
|
||||
updateClipping();
|
||||
setFocus(getHwnd());
|
||||
redoMakeContextCurrent = true;
|
||||
} else {
|
||||
if ( keyboard != null )
|
||||
keyboard.releaseAll(millis);
|
||||
if ( Display.isFullscreen() ) {
|
||||
showWindow(getHwnd(), SW_SHOWMINNOACTIVE);
|
||||
resetDisplayMode();
|
||||
}
|
||||
}
|
||||
updateCursor();
|
||||
inAppActivate = false;
|
||||
}
|
||||
|
|
@ -334,6 +395,26 @@ final class WindowsDisplay implements DisplayImplementation {
|
|||
private static native void setForegroundWindow(long hwnd);
|
||||
private static native void setFocus(long hwnd);
|
||||
|
||||
private void clearAWTFocus() {
|
||||
// This is needed so that the last focused component AWT remembers is NOT our Canvas
|
||||
WindowsDisplay.this.parent.setFocusable(false);
|
||||
WindowsDisplay.this.parent.setFocusable(true);
|
||||
|
||||
// Clear AWT focus owner
|
||||
KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner();
|
||||
}
|
||||
|
||||
private void grabFocus() {
|
||||
if ( parent == null )
|
||||
setFocus(getHwnd());
|
||||
else
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
parent.requestFocus();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void restoreDisplayMode() {
|
||||
try {
|
||||
doSetGammaRamp(current_gamma);
|
||||
|
|
@ -470,11 +551,13 @@ final class WindowsDisplay implements DisplayImplementation {
|
|||
|
||||
public void update() {
|
||||
nUpdate();
|
||||
if (parent != null && parent.isFocusOwner()) {
|
||||
|
||||
if ( !isFocused && parent != null && parent_focused.compareAndSet(true, false) ) {
|
||||
setFocus(getHwnd());
|
||||
}
|
||||
if (did_maximize) {
|
||||
did_maximize = false;
|
||||
|
||||
if (redoMakeContextCurrent) {
|
||||
redoMakeContextCurrent = false;
|
||||
/**
|
||||
* WORKAROUND:
|
||||
* Making the context current (redundantly) when the window
|
||||
|
|
@ -517,7 +600,7 @@ final class WindowsDisplay implements DisplayImplementation {
|
|||
}
|
||||
|
||||
public void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons) {
|
||||
mouse.poll(coord_buffer, buttons);
|
||||
mouse.poll(coord_buffer, buttons, this);
|
||||
}
|
||||
|
||||
public void readMouse(ByteBuffer buffer) {
|
||||
|
|
@ -525,7 +608,7 @@ final class WindowsDisplay implements DisplayImplementation {
|
|||
}
|
||||
|
||||
public void grabMouse(boolean grab) {
|
||||
mouse.grab(grab, shouldGrab());
|
||||
mouse.grab(grab);
|
||||
updateCursor();
|
||||
}
|
||||
|
||||
|
|
@ -549,13 +632,15 @@ final class WindowsDisplay implements DisplayImplementation {
|
|||
|
||||
private void updateCursor() {
|
||||
try {
|
||||
if (mouse != null && shouldGrab())
|
||||
if (mouse != null && shouldGrab()) {
|
||||
centerCursor(hwnd);
|
||||
nSetNativeCursor(getHwnd(), mouse.getBlankCursor());
|
||||
else
|
||||
} else
|
||||
nSetNativeCursor(getHwnd(), current_cursor);
|
||||
} catch (LWJGLException e) {
|
||||
LWJGLUtil.log("Failed to update cursor: " + e);
|
||||
}
|
||||
updateClipping();
|
||||
}
|
||||
static native void nSetNativeCursor(long hwnd, Object handle) throws LWJGLException;
|
||||
|
||||
|
|
@ -609,11 +694,10 @@ final class WindowsDisplay implements DisplayImplementation {
|
|||
|
||||
/* Keyboard */
|
||||
public void createKeyboard() throws LWJGLException {
|
||||
keyboard = new WindowsKeyboard(getHwnd());
|
||||
keyboard = new WindowsKeyboard();
|
||||
}
|
||||
|
||||
public void destroyKeyboard() {
|
||||
keyboard.destroy();
|
||||
keyboard = null;
|
||||
}
|
||||
|
||||
|
|
@ -726,6 +810,23 @@ final class WindowsDisplay implements DisplayImplementation {
|
|||
large_icon = large_new_icon;
|
||||
used++;
|
||||
done_large = true;
|
||||
|
||||
// Problem: The taskbar icon won't update until Windows sends a WM_GETICON to our window proc and we reply. But this method is usually called
|
||||
// on init and it might take a while before the next call to nUpdate (because of resources being loaded, etc). So we wait for the next
|
||||
// WM_GETICON message (usually received about 100ms after WM_SETICON) to make sure the taskbar icon has updated before we return to the user.
|
||||
// (We wouldn't need to do this if the event loop was running continuously on its own thread.)
|
||||
iconsLoaded = false;
|
||||
|
||||
// Track how long the wait takes and give up at 500ms, just in case.
|
||||
long time = System.nanoTime();
|
||||
long MAX_WAIT = 500L * 1000L * 1000L;
|
||||
while ( true ) {
|
||||
nUpdate();
|
||||
if ( iconsLoaded || MAX_WAIT < System.nanoTime() - time )
|
||||
break;
|
||||
|
||||
Thread.yield();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -754,22 +855,12 @@ final class WindowsDisplay implements DisplayImplementation {
|
|||
nReleaseCapture();
|
||||
}
|
||||
}
|
||||
|
||||
if (parent != null && !isFocused) {
|
||||
setFocus(getHwnd());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean shouldGrab() {
|
||||
return !isMinimized && isFocused && Mouse.isGrabbed();
|
||||
}
|
||||
|
||||
private void handleMouseMoved(int x, int y, long millis) {
|
||||
if (mouse != null) {
|
||||
mouse.handleMouseMoved(x, y, millis, shouldGrab());
|
||||
}
|
||||
}
|
||||
|
||||
private static native long nSetCapture(long hwnd);
|
||||
private static native boolean nReleaseCapture();
|
||||
|
||||
|
|
@ -789,14 +880,16 @@ final class WindowsDisplay implements DisplayImplementation {
|
|||
}
|
||||
|
||||
private void handleKeyButton(long wParam, long lParam, long millis) {
|
||||
if ( keyboard == null )
|
||||
return;
|
||||
|
||||
byte previous_state = (byte)((lParam >>> 30) & 0x1);
|
||||
byte state = (byte)(1 - ((lParam >>> 31) & 0x1));
|
||||
boolean repeat = state == previous_state; // Repeat message
|
||||
byte extended = (byte)((lParam >>> 24) & 0x1);
|
||||
int scan_code = (int)((lParam >>> 16) & 0xFF);
|
||||
if (keyboard != null) {
|
||||
keyboard.handleKey((int)wParam, scan_code, extended != 0, state, millis, repeat);
|
||||
}
|
||||
|
||||
keyboard.handleKey((int)wParam, scan_code, extended != 0, state, millis, repeat);
|
||||
}
|
||||
|
||||
private static int transformY(long hwnd, int y) {
|
||||
|
|
@ -807,18 +900,16 @@ final class WindowsDisplay implements DisplayImplementation {
|
|||
|
||||
private static native void clientToScreen(long hwnd, IntBuffer point);
|
||||
|
||||
private static int handleMessage(long hwnd, int msg, long wParam, long lParam, long millis) {
|
||||
private static native void setWindowProc(Method windowProc);
|
||||
|
||||
private static long handleMessage(long hwnd, int msg, long wParam, long lParam, long millis) {
|
||||
if (current_display != null)
|
||||
return current_display.doHandleMessage(hwnd, msg, wParam, lParam, millis);
|
||||
else
|
||||
return defWindowProc(hwnd, msg, wParam, lParam);
|
||||
}
|
||||
|
||||
private static native int defWindowProc(long hwnd, int msg, long wParam, long lParam);
|
||||
|
||||
private void checkCursorState() {
|
||||
updateClipping();
|
||||
}
|
||||
private static native long defWindowProc(long hwnd, int msg, long wParam, long lParam);
|
||||
|
||||
private void updateClipping() {
|
||||
if ((Display.isFullscreen() || (mouse != null && mouse.isGrabbed())) && !isMinimized && isFocused && (getForegroundWindow() == getHwnd() || hasParent)) {
|
||||
|
|
@ -833,15 +924,37 @@ final class WindowsDisplay implements DisplayImplementation {
|
|||
}
|
||||
|
||||
private void setMinimized(boolean m) {
|
||||
isMinimized = m;
|
||||
checkCursorState();
|
||||
if ( m != isMinimized ) {
|
||||
isMinimized = m;
|
||||
updateClipping();
|
||||
}
|
||||
}
|
||||
|
||||
private int doHandleMessage(long hwnd, int msg, long wParam, long lParam, long millis) {
|
||||
private long doHandleMessage(long hwnd, int msg, long wParam, long lParam, long millis) {
|
||||
/*switch ( msg ) {
|
||||
case 0x0:
|
||||
case 0x0020:
|
||||
case 0x0084:
|
||||
case WM_MOUSEMOVE:
|
||||
break;
|
||||
default:
|
||||
WindowsEventDebug.printMessage(msg, wParam, lParam);
|
||||
}*/
|
||||
|
||||
if ( parent != null && !isFocused ) {
|
||||
switch ( msg ) {
|
||||
case WM_LBUTTONDOWN:
|
||||
case WM_RBUTTONDOWN:
|
||||
case WM_MBUTTONDOWN:
|
||||
case WM_XBUTTONDOWN:
|
||||
sendMessage(parent_hwnd, msg, wParam, lParam);
|
||||
}
|
||||
}
|
||||
|
||||
switch (msg) {
|
||||
// disable screen saver and monitor power down messages which wreak havoc
|
||||
case WM_ACTIVATE:
|
||||
switch ((int)wParam) {
|
||||
/*switch ((int)wParam) {
|
||||
case WA_ACTIVE:
|
||||
case WA_CLICKACTIVE:
|
||||
appActivate(true);
|
||||
|
|
@ -849,70 +962,96 @@ final class WindowsDisplay implements DisplayImplementation {
|
|||
case WA_INACTIVE:
|
||||
appActivate(false);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}*/
|
||||
return 0L;
|
||||
case WM_SIZE:
|
||||
switch ((int)wParam) {
|
||||
case SIZE_RESTORED:
|
||||
case SIZE_MAXIMIZED:
|
||||
resized = true;
|
||||
updateWidthAndHeight();
|
||||
setMinimized(false);
|
||||
break;
|
||||
case SIZE_MINIMIZED:
|
||||
setMinimized(true);
|
||||
break;
|
||||
}
|
||||
return defWindowProc(hwnd, msg, wParam, lParam);
|
||||
case WM_ENTERSIZEMOVE:
|
||||
return defWindowProc(hwnd, msg, wParam, lParam);
|
||||
case WM_EXITSIZEMOVE:
|
||||
return defWindowProc(hwnd, msg, wParam, lParam);
|
||||
break;
|
||||
case WM_SIZING:
|
||||
resized = true;
|
||||
updateWidthAndHeight();
|
||||
return defWindowProc(hwnd, msg, wParam, lParam);
|
||||
break;
|
||||
case WM_KILLFOCUS:
|
||||
appActivate(false);
|
||||
return 0;
|
||||
appActivate(false, millis);
|
||||
return 0L;
|
||||
case WM_SETFOCUS:
|
||||
appActivate(true);
|
||||
return 0;
|
||||
appActivate(true, millis);
|
||||
return 0L;
|
||||
case WM_MOUSEACTIVATE:
|
||||
if ( parent != null ) {
|
||||
if ( !isFocused )
|
||||
grabFocus();
|
||||
return 3L; // MA_NOACTIVATE
|
||||
}
|
||||
break;
|
||||
case WM_MOUSEMOVE:
|
||||
int xPos = (int)(short)(lParam & 0xFFFF);
|
||||
int yPos = transformY(getHwnd(), (int)(short)((lParam >> 16) & 0xFFFF));
|
||||
handleMouseMoved(xPos, yPos, millis);
|
||||
checkCursorState();
|
||||
mouseInside = true;
|
||||
if(!trackingMouse) {
|
||||
trackingMouse = nTrackMouseEvent(hwnd);
|
||||
}
|
||||
return 0;
|
||||
if ( mouse != null ) {
|
||||
int xPos = (short)(lParam & 0xFFFF);
|
||||
int yPos = transformY(getHwnd(), (short)(lParam >>> 16));
|
||||
mouse.handleMouseMoved(xPos, yPos, millis);
|
||||
}
|
||||
if ( !mouseInside ) {
|
||||
mouseInside = true;
|
||||
updateCursor();
|
||||
nTrackMouseEvent(hwnd);
|
||||
}
|
||||
return 0L;
|
||||
case WM_MOUSEWHEEL:
|
||||
int dwheel = (int)(short)((wParam >> 16) & 0xFFFF);
|
||||
handleMouseScrolled(dwheel, millis);
|
||||
return 0;
|
||||
return 0L;
|
||||
case WM_LBUTTONDOWN:
|
||||
handleMouseButton(0, 1, millis);
|
||||
return 0;
|
||||
return 0L;
|
||||
case WM_LBUTTONUP:
|
||||
handleMouseButton(0, 0, millis);
|
||||
return 0;
|
||||
return 0L;
|
||||
case WM_RBUTTONDOWN:
|
||||
handleMouseButton(1, 1, millis);
|
||||
return 0;
|
||||
return 0L;
|
||||
case WM_RBUTTONUP:
|
||||
handleMouseButton(1, 0, millis);
|
||||
return 0;
|
||||
return 0L;
|
||||
case WM_MBUTTONDOWN:
|
||||
handleMouseButton(2, 1, millis);
|
||||
return 0;
|
||||
return 0L;
|
||||
case WM_MBUTTONUP:
|
||||
handleMouseButton(2, 0, millis);
|
||||
return 0;
|
||||
return 0L;
|
||||
case WM_XBUTTONUP:
|
||||
if((wParam >> 16) == XBUTTON1) {
|
||||
handleMouseButton(3, 0, millis);
|
||||
} else {
|
||||
handleMouseButton(4, 0, millis);
|
||||
}
|
||||
return 1;
|
||||
case WM_XBUTTONDOWN:
|
||||
if((wParam & 0xFF) == MK_XBUTTON1) {
|
||||
handleMouseButton(3, 1, millis);
|
||||
} else {
|
||||
handleMouseButton(4, 1, millis);
|
||||
}
|
||||
return 1;
|
||||
case WM_SYSCHAR:
|
||||
case WM_CHAR:
|
||||
handleChar(wParam, lParam, millis);
|
||||
return 0;
|
||||
return 0L;
|
||||
case WM_SYSKEYUP:
|
||||
// Disable WM_SYSCOMMAND/SC_KEYMENU
|
||||
if ( wParam == WindowsKeycodes.VK_MENU || wParam == WindowsKeycodes.VK_F10 ) {
|
||||
handleKeyButton(wParam, lParam, millis);
|
||||
return 0L;
|
||||
}
|
||||
/* Fall through */
|
||||
case WM_KEYUP:
|
||||
// SysRq apparently only generates WM_KEYUP, so we'll fake a WM_KEYDOWN
|
||||
|
|
@ -929,31 +1068,26 @@ final class WindowsDisplay implements DisplayImplementation {
|
|||
/* Fall through */
|
||||
case WM_KEYDOWN:
|
||||
handleKeyButton(wParam, lParam, millis);
|
||||
return defWindowProc(hwnd, msg, wParam, lParam);
|
||||
break;
|
||||
case WM_QUIT:
|
||||
close_requested = true;
|
||||
return 0;
|
||||
return 0L;
|
||||
case WM_SYSCOMMAND:
|
||||
switch ((int)(wParam & 0xfff0)) {
|
||||
case SC_KEYMENU:
|
||||
case SC_MOUSEMENU:
|
||||
case SC_SCREENSAVE:
|
||||
case SC_MONITORPOWER:
|
||||
return 0;
|
||||
return 0L;
|
||||
case SC_CLOSE:
|
||||
close_requested = true;
|
||||
return 0;
|
||||
default:
|
||||
break;
|
||||
return 0L;
|
||||
}
|
||||
return defWindowProc(hwnd, msg, wParam, lParam);
|
||||
break;
|
||||
case WM_PAINT:
|
||||
is_dirty = true;
|
||||
return defWindowProc(hwnd, msg, wParam, lParam);
|
||||
break;
|
||||
case WM_MOUSELEAVE:
|
||||
mouseInside = false;
|
||||
trackingMouse = false;
|
||||
return defWindowProc(hwnd, msg, wParam, lParam);
|
||||
break;
|
||||
case WM_CANCELMODE:
|
||||
nReleaseCapture();
|
||||
/* fall through */
|
||||
|
|
@ -962,10 +1096,32 @@ final class WindowsDisplay implements DisplayImplementation {
|
|||
handleMouseButton(captureMouse, 0, millis);
|
||||
captureMouse = -1;
|
||||
}
|
||||
return 0;
|
||||
default:
|
||||
return defWindowProc(hwnd, msg, wParam, lParam);
|
||||
return 0L;
|
||||
case WM_WINDOWPOSCHANGED:
|
||||
if(getWindowRect(hwnd, rect_buffer)) {
|
||||
rect.copyFromBuffer(rect_buffer);
|
||||
x = rect.left;
|
||||
y = rect.top;
|
||||
} else {
|
||||
LWJGLUtil.log("WM_WINDOWPOSCHANGED: Unable to get window rect");
|
||||
}
|
||||
break;
|
||||
case WM_GETICON:
|
||||
iconsLoaded = true;
|
||||
break;
|
||||
}
|
||||
|
||||
return defWindowProc(hwnd, msg, wParam, lParam);
|
||||
}
|
||||
|
||||
private native boolean getWindowRect(long hwnd, IntBuffer rectBuffer);
|
||||
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
|
|
@ -976,15 +1132,6 @@ final class WindowsDisplay implements DisplayImplementation {
|
|||
return height;
|
||||
}
|
||||
|
||||
private int firstMouseButtonDown() {
|
||||
for(int i=0; i<Mouse.getButtonCount(); i++) {
|
||||
if(Mouse.isButtonDown(i)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private native boolean nTrackMouseEvent(long hwnd);
|
||||
|
||||
public boolean isInsideWindow() {
|
||||
|
|
@ -992,34 +1139,45 @@ final class WindowsDisplay implements DisplayImplementation {
|
|||
}
|
||||
|
||||
public void setResizable(boolean resizable) {
|
||||
if(this.resizable != resizable) {
|
||||
long style = getWindowLongPtr(hwnd, GWL_STYLE);
|
||||
long styleex = getWindowLongPtr(hwnd, GWL_EXSTYLE);
|
||||
if ( this.resizable == resizable )
|
||||
return;
|
||||
|
||||
// update frame style
|
||||
if(resizable) {
|
||||
setWindowLongPtr(hwnd, GWL_STYLE, style |= WS_THICKFRAME);
|
||||
} else {
|
||||
setWindowLongPtr(hwnd, GWL_STYLE, style &= ~WS_THICKFRAME);
|
||||
}
|
||||
|
||||
// from the existing client rect, determine the new window rect
|
||||
// based on the style changes - using AdjustWindowRectEx.
|
||||
getClientRect(hwnd, rect_buffer);
|
||||
rect.copyFromBuffer(rect_buffer);
|
||||
adjustWindowRectEx(rect_buffer, style, false, styleex);
|
||||
rect.copyFromBuffer(rect_buffer);
|
||||
|
||||
// force a frame update and resize accordingly
|
||||
setWindowPos(hwnd, HWND_TOP, 0, 0, rect.right - rect.left, rect.bottom - rect.top, SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED);
|
||||
|
||||
updateWidthAndHeight();
|
||||
resized = false;
|
||||
}
|
||||
this.resized = false;
|
||||
this.resizable = resizable;
|
||||
|
||||
int style = (int)getWindowLongPtr(hwnd, GWL_STYLE);
|
||||
int styleex = (int)getWindowLongPtr(hwnd, GWL_EXSTYLE);
|
||||
|
||||
// update frame style
|
||||
setWindowLongPtr(
|
||||
hwnd,
|
||||
GWL_STYLE,
|
||||
style = resizable && !Display.isFullscreen()
|
||||
? (style | (WS_THICKFRAME | WS_MAXIMIZEBOX))
|
||||
: (style & ~(WS_THICKFRAME | WS_MAXIMIZEBOX))
|
||||
);
|
||||
|
||||
// from the existing client rect, determine the new window rect
|
||||
// based on the style changes - using AdjustWindowRectEx.
|
||||
getGlobalClientRect(hwnd, rect);
|
||||
rect.copyToBuffer(rect_buffer);
|
||||
adjustWindowRectEx(rect_buffer, style, false, styleex);
|
||||
rect.copyFromBuffer(rect_buffer);
|
||||
|
||||
// Apply the style changes
|
||||
setWindowPos(
|
||||
hwnd, 0L,
|
||||
rect.left,
|
||||
rect.top,
|
||||
rect.right - rect.left,
|
||||
rect.bottom - rect.top,
|
||||
SWP_NOZORDER | SWP_FRAMECHANGED
|
||||
);
|
||||
|
||||
updateWidthAndHeight();
|
||||
}
|
||||
|
||||
private native boolean adjustWindowRectEx(IntBuffer rectBuffer, long style, boolean menu, long styleex);
|
||||
private native boolean adjustWindowRectEx(IntBuffer rectBuffer, int style, boolean menu, int styleex);
|
||||
|
||||
public boolean wasResized() {
|
||||
if(resized) {
|
||||
|
|
@ -1029,39 +1187,49 @@ final class WindowsDisplay implements DisplayImplementation {
|
|||
return false;
|
||||
}
|
||||
|
||||
public float getPixelScaleFactor() {
|
||||
return 1f;
|
||||
}
|
||||
|
||||
private static final class Rect {
|
||||
public int top;
|
||||
public int bottom;
|
||||
public int left;
|
||||
public int right;
|
||||
|
||||
public int
|
||||
left,
|
||||
top,
|
||||
right,
|
||||
bottom;
|
||||
|
||||
public void copyToBuffer(IntBuffer buffer) {
|
||||
buffer.put(0, top).put(1, bottom).put(2, left).put(3, right);
|
||||
buffer
|
||||
.put(0, left)
|
||||
.put(1, top)
|
||||
.put(2, right)
|
||||
.put(3, bottom);
|
||||
}
|
||||
|
||||
public void copyFromBuffer(IntBuffer buffer) {
|
||||
top = buffer.get(0);
|
||||
bottom = buffer.get(1);
|
||||
left = buffer.get(2);
|
||||
right = buffer.get(3);
|
||||
left = buffer.get(0);
|
||||
top = buffer.get(1);
|
||||
right = buffer.get(2);
|
||||
bottom = buffer.get(3);
|
||||
}
|
||||
|
||||
public void offset(int offset_x, int offset_y) {
|
||||
left += offset_x;
|
||||
right += offset_x;
|
||||
top += offset_y;
|
||||
right += offset_x;
|
||||
bottom += offset_y;
|
||||
}
|
||||
|
||||
public static void intersect(Rect r1, Rect r2, Rect dst) {
|
||||
dst.top = Math.max(r1.top, r2.top);
|
||||
dst.bottom = Math.min(r1.bottom, r2.bottom);
|
||||
dst.left = Math.max(r1.left, r2.left);
|
||||
dst.top = Math.max(r1.top, r2.top);
|
||||
dst.right = Math.min(r1.right, r2.right);
|
||||
dst.bottom = Math.min(r1.bottom, r2.bottom);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "Rect: top = " + top + " bottom = " + bottom + " left = " + left + " right = " + right + ", width: " + (right - left) + ", height: " + (bottom - top);
|
||||
return "Rect: left = " + left + " top = " + top + " right = " + right + " bottom = " + bottom + ", width: " + (right - left) + ", height: " + (bottom - top);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -39,23 +39,16 @@ package org.lwjgl.opengl;
|
|||
import java.nio.ByteBuffer;
|
||||
import java.nio.CharBuffer;
|
||||
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.LWJGLException;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
final class WindowsKeyboard {
|
||||
private static final int MAPVK_VK_TO_VSC = 0;
|
||||
|
||||
private static final int BUFFER_SIZE = 50;
|
||||
|
||||
private final long hwnd;
|
||||
private final ByteBuffer keyboard_state;
|
||||
private final byte[] key_down_buffer = new byte[Keyboard.KEYBOARD_SIZE];
|
||||
private final byte[] virt_key_down_buffer = new byte[Keyboard.KEYBOARD_SIZE];
|
||||
private final EventQueue event_queue = new EventQueue(Keyboard.EVENT_SIZE);
|
||||
private final ByteBuffer tmp_event = ByteBuffer.allocate(Keyboard.EVENT_SIZE);
|
||||
|
||||
private boolean grabbed;
|
||||
|
||||
private boolean has_retained_event; // Indicates if we're waiting for a WM_CHAR
|
||||
private int retained_key_code;
|
||||
private byte retained_state;
|
||||
|
|
@ -63,32 +56,26 @@ final class WindowsKeyboard {
|
|||
private long retained_millis;
|
||||
private boolean retained_repeat;
|
||||
|
||||
WindowsKeyboard(long hwnd) throws LWJGLException {
|
||||
this.hwnd = hwnd;
|
||||
keyboard_state = BufferUtils.createByteBuffer(256);
|
||||
WindowsKeyboard() throws LWJGLException {
|
||||
}
|
||||
private static native boolean isWindowsNT();
|
||||
|
||||
public void destroy() {
|
||||
}
|
||||
private static native boolean isWindowsNT();
|
||||
|
||||
boolean isKeyDown(int lwjgl_keycode) {
|
||||
return key_down_buffer[lwjgl_keycode] == 1;
|
||||
}
|
||||
|
||||
public void grab(boolean grab) {
|
||||
if(grab) {
|
||||
if (!grabbed) {
|
||||
grabbed = true;
|
||||
}
|
||||
} else {
|
||||
if (grabbed) {
|
||||
grabbed = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
void poll(ByteBuffer keyDownBuffer) {
|
||||
// Handle shift key release while both are pressed.
|
||||
// Windows will not send an up event for the first button that was released in this case.
|
||||
// There will only be one up event, for the last button only. We handle this problem
|
||||
// here, using asynchronous state queries.
|
||||
if ( isKeyDown(Keyboard.KEY_LSHIFT) && !isKeyPressedAsync(WindowsKeycodes.VK_LSHIFT) )
|
||||
handleKey(WindowsKeycodes.VK_SHIFT, Keyboard.KEY_LSHIFT, false, (byte)0, 0L, false);
|
||||
|
||||
if ( isKeyDown(Keyboard.KEY_RSHIFT) && !isKeyPressedAsync(WindowsKeycodes.VK_RSHIFT) )
|
||||
handleKey(WindowsKeycodes.VK_SHIFT, Keyboard.KEY_RSHIFT, false, (byte)0, 0L, false);
|
||||
|
||||
public void poll(ByteBuffer keyDownBuffer) {
|
||||
int old_position = keyDownBuffer.position();
|
||||
keyDownBuffer.put(key_down_buffer);
|
||||
keyDownBuffer.position(old_position);
|
||||
|
|
@ -98,7 +85,8 @@ final class WindowsKeyboard {
|
|||
private static native int ToUnicode(int wVirtKey, int wScanCode, ByteBuffer lpKeyState, CharBuffer pwszBuff, int cchBuff, int flags);
|
||||
private static native int ToAscii(int wVirtKey, int wScanCode, ByteBuffer lpKeyState, ByteBuffer lpChar, int flags);
|
||||
private static native int GetKeyboardState(ByteBuffer lpKeyState);
|
||||
private static native int GetKeyState(int virt_key);
|
||||
private static native short GetKeyState(int virt_key);
|
||||
private static native short GetAsyncKeyState(int virt_key);
|
||||
|
||||
private void putEvent(int keycode, byte state, int ch, long millis, boolean repeat) {
|
||||
tmp_event.clear();
|
||||
|
|
@ -107,33 +95,10 @@ final class WindowsKeyboard {
|
|||
event_queue.putEvent(tmp_event);
|
||||
}
|
||||
|
||||
private boolean checkShiftKey(int virt_key, byte state) {
|
||||
int key_state = (GetKeyState(virt_key) >>> 15) & 0x1;
|
||||
int lwjgl_code = WindowsKeycodes.mapVirtualKeyToLWJGLCode(virt_key);
|
||||
return (key_down_buffer[lwjgl_code] == 1 - state) && (key_state == state);
|
||||
}
|
||||
|
||||
private int translateShift(int scan_code, byte state) {
|
||||
if (checkShiftKey(WindowsKeycodes.VK_LSHIFT, state)) {
|
||||
return WindowsKeycodes.VK_LSHIFT;
|
||||
} else if (checkShiftKey(WindowsKeycodes.VK_RSHIFT, state)) {
|
||||
return WindowsKeycodes.VK_RSHIFT;
|
||||
} else {
|
||||
if (scan_code== 0x2A)
|
||||
return WindowsKeycodes.VK_LSHIFT;
|
||||
else {
|
||||
if (scan_code == 0x36)
|
||||
return WindowsKeycodes.VK_RSHIFT;
|
||||
else
|
||||
return WindowsKeycodes.VK_LSHIFT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int translateExtended(int virt_key, int scan_code, byte state, boolean extended) {
|
||||
private static int translateExtended(int virt_key, int scan_code, boolean extended) {
|
||||
switch (virt_key) {
|
||||
case WindowsKeycodes.VK_SHIFT:
|
||||
return translateShift(scan_code, state);
|
||||
return scan_code == 0x36 ? WindowsKeycodes.VK_RSHIFT : WindowsKeycodes.VK_LSHIFT;
|
||||
case WindowsKeycodes.VK_CONTROL:
|
||||
return extended ? WindowsKeycodes.VK_RCONTROL : WindowsKeycodes.VK_LCONTROL;
|
||||
case WindowsKeycodes.VK_MENU:
|
||||
|
|
@ -150,13 +115,39 @@ final class WindowsKeyboard {
|
|||
}
|
||||
}
|
||||
|
||||
public void handleKey(int virt_key, int scan_code, boolean extended, byte event_state, long millis, boolean repeat) {
|
||||
virt_key = translateExtended(virt_key, scan_code, event_state, extended);
|
||||
private static boolean isKeyPressed(int state) {
|
||||
return (state & 1) == 1;
|
||||
}
|
||||
|
||||
private static boolean isKeyPressedAsync(int virt_key) {
|
||||
return (GetAsyncKeyState(virt_key) & 0x8000) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is called when the window loses focus: we release all currently pressed keys. If a key has been pressed (or hasn't been released at all), before we
|
||||
* regain focus, we'll start receiving repeat press events. We'll treat the first of those as a non-repeat press.
|
||||
*/
|
||||
void releaseAll(long millis) {
|
||||
for ( int i = 0; i < virt_key_down_buffer.length; i++ ) {
|
||||
if ( isKeyPressed(virt_key_down_buffer[i]) ) {
|
||||
handleKey(i, 0, false, (byte)0, millis, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void handleKey(int virt_key, int scan_code, boolean extended, byte event_state, long millis, boolean repeat) {
|
||||
virt_key = translateExtended(virt_key, scan_code, extended);
|
||||
if ( !repeat && isKeyPressed(event_state) == isKeyPressed(virt_key_down_buffer[virt_key]) )
|
||||
return;
|
||||
|
||||
flushRetained();
|
||||
has_retained_event = true;
|
||||
int keycode = WindowsKeycodes.mapVirtualKeyToLWJGLCode(virt_key);
|
||||
if (keycode < key_down_buffer.length)
|
||||
if (keycode < key_down_buffer.length) {
|
||||
key_down_buffer[keycode] = event_state;
|
||||
repeat &= isKeyPressed(virt_key_down_buffer[virt_key]); // Treat the first repeat event after releaseAll() as a non-repeat press.
|
||||
virt_key_down_buffer[virt_key] = event_state;
|
||||
}
|
||||
retained_key_code = keycode;
|
||||
retained_state = event_state;
|
||||
retained_millis = millis;
|
||||
|
|
@ -164,7 +155,7 @@ final class WindowsKeyboard {
|
|||
retained_repeat = repeat;
|
||||
}
|
||||
|
||||
public void handleChar(int event_char, long millis, boolean repeat) {
|
||||
void handleChar(int event_char, long millis, boolean repeat) {
|
||||
if (has_retained_event && retained_char != 0)
|
||||
flushRetained();
|
||||
if (!has_retained_event) {
|
||||
|
|
@ -173,7 +164,7 @@ final class WindowsKeyboard {
|
|||
retained_char = event_char;
|
||||
}
|
||||
|
||||
public void read(ByteBuffer buffer) {
|
||||
void read(ByteBuffer buffer) {
|
||||
flushRetained();
|
||||
event_queue.copyEvents(buffer);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ final class WindowsMouse {
|
|||
|
||||
WindowsMouse(long hwnd) throws LWJGLException {
|
||||
this.hwnd = hwnd;
|
||||
this.mouse_button_count = WindowsDisplay.getSystemMetrics(WindowsDisplay.SM_CMOUSEBUTTONS);
|
||||
this.mouse_button_count = Math.min(5, WindowsDisplay.getSystemMetrics(WindowsDisplay.SM_CMOUSEBUTTONS));
|
||||
this.has_wheel = WindowsDisplay.getSystemMetrics(WindowsDisplay.SM_MOUSEWHEELPRESENT) != 0;
|
||||
this.blank_cursor = createBlankCursor();
|
||||
this.button_states = new byte[mouse_button_count];
|
||||
|
|
@ -90,7 +90,7 @@ final class WindowsMouse {
|
|||
return mouse_button_count;
|
||||
}
|
||||
|
||||
public void poll(IntBuffer coord_buffer, ByteBuffer buttons) {
|
||||
public void poll(IntBuffer coord_buffer, ByteBuffer buttons, WindowsDisplay display) {
|
||||
for (int i = 0; i < coord_buffer.remaining(); i++)
|
||||
coord_buffer.put(coord_buffer.position() + i, 0);
|
||||
int num_buttons = mouse_button_count;
|
||||
|
|
@ -103,6 +103,9 @@ final class WindowsMouse {
|
|||
if (isGrabbed()) {
|
||||
coord_buffer.put(coord_buffer.position() + 0, accum_dx);
|
||||
coord_buffer.put(coord_buffer.position() + 1, accum_dy);
|
||||
|
||||
if ( display.isActive() && display.isVisible() && (accum_dx != 0 || accum_dy != 0) )
|
||||
WindowsDisplay.centerCursor(hwnd);
|
||||
} else {
|
||||
coord_buffer.put(coord_buffer.position() + 0, last_x);
|
||||
coord_buffer.put(coord_buffer.position() + 1, last_y);
|
||||
|
|
@ -132,25 +135,8 @@ final class WindowsMouse {
|
|||
return blank_cursor;
|
||||
}
|
||||
|
||||
public void grab(boolean grab, boolean should_center) {
|
||||
if (grab) {
|
||||
if (!mouse_grabbed) {
|
||||
mouse_grabbed = true;
|
||||
if (should_center) {
|
||||
try {
|
||||
WindowsDisplay.setupCursorClipping(hwnd);
|
||||
} catch (LWJGLException e) {
|
||||
LWJGLUtil.log("Failed to setup cursor clipping: " + e);
|
||||
}
|
||||
centerCursor();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (mouse_grabbed) {
|
||||
mouse_grabbed = false;
|
||||
WindowsDisplay.resetCursorClipping();
|
||||
}
|
||||
}
|
||||
public void grab(boolean grab) {
|
||||
mouse_grabbed = grab;
|
||||
event_queue.clearEvents();
|
||||
}
|
||||
|
||||
|
|
@ -159,10 +145,6 @@ final class WindowsMouse {
|
|||
putMouseEvent((byte)-1, (byte)0, event_dwheel, millis*1000000);
|
||||
}
|
||||
|
||||
private void centerCursor() {
|
||||
WindowsDisplay.centerCursor(hwnd);
|
||||
}
|
||||
|
||||
public void setPosition(int x, int y) {
|
||||
this.last_x = x;
|
||||
this.last_y = y;
|
||||
|
|
@ -172,7 +154,7 @@ final class WindowsMouse {
|
|||
WindowsDisplay.doDestroyCursor(blank_cursor);
|
||||
}
|
||||
|
||||
public void handleMouseMoved(int x, int y, long millis, boolean should_center) {
|
||||
public void handleMouseMoved(int x, int y, long millis) {
|
||||
int dx = x - last_x;
|
||||
int dy = y - last_y;
|
||||
if (dx != 0 || dy != 0) {
|
||||
|
|
@ -183,8 +165,6 @@ final class WindowsMouse {
|
|||
long nanos = millis*1000000;
|
||||
if (mouse_grabbed) {
|
||||
putMouseEventWithCoords((byte)-1, (byte)0, dx, dy, 0, nanos);
|
||||
if (should_center)
|
||||
centerCursor();
|
||||
} else {
|
||||
putMouseEventWithCoords((byte)-1, (byte)0, x, y, 0, nanos);
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue