Imported Upstream version 2.5+dfsg
Gabriele Giacone
13 years ago
123 | 123 | <fileset refid="lwjgl.fileset" /> |
124 | 124 | <manifest> |
125 | 125 | <attribute name="Sealed" value="true"/> |
126 | <attribute name="Trusted-Library" value="true"/> | |
127 | 126 | </manifest> |
128 | 127 | </jar> |
129 | 128 | |
132 | 131 | <fileset refid="lwjgl_util_applet.fileset" /> |
133 | 132 | <manifest> |
134 | 133 | <attribute name="Sealed" value="true"/> |
135 | <attribute name="Trusted-Library" value="true"/> | |
136 | 134 | </manifest> |
137 | 135 | </jar> |
138 | 136 | |
252 | 250 | <class name="org.lwjgl.openal.AL" /> |
253 | 251 | <class name="org.lwjgl.opengl.GLContext" /> |
254 | 252 | <class name="org.lwjgl.opengl.Pbuffer" /> |
253 | <class name="org.lwjgl.opengl.AMDDebugOutputCallback" /> | |
255 | 254 | </javah> |
256 | 255 | </target> |
257 | 256 |
11 | 11 | <property name="lwjgl.docs" location="doc" /> |
12 | 12 | <property name="lwjgl.temp" location="temp" /> |
13 | 13 | <property name="lwjgl.res" location="res" /> |
14 | <property name="lwjgl.version" value="2.4.2" /> | |
14 | <property name="lwjgl.version" value="2.5" /> | |
15 | 15 | |
16 | 16 | <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"/> |
17 | 17 | <!-- ================================================================== --> |
12 | 12 | <javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" includes="org/lwjgl/util/generator/**.java" source="1.5" target="1.5" taskname="generator"> |
13 | 13 | <compilerarg value="-Xlint:all"/> |
14 | 14 | </javac> |
15 | <!-- Compile helper classes used by the templates --> | |
15 | 16 | <javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" source="1.4" target="1.4" taskname="generator"> |
16 | 17 | <include name="org/lwjgl/opengl/GLSync.java"/> |
18 | <include name="org/lwjgl/opengl/AMDDebugOutputCallback.java"/> | |
17 | 19 | <include name="org/lwjgl/opengl/PointerWrapper.java"/> |
18 | 20 | </javac> |
19 | 21 | </target> |
36 | 38 | <arg value="-d"/> |
37 | 39 | <arg path="${lwjgl.src.native}/generated"/> |
38 | 40 | <arg value="-Atypemap=org.lwjgl.util.generator.ALTypeMap"/> |
39 | <fileset dir="${lwjgl.src.templates}" includes="org/lwjgl/openal/AL10.java, org/lwjgl/openal/AL11.java"/> | |
41 | <fileset dir="${lwjgl.src.templates}" includes="org/lwjgl/openal/AL10.java, org/lwjgl/openal/AL11.java, org/lwjgl/openal/EFX10.java"/> | |
40 | 42 | </apply> |
41 | 43 | </target> |
42 | 44 | |
54 | 56 | <arg path="${lwjgl.src.native}/generated"/> |
55 | 57 | <arg value="-Atypemap=org.lwjgl.util.generator.ALTypeMap"/> |
56 | 58 | <arg value="-Ageneratechecks"/> |
57 | <fileset dir="${lwjgl.src.templates}" includes="org/lwjgl/openal/AL10.java, org/lwjgl/openal/AL11.java"/> | |
59 | <fileset dir="${lwjgl.src.templates}" includes="org/lwjgl/openal/AL10.java, org/lwjgl/openal/AL11.java, org/lwjgl/openal/EFX10.java"/> | |
58 | 60 | </apply> |
59 | 61 | </target> |
60 | 62 |
6 | 6 | </antcall> |
7 | 7 | </target> |
8 | 8 | |
9 | <target name="webstart_demo-release" depends="jars"> | |
9 | <target name="webstart_demo-release"> | |
10 | 10 | <input message="Please type the password for the keystore" addproperty="sign.pwd"/> |
11 | 11 | |
12 | 12 | <antcall target="-webstart_demo"> |
24 | 24 | |
25 | 25 | <!-- unzip common files --> |
26 | 26 | <unzip src="${lwjgl.dist}/lwjgl-${lwjgl.version}.zip" dest="${lwjgl.temp}/jnlp/temp" overwrite="true"/> |
27 | <copy file="${lwjgl.lib}/lwjgl_test.jar" tofile="${lwjgl.temp}/jnlp/temp/lwjgl-${lwjgl.version}/lwjgl_test.jar"/> | |
28 | <copy file="${lwjgl.lib}/lwjgl_util.jar" tofile="${lwjgl.temp}/jnlp/temp/lwjgl-${lwjgl.version}/lwjgl_util.jar"/> | |
27 | 29 | |
28 | 30 | <!-- move files to unified structure --> |
29 | 31 | <move todir="${lwjgl.temp}/jnlp/temp"> |
35 | 37 | <!-- move relevant files to root --> |
36 | 38 | <move todir="${lwjgl.temp}/jnlp/" flatten="true"> |
37 | 39 | <fileset dir="${lwjgl.temp}/jnlp/temp"> |
38 | <include name="**/**.jar"/> | |
40 | <include name="**/jinput.jar"/> | |
41 | <include name="**/lwjgl*.jar"/> | |
39 | 42 | </fileset> |
40 | 43 | </move> |
41 | 44 | |
45 | <!-- update Trusted-Library --> | |
46 | <jar destfile="${lwjgl.temp}/jnlp/lwjgl.jar" update="true"> | |
47 | <manifest> | |
48 | <attribute name="Sealed" value="true"/> | |
49 | <attribute name="Trusted-Library" value="true"/> | |
50 | </manifest> | |
51 | </jar> | |
52 | ||
53 | <jar destfile="${lwjgl.temp}/jnlp/jinput.jar" update="true"> | |
54 | <manifest> | |
55 | <attribute name="Sealed" value="true"/> | |
56 | </manifest> | |
57 | </jar> | |
58 | ||
59 | <jar destfile="${lwjgl.temp}/jnlp/lwjgl_util.jar" update="true"> | |
60 | <manifest> | |
61 | <attribute name="Sealed" value="true"/> | |
62 | </manifest> | |
63 | </jar> | |
64 | ||
42 | 65 | <!-- create native jars --> |
43 | <jar destfile="${lwjgl.temp}/jnlp/native_windows.jar" basedir="${lwjgl.temp}/jnlp/temp/native/windows"/> | |
44 | <jar destfile="${lwjgl.temp}/jnlp/native_linux.jar" basedir="${lwjgl.temp}/jnlp/temp/native/linux"/> | |
45 | <jar destfile="${lwjgl.temp}/jnlp/native_macosx.jar" basedir="${lwjgl.temp}/jnlp/temp/native/macosx"/> | |
46 | <jar destfile="${lwjgl.temp}/jnlp/native_solaris.jar" basedir="${lwjgl.temp}/jnlp/temp/native/solaris"/> | |
66 | <jar destfile="${lwjgl.temp}/jnlp/native_windows.jar" basedir="${lwjgl.temp}/jnlp/temp/native/windows"> | |
67 | <manifest> | |
68 | <attribute name="Sealed" value="true"/> | |
69 | </manifest> | |
70 | </jar> | |
71 | ||
72 | <jar destfile="${lwjgl.temp}/jnlp/native_linux.jar" basedir="${lwjgl.temp}/jnlp/temp/native/linux"> | |
73 | <manifest> | |
74 | <attribute name="Sealed" value="true"/> | |
75 | </manifest> | |
76 | </jar> | |
77 | ||
78 | <jar destfile="${lwjgl.temp}/jnlp/native_macosx.jar" basedir="${lwjgl.temp}/jnlp/temp/native/macosx"> | |
79 | <manifest> | |
80 | <attribute name="Sealed" value="true"/> | |
81 | </manifest> | |
82 | </jar> | |
83 | ||
84 | <jar destfile="${lwjgl.temp}/jnlp/native_solaris.jar" basedir="${lwjgl.temp}/jnlp/temp/native/solaris"> | |
85 | <manifest> | |
86 | <attribute name="Sealed" value="true"/> | |
87 | </manifest> | |
88 | </jar> | |
47 | 89 | |
48 | 90 | <!-- create media jar --> |
49 | <jar destfile="${lwjgl.temp}/jnlp/media.jar" basedir="${lwjgl.res}"/> | |
91 | <jar destfile="${lwjgl.temp}/jnlp/media.jar" basedir="${lwjgl.res}"> | |
92 | <manifest> | |
93 | <attribute name="Sealed" value="true"/> | |
94 | </manifest> | |
95 | </jar> | |
50 | 96 | |
51 | 97 | <!-- sign 'em --> |
52 | 98 | <signjar jar="${lwjgl.temp}/jnlp/lwjgl.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/> |
56 | 102 | <signjar jar="${lwjgl.temp}/jnlp/native_macosx.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/> |
57 | 103 | <signjar jar="${lwjgl.temp}/jnlp/native_windows.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/> |
58 | 104 | <signjar jar="${lwjgl.temp}/jnlp/jinput.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/> |
105 | <signjar jar="${lwjgl.temp}/jnlp/media.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/> | |
59 | 106 | </target> |
60 | 107 | </project>⏎ |
0 | <project name="webstart"> | |
1 | <target name="webstart_demo" depends="jars"> | |
2 | <antcall target="-webstart_demo"> | |
3 | <param name="keystore" value="applet/lwjglkeystore"/> | |
4 | <param name="alias" value="lwjgl"/> | |
5 | <param name="password" value="123456"/> | |
6 | </antcall> | |
7 | </target> | |
8 | ||
9 | <target name="webstart_demo-release"> | |
10 | <input message="Please type the password for the keystore" addproperty="sign.pwd"/> | |
11 | ||
12 | <antcall target="-webstart_demo"> | |
13 | <param name="keystore" value="signing/matzon_java_code_signing.keystore"/> | |
14 | <param name="alias" value="oddlabs_java_code_signing"/> | |
15 | <param name="password" value="${sign.pwd}"/> | |
16 | </antcall> | |
17 | </target> | |
18 | ||
19 | <!-- --> | |
20 | <target name="-webstart_demo" description="Using released files, creates the necessary files used for jnlp demos"> | |
21 | ||
22 | <!-- delete existing temp --> | |
23 | <delete dir="${lwjgl.temp}"/> | |
24 | ||
25 | <!-- unzip common files --> | |
26 | <unzip src="${lwjgl.dist}/lwjgl-${lwjgl.version}.zip" dest="${lwjgl.temp}/jnlp/temp" overwrite="true"/> | |
27 | ||
28 | <!-- move files to unified structure --> | |
29 | <move todir="${lwjgl.temp}/jnlp/temp"> | |
30 | <fileset dir="${lwjgl.temp}/jnlp/temp/lwjgl-${lwjgl.version}/"> | |
31 | <include name="**"/> | |
32 | </fileset> | |
33 | </move> | |
34 | ||
35 | <!-- move relevant files to root --> | |
36 | <move todir="${lwjgl.temp}/jnlp/" flatten="true"> | |
37 | <fileset dir="${lwjgl.temp}/jnlp/temp"> | |
38 | <include name="**/**.jar"/> | |
39 | </fileset> | |
40 | </move> | |
41 | ||
42 | <!-- create native jars --> | |
43 | <jar destfile="${lwjgl.temp}/jnlp/native_windows.jar" basedir="${lwjgl.temp}/jnlp/temp/native/windows"/> | |
44 | <jar destfile="${lwjgl.temp}/jnlp/native_linux.jar" basedir="${lwjgl.temp}/jnlp/temp/native/linux"/> | |
45 | <jar destfile="${lwjgl.temp}/jnlp/native_macosx.jar" basedir="${lwjgl.temp}/jnlp/temp/native/macosx"/> | |
46 | <jar destfile="${lwjgl.temp}/jnlp/native_solaris.jar" basedir="${lwjgl.temp}/jnlp/temp/native/solaris"/> | |
47 | ||
48 | <!-- add media and trusted info --> | |
49 | <jar destfile="${lwjgl.temp}/jnlp/lwjgl_test.jar" update="true"> | |
50 | <manifest> | |
51 | <attribute name="Sealed" value="true"/> | |
52 | <attribute name="Trusted-Only" value="true"/> | |
53 | </manifest> | |
54 | </jar> | |
55 | ||
56 | <jar destfile="${lwjgl.temp}/jnlp/lwjgl_util.jar" update="true"> | |
57 | <fileset dir="${lwjgl.res}"/> | |
58 | <manifest> | |
59 | <attribute name="Sealed" value="true"/> | |
60 | <attribute name="Trusted-Library" value="true"/> | |
61 | </manifest> | |
62 | </jar> | |
63 | ||
64 | <jar destfile="${lwjgl.temp}/jnlp/jinput.jar" update="true"> | |
65 | <manifest> | |
66 | <attribute name="Sealed" value="true"/> | |
67 | <attribute name="Trusted-Library" value="true"/> | |
68 | </manifest> | |
69 | </jar> | |
70 | ||
71 | <!-- sign 'em --> | |
72 | <signjar jar="${lwjgl.temp}/jnlp/lwjgl.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/> | |
73 | <signjar jar="${lwjgl.temp}/jnlp/lwjgl_util.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/> | |
74 | <signjar jar="${lwjgl.temp}/jnlp/jinput.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/> | |
75 | ||
76 | <signjar jar="${lwjgl.temp}/jnlp/native_solaris.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/> | |
77 | <signjar jar="${lwjgl.temp}/jnlp/native_linux.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/> | |
78 | <signjar jar="${lwjgl.temp}/jnlp/native_macosx.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/> | |
79 | <signjar jar="${lwjgl.temp}/jnlp/native_windows.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/> | |
80 | ||
81 | <signjar jar="${lwjgl.temp}/jnlp/lwjgl_test.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/> | |
82 | ||
83 | </target> | |
84 | </project>⏎ |
47 | 47 | * </p> |
48 | 48 | * @author cix_foo <cix_foo@users.sourceforge.net> |
49 | 49 | * @author elias_naur <elias_naur@users.sourceforge.net> |
50 | * @version $Revision: 3279 $ | |
51 | * $Id: BufferChecks.java 3279 2010-03-11 21:06:49Z spasi $ | |
50 | * @version $Revision: 3334 $ | |
51 | * $Id: BufferChecks.java 3334 2010-04-22 23:21:48Z spasi $ | |
52 | 52 | */ |
53 | 53 | public class BufferChecks { |
54 | 54 | /** Static methods only! */ |
59 | 59 | * Helper methods to ensure a function pointer is not-null (0) |
60 | 60 | */ |
61 | 61 | public static void checkFunctionAddress(long pointer) { |
62 | if (pointer == 0) { | |
62 | if (LWJGLUtil.CHECKS && pointer == 0) { | |
63 | 63 | throw new IllegalStateException("Function is not supported"); |
64 | 64 | } |
65 | 65 | } |
68 | 68 | * Helper methods to ensure a ByteBuffer is null-terminated |
69 | 69 | */ |
70 | 70 | public static void checkNullTerminated(ByteBuffer buf) { |
71 | if (buf.get(buf.limit() - 1) != 0) { | |
71 | if ( LWJGLUtil.CHECKS && buf.get(buf.limit() - 1) != 0) { | |
72 | 72 | throw new IllegalArgumentException("Missing null termination"); |
73 | 73 | } |
74 | 74 | } |
75 | 75 | |
76 | 76 | public static void checkNullTerminated(ByteBuffer buf, int count) { |
77 | int nullFound = 0; | |
78 | for ( int i = buf.position(); i < buf.limit(); i++ ) { | |
79 | if ( buf.get(i) == 0 ) | |
80 | nullFound++; | |
81 | } | |
82 | ||
83 | if ( nullFound < count ) | |
84 | throw new IllegalArgumentException("Missing null termination"); | |
77 | if ( LWJGLUtil.CHECKS ) { | |
78 | int nullFound = 0; | |
79 | for ( int i = buf.position(); i < buf.limit(); i++ ) { | |
80 | if ( buf.get(i) == 0 ) | |
81 | nullFound++; | |
82 | } | |
83 | ||
84 | if ( nullFound < count ) | |
85 | throw new IllegalArgumentException("Missing null termination"); | |
86 | } | |
85 | 87 | } |
86 | 88 | |
87 | 89 | /** Helper methods to ensure an IntBuffer is null-terminated */ |
92 | 94 | } |
93 | 95 | |
94 | 96 | public static void checkNotNull(Object o) { |
95 | if (o == null) | |
97 | if ( LWJGLUtil.CHECKS && o == null) | |
96 | 98 | throw new IllegalArgumentException("Null argument"); |
97 | 99 | } |
98 | 100 | |
100 | 102 | * Helper methods to ensure a buffer is direct (and, implicitly, non-null). |
101 | 103 | */ |
102 | 104 | public static void checkDirect(ByteBuffer buf) { |
103 | if (!buf.isDirect()) { | |
105 | if ( LWJGLUtil.CHECKS && !buf.isDirect()) { | |
104 | 106 | throw new IllegalArgumentException("ByteBuffer is not direct"); |
105 | 107 | } |
106 | 108 | } |
107 | 109 | |
108 | 110 | public static void checkDirect(ShortBuffer buf) { |
109 | if (!buf.isDirect()) { | |
111 | if ( LWJGLUtil.CHECKS && !buf.isDirect()) { | |
110 | 112 | throw new IllegalArgumentException("ShortBuffer is not direct"); |
111 | 113 | } |
112 | 114 | } |
113 | 115 | |
114 | 116 | public static void checkDirect(IntBuffer buf) { |
115 | if (!buf.isDirect()) { | |
117 | if ( LWJGLUtil.CHECKS && !buf.isDirect()) { | |
116 | 118 | throw new IllegalArgumentException("IntBuffer is not direct"); |
117 | 119 | } |
118 | 120 | } |
119 | 121 | |
120 | 122 | public static void checkDirect(LongBuffer buf) { |
121 | if (!buf.isDirect()) { | |
123 | if ( LWJGLUtil.CHECKS && !buf.isDirect()) { | |
122 | 124 | throw new IllegalArgumentException("LongBuffer is not direct"); |
123 | 125 | } |
124 | 126 | } |
125 | 127 | |
126 | 128 | public static void checkDirect(FloatBuffer buf) { |
127 | if (!buf.isDirect()) { | |
129 | if ( LWJGLUtil.CHECKS && !buf.isDirect()) { | |
128 | 130 | throw new IllegalArgumentException("FloatBuffer is not direct"); |
129 | 131 | } |
130 | 132 | } |
131 | 133 | |
132 | 134 | public static void checkDirect(DoubleBuffer buf) { |
133 | if (!buf.isDirect()) { | |
135 | if ( LWJGLUtil.CHECKS && !buf.isDirect()) { | |
134 | 136 | throw new IllegalArgumentException("DoubleBuffer is not direct"); |
135 | 137 | } |
136 | 138 | } |
153 | 155 | * @throws IllegalArgumentException |
154 | 156 | */ |
155 | 157 | public static void checkBufferSize(Buffer buf, int size) { |
156 | if (buf.remaining() < size) { | |
158 | if ( LWJGLUtil.CHECKS && buf.remaining() < size) { | |
157 | 159 | throwBufferSizeException(buf, size); |
158 | 160 | } |
159 | 161 | } |
160 | 162 | |
161 | 163 | public static void checkBuffer(ByteBuffer buf, int size) { |
162 | checkBufferSize(buf, size); | |
163 | checkDirect(buf); | |
164 | if ( LWJGLUtil.CHECKS ) { | |
165 | checkBufferSize(buf, size); | |
166 | checkDirect(buf); | |
167 | } | |
164 | 168 | } |
165 | 169 | |
166 | 170 | public static void checkBuffer(ShortBuffer buf, int size) { |
167 | checkBufferSize(buf, size); | |
168 | checkDirect(buf); | |
171 | if ( LWJGLUtil.CHECKS ) { | |
172 | checkBufferSize(buf, size); | |
173 | checkDirect(buf); | |
174 | } | |
169 | 175 | } |
170 | 176 | |
171 | 177 | public static void checkBuffer(IntBuffer buf, int size) { |
172 | checkBufferSize(buf, size); | |
173 | checkDirect(buf); | |
178 | if ( LWJGLUtil.CHECKS ) { | |
179 | checkBufferSize(buf, size); | |
180 | checkDirect(buf); | |
181 | } | |
174 | 182 | } |
175 | 183 | |
176 | 184 | public static void checkBuffer(LongBuffer buf, int size) { |
177 | checkBufferSize(buf, size); | |
178 | checkDirect(buf); | |
185 | if ( LWJGLUtil.CHECKS ) { | |
186 | checkBufferSize(buf, size); | |
187 | checkDirect(buf); | |
188 | } | |
179 | 189 | } |
180 | 190 | |
181 | 191 | public static void checkBuffer(FloatBuffer buf, int size) { |
182 | checkBufferSize(buf, size); | |
183 | checkDirect(buf); | |
192 | if ( LWJGLUtil.CHECKS ) { | |
193 | checkBufferSize(buf, size); | |
194 | checkDirect(buf); | |
195 | } | |
184 | 196 | } |
185 | 197 | |
186 | 198 | public static void checkBuffer(DoubleBuffer buf, int size) { |
187 | checkBufferSize(buf, size); | |
188 | checkDirect(buf); | |
199 | if ( LWJGLUtil.CHECKS ) { | |
200 | checkBufferSize(buf, size); | |
201 | checkDirect(buf); | |
202 | } | |
189 | 203 | } |
190 | 204 | } |
48 | 48 | * </p> |
49 | 49 | * |
50 | 50 | * @author Brian Matzon <brian@matzon.dk> |
51 | * @version $Revision: 2983 $ | |
52 | * $Id: LWJGLUtil.java 2983 2008-04-07 18:36:09Z matzon $ | |
51 | * @version $Revision: 3334 $ | |
52 | * $Id: LWJGLUtil.java 3334 2010-04-22 23:21:48Z spasi $ | |
53 | 53 | */ |
54 | 54 | public class LWJGLUtil { |
55 | 55 | public static final int PLATFORM_LINUX = 1; |
265 | 265 | |
266 | 266 | /** Debug flag. */ |
267 | 267 | public static final boolean DEBUG = getPrivilegedBoolean("org.lwjgl.util.Debug"); |
268 | ||
268 | ||
269 | public static final boolean CHECKS = !getPrivilegedBoolean("org.lwjgl.util.NoChecks"); | |
270 | ||
269 | 271 | static { |
270 | 272 | LWJGLIcon16x16.flip(); |
271 | 273 | LWJGLIcon32x32.flip(); |
45 | 45 | * System class (named Sys so as not to conflict with java.lang.System) |
46 | 46 | * </p> |
47 | 47 | * @author cix_foo <cix_foo@users.sourceforge.net> |
48 | * @version $Revision: 3328 $ | |
49 | * $Id: Sys.java 3328 2010-04-15 18:03:54Z matzon $ | |
48 | * @version $Revision: 3353 $ | |
49 | * $Id: Sys.java 3353 2010-05-24 22:39:06Z matzon $ | |
50 | 50 | */ |
51 | 51 | public final class Sys { |
52 | 52 | /** The native library name */ |
53 | 53 | private static final String JNI_LIBRARY_NAME = "lwjgl"; |
54 | 54 | |
55 | 55 | /** Current version of library */ |
56 | private static final String VERSION = "2.4.2"; | |
56 | private static final String VERSION = "2.5"; | |
57 | 57 | |
58 | 58 | /** The implementation instance to delegate platform specific behavior to */ |
59 | 59 | private final static SysImplementation implementation; |
58 | 58 | * @author cix_foo <cix_foo@users.sourceforge.net> |
59 | 59 | * @author elias_naur <elias_naur@users.sourceforge.net> |
60 | 60 | * @author Brian Matzon <brian@matzon.dk> |
61 | * @version $Revision: 3297 $ | |
62 | * $Id: Mouse.java 3297 2010-03-27 16:04:30Z kappa1 $ | |
61 | * @version $Revision: 3337 $ | |
62 | * $Id: Mouse.java 3337 2010-04-29 17:37:18Z matzon $ | |
63 | 63 | */ |
64 | 64 | public class Mouse { |
65 | 65 | /** Internal use - event size in bytes */ |
466 | 466 | } |
467 | 467 | |
468 | 468 | /** |
469 | * @return Current events delta x. Only valid when the mouse is grabbed. | |
469 | * @return Current events delta x. | |
470 | 470 | */ |
471 | 471 | public static int getEventDX() { |
472 | 472 | synchronized (OpenGLPackageAccess.global_lock) { |
475 | 475 | } |
476 | 476 | |
477 | 477 | /** |
478 | * @return Current events delta y. Only valid when the mouse is grabbed. | |
478 | * @return Current events delta y. | |
479 | 479 | */ |
480 | 480 | public static int getEventDY() { |
481 | 481 | synchronized (OpenGLPackageAccess.global_lock) { |
484 | 484 | } |
485 | 485 | |
486 | 486 | /** |
487 | * @return Current events absolute x. Only valid when the mouse is not grabbed. | |
487 | * @return Current events absolute x. | |
488 | 488 | */ |
489 | 489 | public static int getEventX() { |
490 | 490 | synchronized (OpenGLPackageAccess.global_lock) { |
493 | 493 | } |
494 | 494 | |
495 | 495 | /** |
496 | * @return Current events absolute y. Only valid when the mouse is not grabbed. | |
496 | * @return Current events absolute y. | |
497 | 497 | */ |
498 | 498 | public static int getEventY() { |
499 | 499 | synchronized (OpenGLPackageAccess.global_lock) { |
549 | 549 | } |
550 | 550 | |
551 | 551 | /** |
552 | * @return Movement on the x axis since last time getDX() was called. Only valid when the mouse is grabbed. | |
552 | * @return Movement on the x axis since last time getDX() was called. | |
553 | 553 | */ |
554 | 554 | public static int getDX() { |
555 | 555 | synchronized (OpenGLPackageAccess.global_lock) { |
560 | 560 | } |
561 | 561 | |
562 | 562 | /** |
563 | * @return Movement on the y axis since last time getDY() was called. Only valid when the mouse is grabbed. | |
563 | * @return Movement on the y axis since last time getDY() was called. | |
564 | 564 | */ |
565 | 565 | public static int getDY() { |
566 | 566 | synchronized (OpenGLPackageAccess.global_lock) { |
41 | 41 | * </p> |
42 | 42 | * |
43 | 43 | * @author Brian Matzon <brian@matzon.dk> |
44 | * @version $Revision: 3182 $ | |
45 | * $Id: AL.java 3182 2009-03-17 21:36:18Z matzon $ | |
44 | * @version $Revision: 3348 $ | |
45 | * $Id: AL.java 3348 2010-05-24 21:54:37Z matzon $ | |
46 | 46 | */ |
47 | 47 | public final class AL { |
48 | 48 | /** ALCdevice instance. */ |
159 | 159 | |
160 | 160 | if(openDevice) { |
161 | 161 | device = ALC10.alcOpenDevice(deviceArguments); |
162 | if (device == null) | |
162 | if (device == null) { | |
163 | 163 | throw new LWJGLException("Could not open ALC device"); |
164 | } | |
164 | 165 | |
165 | 166 | if (contextFrequency == -1) { |
166 | 167 | context = ALC10.alcCreateContext(device, null); |
176 | 177 | throw e; |
177 | 178 | } |
178 | 179 | |
179 | ALC11.initialize(); | |
180 | ALC11.initialize(); | |
181 | ||
182 | // Load EFX10 native stubs if ALC_EXT_EFX is supported. | |
183 | // Is there any situation where the current device supports ALC_EXT_EFX and one | |
184 | // later created by the user does not? | |
185 | // Do we have to call resetNativeStubs(EFX10.class); somewhere? Not done for AL11 | |
186 | // either. | |
187 | // This can either be here or in ALC11, since ALC_EXT_EFX indirectly requires AL 1.1 | |
188 | // for functions like alSource3i. | |
189 | if (ALC10.alcIsExtensionPresent(device, EFX10.ALC_EXT_EFX_NAME)){ | |
190 | EFX10.initNativeStubs(); | |
191 | } | |
180 | 192 | } |
181 | 193 | |
182 | 194 | /** |
204 | 216 | device = null; |
205 | 217 | } |
206 | 218 | resetNativeStubs(AL10.class); |
219 | resetNativeStubs(AL11.class); | |
207 | 220 | resetNativeStubs(ALC10.class); |
208 | 221 | resetNativeStubs(ALC11.class); |
222 | resetNativeStubs(EFX10.class); | |
209 | 223 | |
210 | 224 | if (created) |
211 | 225 | nDestroy(); |
57 | 57 | public static final int ALC_CAPTURE_DEVICE_SPECIFIER = 0x310; |
58 | 58 | public static final int ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER = 0x311; |
59 | 59 | public static final int ALC_CAPTURE_SAMPLES = 0x312; |
60 | ||
61 | public static final int ALC_MONO_SOURCES = 0x1010; | |
62 | public static final int ALC_STEREO_SOURCES = 0x1011; | |
60 | 63 | |
61 | 64 | /** |
62 | 65 | * The alcCaptureOpenDevice function allows the application to connect to a capture |
0 | /* | |
1 | * Copyright (c) 2002-2010 LWJGL Project | |
2 | * All rights reserved. | |
3 | * | |
4 | * Redistribution and use in source and binary forms, with or without | |
5 | * modification, are permitted provided that the following conditions are | |
6 | * met: | |
7 | * | |
8 | * * Redistributions of source code must retain the above copyright | |
9 | * notice, this list of conditions and the following disclaimer. | |
10 | * | |
11 | * * Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | |
14 | * | |
15 | * * Neither the name of 'LWJGL' nor the names of | |
16 | * its contributors may be used to endorse or promote products derived | |
17 | * from this software without specific prior written permission. | |
18 | * | |
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | |
23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
24 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
25 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
26 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | |
27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | |
31 | package org.lwjgl.openal; | |
32 | ||
33 | /** | |
34 | * Utility class for the OpenAL extension ALC_EXT_EFX. Provides functions to check for the extension | |
35 | * and support of various effects and filters. | |
36 | * <p> | |
37 | * Currently supports ALC_EXT_EFX version 1.0 effects and filters. | |
38 | * | |
39 | * @author Ciardhubh <ciardhubh[at]ciardhubh.de> | |
40 | * @version $Revision$ | |
41 | * $Id$ | |
42 | */ | |
43 | public final class EFXUtil { | |
44 | ||
45 | /** Constant for testSupportGeneric to check an effect. */ | |
46 | private static final int EFFECT = 1111; | |
47 | /** Constant for testSupportGeneric to check a filter. */ | |
48 | private static final int FILTER = 2222; | |
49 | ||
50 | /** Utility class, hidden contructor. */ | |
51 | private EFXUtil() { | |
52 | } | |
53 | ||
54 | /** | |
55 | * Checks if OpenAL implementation is loaded and supports ALC_EXT_EFX. | |
56 | * | |
57 | * @return True if ALC_EXT_EFX is supported, false if not. | |
58 | * @throws OpenALException If OpenAL has not been created yet. | |
59 | */ | |
60 | public static boolean isEfxSupported() { | |
61 | if (!AL.isCreated()) { | |
62 | throw new OpenALException("OpenAL has not been created."); | |
63 | } | |
64 | return ALC10.alcIsExtensionPresent(AL.getDevice(), EFX10.ALC_EXT_EFX_NAME); | |
65 | } | |
66 | ||
67 | /** | |
68 | * Tests OpenAL to see whether the given effect type is supported. This is done by creating an | |
69 | * effect of the given type. If creation succeeds the effect is supported. | |
70 | * | |
71 | * @param effectType Type of effect whose support is to be tested, e.g. AL_EFFECT_REVERB. | |
72 | * @return True if it is supported, false if not. | |
73 | * @throws OpenALException If the request fails due to an AL_OUT_OF_MEMORY error or OpenAL has | |
74 | * not been created yet. | |
75 | * @throws IllegalArgumentException effectType is not a valid effect type. | |
76 | */ | |
77 | public static boolean isEffectSupported(final int effectType) { | |
78 | // Make sure type is a real effect. | |
79 | switch (effectType) { | |
80 | case EFX10.AL_EFFECT_NULL: | |
81 | case EFX10.AL_EFFECT_EAXREVERB: | |
82 | case EFX10.AL_EFFECT_REVERB: | |
83 | case EFX10.AL_EFFECT_CHORUS: | |
84 | case EFX10.AL_EFFECT_DISTORTION: | |
85 | case EFX10.AL_EFFECT_ECHO: | |
86 | case EFX10.AL_EFFECT_FLANGER: | |
87 | case EFX10.AL_EFFECT_FREQUENCY_SHIFTER: | |
88 | case EFX10.AL_EFFECT_VOCAL_MORPHER: | |
89 | case EFX10.AL_EFFECT_PITCH_SHIFTER: | |
90 | case EFX10.AL_EFFECT_RING_MODULATOR: | |
91 | case EFX10.AL_EFFECT_AUTOWAH: | |
92 | case EFX10.AL_EFFECT_COMPRESSOR: | |
93 | case EFX10.AL_EFFECT_EQUALIZER: | |
94 | break; | |
95 | default: | |
96 | throw new IllegalArgumentException("Unknown or invalid effect type: " + effectType); | |
97 | } | |
98 | ||
99 | return testSupportGeneric(EFFECT, effectType); | |
100 | } | |
101 | ||
102 | /** | |
103 | * Tests OpenAL to see whether the given filter type is supported. This is done by creating a | |
104 | * filter of the given type. If creation succeeds the filter is supported. | |
105 | * | |
106 | * @param filterType Type of filter whose support is to be tested, e.g. AL_FILTER_LOWPASS. | |
107 | * @return True if it is supported, false if not. | |
108 | * @throws OpenALException If the request fails due to an AL_OUT_OF_MEMORY error or OpenAL has | |
109 | * not been created yet. | |
110 | * @throws IllegalArgumentException filterType is not a valid filter type. | |
111 | */ | |
112 | public static boolean isFilterSupported(final int filterType) { | |
113 | // Make sure type is a real filter. | |
114 | switch (filterType) { | |
115 | case EFX10.AL_FILTER_NULL: | |
116 | case EFX10.AL_FILTER_LOWPASS: | |
117 | case EFX10.AL_FILTER_HIGHPASS: | |
118 | case EFX10.AL_FILTER_BANDPASS: | |
119 | break; | |
120 | default: | |
121 | throw new IllegalArgumentException("Unknown or invalid filter type: " + filterType); | |
122 | } | |
123 | ||
124 | return testSupportGeneric(FILTER, filterType); | |
125 | } | |
126 | ||
127 | /** | |
128 | * Generic test function to see if an EFX object supports a given kind of type. Works for | |
129 | * effects and filters. | |
130 | * | |
131 | * @param objectType Type of object to test. Must be either EFXUtil.EFFECT or EFXUtil.FILTER. | |
132 | * @param typeValue OpenAL type the object should be tested for support, e.g. AL_FILTER_LOWPASS | |
133 | * or AL_EFFECT_REVERB. | |
134 | * @return True if object supports typeValue, false else. | |
135 | */ | |
136 | private static boolean testSupportGeneric(final int objectType, final int typeValue) { | |
137 | // Check for supported objectType. | |
138 | switch (objectType) { | |
139 | case EFFECT: | |
140 | case FILTER: | |
141 | break; | |
142 | default: | |
143 | throw new IllegalArgumentException("Invalid objectType: " + objectType); | |
144 | } | |
145 | ||
146 | boolean supported = false; | |
147 | if (isEfxSupported()) { | |
148 | ||
149 | // Try to create object in order to check AL's response. | |
150 | AL10.alGetError(); | |
151 | int genError; | |
152 | int testObject = 0; | |
153 | try { | |
154 | switch (objectType) { // Create object based on type | |
155 | case EFFECT: | |
156 | testObject = EFX10.alGenEffects(); | |
157 | break; | |
158 | case FILTER: | |
159 | testObject = EFX10.alGenFilters(); | |
160 | break; | |
161 | default: | |
162 | throw new IllegalArgumentException("Invalid objectType: " + objectType); | |
163 | } | |
164 | genError = AL10.alGetError(); | |
165 | } catch (final OpenALException debugBuildException) { | |
166 | // Hack because OpenALException hides the original error code (short of parsing the | |
167 | // error message String which would break if it gets changed). | |
168 | if (debugBuildException.getMessage().contains("AL_OUT_OF_MEMORY")) { | |
169 | genError = AL10.AL_OUT_OF_MEMORY; | |
170 | } else { | |
171 | genError = AL10.AL_INVALID_OPERATION; | |
172 | } | |
173 | } | |
174 | ||
175 | if (genError == AL10.AL_NO_ERROR) { | |
176 | // Successfully created, now try to set type. | |
177 | AL10.alGetError(); | |
178 | int setError; | |
179 | try { | |
180 | switch (objectType) { // Set based on object type | |
181 | case EFFECT: | |
182 | EFX10.alEffecti(testObject, EFX10.AL_EFFECT_TYPE, typeValue); | |
183 | break; | |
184 | case FILTER: | |
185 | EFX10.alFilteri(testObject, EFX10.AL_FILTER_TYPE, typeValue); | |
186 | break; | |
187 | default: | |
188 | throw new IllegalArgumentException("Invalid objectType: " + objectType); | |
189 | } | |
190 | setError = AL10.alGetError(); | |
191 | } catch (final OpenALException debugBuildException) { | |
192 | // Hack because OpenALException hides the original error code (short of parsing | |
193 | // the error message String which would break when it gets changed). | |
194 | setError = AL10.AL_INVALID_VALUE; | |
195 | } | |
196 | ||
197 | if (setError == AL10.AL_NO_ERROR) { | |
198 | supported = true; | |
199 | } | |
200 | ||
201 | // Cleanup | |
202 | try { | |
203 | switch (objectType) { // Set based on object type | |
204 | case EFFECT: | |
205 | EFX10.alDeleteEffects(testObject); | |
206 | break; | |
207 | case FILTER: | |
208 | EFX10.alDeleteFilters(testObject); | |
209 | break; | |
210 | default: | |
211 | throw new IllegalArgumentException("Invalid objectType: " + objectType); | |
212 | } | |
213 | } catch (final OpenALException debugBuildException) { | |
214 | // Don't care about cleanup errors. | |
215 | } | |
216 | ||
217 | } else if (genError == AL10.AL_OUT_OF_MEMORY) { | |
218 | throw new OpenALException(genError); | |
219 | } | |
220 | } | |
221 | ||
222 | return supported; | |
223 | } | |
224 | } |
0 | /* | |
1 | * Copyright (c) 2002-2008 LWJGL Project | |
2 | * All rights reserved. | |
3 | * | |
4 | * Redistribution and use in source and binary forms, with or without | |
5 | * modification, are permitted provided that the following conditions are | |
6 | * met: | |
7 | * | |
8 | * * Redistributions of source code must retain the above copyright | |
9 | * notice, this list of conditions and the following disclaimer. | |
10 | * | |
11 | * * Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | |
14 | * | |
15 | * * Neither the name of 'LWJGL' nor the names of | |
16 | * its contributors may be used to endorse or promote products derived | |
17 | * from this software without specific prior written permission. | |
18 | * | |
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | |
23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
24 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
25 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
26 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | |
27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | |
31 | package org.lwjgl.opengl; | |
32 | ||
33 | /** | |
34 | * Instances of this class are needed to use the callback functionality of the AMD_debug_output extension. | |
35 | * A debug context must be current before creating instances of this class. Users of this class may provide | |
36 | * implementations of the {@code Handler} interface to receive notifications. The same {@code Handler} | |
37 | * instance may be used by different contexts but it is not recommended. Handler notifications are synchronized. | |
38 | * | |
39 | * @author Spasi | |
40 | */ | |
41 | public final class AMDDebugOutputCallback implements PointerWrapper { | |
42 | ||
43 | /** Severity levels. */ | |
44 | private static final int GL_DEBUG_SEVERITY_HIGH_AMD = 0x9146, | |
45 | GL_DEBUG_SEVERITY_MEDIUM_AMD = 0x9147, | |
46 | GL_DEBUG_SEVERITY_LOW_AMD = 0x9148; | |
47 | ||
48 | /** Categories */ | |
49 | private static final int GL_DEBUG_CATEGORY_API_ERROR_AMD = 0x9149, | |
50 | GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD = 0x914A, | |
51 | GL_DEBUG_CATEGORY_DEPRECATION_AMD = 0x914B, | |
52 | GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD = 0x914C, | |
53 | GL_DEBUG_CATEGORY_PERFORMANCE_AMD = 0x914D, | |
54 | GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD = 0x914E, | |
55 | GL_DEBUG_CATEGORY_APPLICATION_AMD = 0x914F, | |
56 | GL_DEBUG_CATEGORY_OTHER_AMD = 0x9150; | |
57 | ||
58 | private final long pointer; | |
59 | ||
60 | /** | |
61 | * Creates a AMDDebugOutputCallback with a default callback handler. | |
62 | * The default handler will simply print the message on System.err. | |
63 | */ | |
64 | public AMDDebugOutputCallback() { | |
65 | this(new Handler() { | |
66 | public void handleMessage(final int id, final int category, final int severity, final String message) { | |
67 | System.err.println("[LWJGL] AMD_debug_output message"); | |
68 | System.err.println("\tID: " + id); | |
69 | ||
70 | String description; | |
71 | switch ( category ) { | |
72 | case GL_DEBUG_CATEGORY_API_ERROR_AMD: | |
73 | description = "API ERROR"; | |
74 | break; | |
75 | case GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD: | |
76 | description = "WINDOW SYSTEM"; | |
77 | break; | |
78 | case GL_DEBUG_CATEGORY_DEPRECATION_AMD: | |
79 | description = "DEPRECATION"; | |
80 | break; | |
81 | case GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD: | |
82 | description = "UNDEFINED BEHAVIOR"; | |
83 | break; | |
84 | case GL_DEBUG_CATEGORY_PERFORMANCE_AMD: | |
85 | description = "PERFORMANCE"; | |
86 | break; | |
87 | case GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD: | |
88 | description = "SHADER COMPILER"; | |
89 | break; | |
90 | case GL_DEBUG_CATEGORY_APPLICATION_AMD: | |
91 | description = "APPLICATION"; | |
92 | break; | |
93 | case GL_DEBUG_CATEGORY_OTHER_AMD: | |
94 | description = "OTHER"; | |
95 | break; | |
96 | default: | |
97 | description = "Unknown (" + Integer.toHexString(category) + ")"; | |
98 | } | |
99 | System.err.println("\tCategory: " + description); | |
100 | ||
101 | switch ( severity ) { | |
102 | case GL_DEBUG_SEVERITY_HIGH_AMD: | |
103 | description = "HIGH"; | |
104 | break; | |
105 | case GL_DEBUG_SEVERITY_MEDIUM_AMD: | |
106 | description = "MEDIUM"; | |
107 | break; | |
108 | case GL_DEBUG_SEVERITY_LOW_AMD: | |
109 | description = "LOW"; | |
110 | break; | |
111 | default: | |
112 | description = "Unknown (" + Integer.toHexString(category) + ")"; | |
113 | } | |
114 | System.err.println("\tSeverity: " + description); | |
115 | ||
116 | System.err.println("\tMessage: " + message); | |
117 | } | |
118 | }); | |
119 | } | |
120 | ||
121 | /** | |
122 | * Creates a AMDDebugOutputCallback with the specified callback handlers. | |
123 | * The handler's {@code handleMessage} method will be called whenever | |
124 | * debug output is generated by the GL. | |
125 | * | |
126 | * @param handler the callback handler | |
127 | */ | |
128 | public AMDDebugOutputCallback(final Handler handler) { | |
129 | try { | |
130 | // We have to call registerHandler reflectively because we need this class to compile before we run the Generator. | |
131 | // The registerHandler method depends on org.lwjgl.opengl.Context, if we touched that we would need to compile | |
132 | // the whole library (which is not possible). | |
133 | Class.forName("org.lwjgl.opengl.AMDDebugOutputUtil").getMethod("registerHandler", new Class[] { Handler.class }).invoke(null, new Object[] { handler }); | |
134 | } catch (Exception e) { | |
135 | throw new RuntimeException(e.getCause() != null ? e.getCause() : e); | |
136 | } | |
137 | this.pointer = getFunctionPointer(); | |
138 | } | |
139 | ||
140 | public long getPointer() { | |
141 | return pointer; | |
142 | } | |
143 | ||
144 | private static native long getFunctionPointer(); | |
145 | ||
146 | /** Implementations of this interface can be used to receive AMD_debug_output notifications. */ | |
147 | public interface Handler { | |
148 | ||
149 | /** | |
150 | * This method will be called when an AMD_debug_output message is generated. | |
151 | * | |
152 | * @param id the message ID | |
153 | * @param category the message category | |
154 | * @param severity the message severity | |
155 | * @param message the string representation of the message. | |
156 | */ | |
157 | void handleMessage(int id, int category, int severity, String message); | |
158 | ||
159 | } | |
160 | ||
161 | } |
0 | package org.lwjgl.opengl; | |
1 | ||
2 | import org.lwjgl.opengl.AMDDebugOutputCallback.Handler; | |
3 | ||
4 | import java.nio.ByteBuffer; | |
5 | import java.util.Map; | |
6 | import java.util.WeakHashMap; | |
7 | ||
8 | /** | |
9 | * This class handles AMDDebugOutputCallback.Handler registration and notification. | |
10 | * We could have put this in AMDDebugOutputCallback, but we need to compile it for | |
11 | * the generator. Registration is done reflectively in the AMDDebugOutputCallback | |
12 | * constructor. | |
13 | * | |
14 | * @author Spasi | |
15 | */ | |
16 | final class AMDDebugOutputUtil { | |
17 | ||
18 | private static final Map handlers = new WeakHashMap(); | |
19 | ||
20 | private AMDDebugOutputUtil() {} | |
21 | ||
22 | public static void registerHandler(final Handler handler) { | |
23 | final Context ctx = Context.getCurrentContext(); | |
24 | if ( ctx == null ) | |
25 | throw new IllegalStateException("No context is current."); | |
26 | ||
27 | if ( !ctx.getContextAttribs().isDebug() ) | |
28 | throw new IllegalStateException("The current context is not a debug context."); | |
29 | ||
30 | if ( !GLContext.getCapabilities().GL_AMD_debug_output ) | |
31 | throw new IllegalStateException("AMD_debug_output is not supported."); | |
32 | ||
33 | handlers.put(ctx, handler); | |
34 | } | |
35 | ||
36 | /** | |
37 | * This method is called by native code. If finds the callback handler associated | |
38 | * with the current Thread and calls its {@code handleMessage} method. | |
39 | * | |
40 | * @param id the message ID | |
41 | * @param category the message category | |
42 | * @param severity the message severity | |
43 | * @param message the string representation of the message. | |
44 | * @param userParam the user-specified data specified in glDebugMessageCallbackAMD. For the current implementation this is always null and we ignore it. | |
45 | */ | |
46 | private static void messageCallback(final int id, final int category, final int severity, final String message, final ByteBuffer userParam) { | |
47 | synchronized ( GlobalLock.lock ) { | |
48 | final Context ctx = Context.getCurrentContext(); | |
49 | if ( ctx == null ) | |
50 | return; | |
51 | ||
52 | final Handler handler = (Handler)handlers.get(ctx); | |
53 | if ( handler != null ) | |
54 | handler.handleMessage(id, category, severity, message); | |
55 | } | |
56 | } | |
57 | ||
58 | } |
157 | 157 | final InfiniteCharSequence infiniteSeq = getInfiniteSeq(); |
158 | 158 | infiniteSeq.setString(string); |
159 | 159 | encoder.encode(infiniteSeq.buffer, buffer, true); |
160 | infiniteSeq.clear(); | |
160 | 161 | } |
161 | 162 | |
162 | 163 | /** |
46 | 46 | * <p/> |
47 | 47 | * |
48 | 48 | * @author $Author: spasi $ |
49 | * $Id: AWTGLCanvas.java 3116 2008-08-19 16:46:03Z spasi $ | |
50 | * @version $Revision: 3116 $ | |
49 | * $Id: AWTGLCanvas.java 3334 2010-04-22 23:21:48Z spasi $ | |
50 | * @version $Revision: 3334 $ | |
51 | 51 | */ |
52 | public class AWTGLCanvas extends Canvas implements Drawable, ComponentListener, HierarchyListener { | |
52 | public class AWTGLCanvas extends Canvas implements DrawableLWJGL, ComponentListener, HierarchyListener { | |
53 | 53 | |
54 | 54 | private static final long serialVersionUID = 1L; |
55 | 55 | |
108 | 108 | return context; |
109 | 109 | } |
110 | 110 | |
111 | /** This method should only be called internally. */ | |
112 | public Context createSharedContext() throws LWJGLException { | |
113 | synchronized ( SYNC_LOCK ) { | |
114 | if ( context == null ) throw new IllegalStateException("Canvas not yet displayable"); | |
115 | ||
116 | return new Context(peer_info, context.getContextAttribs(), context); | |
117 | } | |
118 | } | |
119 | ||
111 | 120 | /** Constructor using the default PixelFormat. */ |
112 | 121 | public AWTGLCanvas() throws LWJGLException { |
113 | 122 | this(new PixelFormat()); |
174 | 183 | */ |
175 | 184 | public void removeNotify() { |
176 | 185 | synchronized ( SYNC_LOCK ) { |
177 | destroyContext(); | |
186 | destroy(); | |
178 | 187 | super.removeNotify(); |
179 | 188 | } |
180 | 189 | } |
199 | 208 | if ( context == null ) |
200 | 209 | throw new IllegalStateException("Canvas not yet displayable"); |
201 | 210 | Context.swapBuffers(); |
211 | } | |
212 | } | |
213 | ||
214 | public boolean isCurrent() throws LWJGLException { | |
215 | synchronized ( SYNC_LOCK ) { | |
216 | if ( context == null ) throw new IllegalStateException("Canvas not yet displayable"); | |
217 | ||
218 | return context.isCurrent(); | |
219 | } | |
220 | } | |
221 | ||
222 | /** | |
223 | * Make the canvas' context current. It is highly recommended that the context | |
224 | * is only made current inside the AWT thread (for example in an overridden paintGL()). | |
225 | */ | |
226 | public void makeCurrent() throws LWJGLException { | |
227 | synchronized ( SYNC_LOCK ) { | |
228 | if ( context == null ) | |
229 | throw new IllegalStateException("Canvas not yet displayable"); | |
230 | context.makeCurrent(); | |
202 | 231 | } |
203 | 232 | } |
204 | 233 | |
211 | 240 | } |
212 | 241 | } |
213 | 242 | |
214 | /** | |
215 | * Make the canvas' context current. It is highly recommended that the context | |
216 | * is only made current inside the AWT thread (for example in an overridden paintGL()). | |
217 | */ | |
218 | public void makeCurrent() throws LWJGLException { | |
219 | synchronized ( SYNC_LOCK ) { | |
220 | if ( context == null ) | |
221 | throw new IllegalStateException("Canvas not yet displayable"); | |
222 | context.makeCurrent(); | |
223 | } | |
224 | } | |
225 | ||
226 | 243 | /** Destroy the OpenGL context. This happens when the component becomes undisplayable */ |
227 | private void destroyContext() { | |
244 | public final void destroy() { | |
228 | 245 | synchronized ( SYNC_LOCK ) { |
229 | 246 | try { |
230 | 247 | if ( context != null ) { |
268 | 285 | peer_info.lockAndGetHandle(); |
269 | 286 | try { |
270 | 287 | if ( context == null ) { |
271 | this.context = new Context(peer_info, attribs, drawable != null ? drawable.getContext() : null); | |
288 | this.context = new Context(peer_info, attribs, drawable != null ? ((DrawableLWJGL)drawable).getContext() : null); | |
272 | 289 | first_run = true; |
273 | 290 | } |
274 | 291 |
0 | package org.lwjgl.opengl; | |
1 | ||
2 | import org.lwjgl.LWJGLException; | |
3 | import org.lwjgl.LWJGLUtil; | |
4 | ||
5 | /** | |
6 | * @author Spasi | |
7 | */ | |
8 | abstract class AbstractDrawable implements DrawableLWJGL { | |
9 | ||
10 | /** Handle to the native GL rendering context */ | |
11 | protected PeerInfo peer_info; | |
12 | ||
13 | /** The OpenGL Context. */ | |
14 | protected Context context; | |
15 | ||
16 | protected AbstractDrawable() { | |
17 | } | |
18 | ||
19 | public Context getContext() { | |
20 | synchronized ( GlobalLock.lock ) { | |
21 | return context; | |
22 | } | |
23 | } | |
24 | ||
25 | public Context createSharedContext() throws LWJGLException { | |
26 | synchronized ( GlobalLock.lock ) { | |
27 | checkDestroyed(); | |
28 | return new Context(peer_info, context.getContextAttribs(), context); | |
29 | } | |
30 | } | |
31 | ||
32 | public boolean isCurrent() throws LWJGLException { | |
33 | synchronized ( GlobalLock.lock ) { | |
34 | checkDestroyed(); | |
35 | return context.isCurrent(); | |
36 | } | |
37 | } | |
38 | ||
39 | public void makeCurrent() throws LWJGLException { | |
40 | synchronized ( GlobalLock.lock ) { | |
41 | checkDestroyed(); | |
42 | context.makeCurrent(); | |
43 | } | |
44 | } | |
45 | ||
46 | public void releaseContext() throws LWJGLException { | |
47 | synchronized ( GlobalLock.lock ) { | |
48 | checkDestroyed(); | |
49 | if ( context.isCurrent() ) | |
50 | Context.releaseCurrentContext(); | |
51 | } | |
52 | } | |
53 | ||
54 | public void destroy() { | |
55 | synchronized ( GlobalLock.lock ) { | |
56 | if ( context == null ) | |
57 | return; | |
58 | ||
59 | try { | |
60 | releaseContext(); | |
61 | ||
62 | context.forceDestroy(); | |
63 | context = null; | |
64 | ||
65 | if ( peer_info != null ) { | |
66 | peer_info.destroy(); | |
67 | peer_info = null; | |
68 | } | |
69 | } catch (LWJGLException e) { | |
70 | LWJGLUtil.log("Exception occurred while destroying Drawable: " + e); | |
71 | } | |
72 | } | |
73 | } | |
74 | ||
75 | protected final void checkDestroyed() { | |
76 | if ( context == null ) | |
77 | throw new IllegalStateException("The Drawable has no context available."); | |
78 | } | |
79 | ||
80 | } |
31 | 31 | package org.lwjgl.opengl; |
32 | 32 | |
33 | 33 | import java.nio.Buffer; |
34 | import java.nio.IntBuffer; | |
35 | 34 | import java.util.Arrays; |
36 | 35 | |
37 | 36 | class BaseReferences { |
48 | 47 | int indirectBuffer; |
49 | 48 | |
50 | 49 | BaseReferences(ContextCapabilities caps) { |
51 | IntBuffer temp = caps.scratch_int_buffer; | |
52 | ||
53 | 50 | int max_vertex_attribs; |
54 | if (caps.OpenGL20 || caps.GL_ARB_vertex_shader) { | |
55 | GL11.glGetInteger(ARBVertexShader.GL_MAX_VERTEX_ATTRIBS_ARB, temp); | |
56 | max_vertex_attribs = temp.get(0); | |
57 | } else | |
51 | if (caps.OpenGL20 || caps.GL_ARB_vertex_shader) | |
52 | max_vertex_attribs = GL11.glGetInteger(ARBVertexShader.GL_MAX_VERTEX_ATTRIBS_ARB); | |
53 | else | |
58 | 54 | max_vertex_attribs = 0; |
59 | 55 | glVertexAttribPointer_buffer = new Buffer[max_vertex_attribs]; |
60 | 56 | |
61 | 57 | int max_texture_units; |
62 | if (caps.OpenGL20) { | |
63 | GL11.glGetInteger(GL20.GL_MAX_TEXTURE_IMAGE_UNITS, temp); | |
64 | max_texture_units = temp.get(0); | |
65 | } else if (caps.OpenGL13 || caps.GL_ARB_multitexture) { | |
66 | GL11.glGetInteger(GL13.GL_MAX_TEXTURE_UNITS, temp); | |
67 | max_texture_units = temp.get(0); | |
68 | } else | |
58 | if (caps.OpenGL20) | |
59 | max_texture_units = GL11.glGetInteger(GL20.GL_MAX_TEXTURE_IMAGE_UNITS); | |
60 | else if (caps.OpenGL13 || caps.GL_ARB_multitexture) | |
61 | max_texture_units = GL11.glGetInteger(GL13.GL_MAX_TEXTURE_UNITS); | |
62 | else | |
69 | 63 | max_texture_units = 1; |
70 | 64 | glTexCoordPointer_buffer = new Buffer[max_texture_units]; |
71 | 65 | } |
45 | 45 | * This class is thread-safe. |
46 | 46 | * |
47 | 47 | * @author elias_naur <elias_naur@users.sourceforge.net> |
48 | * @version $Revision: 3117 $ | |
49 | * $Id: Context.java 3117 2008-08-19 17:47:24Z spasi $ | |
48 | * @version $Revision: 3332 $ | |
49 | * $Id: Context.java 3332 2010-04-20 18:21:05Z spasi $ | |
50 | 50 | */ |
51 | 51 | final class Context { |
52 | 52 | |
60 | 60 | private final ByteBuffer handle; |
61 | 61 | private final PeerInfo peer_info; |
62 | 62 | |
63 | private final IntBuffer attribList; | |
63 | private final ContextAttribs contextAttribs; | |
64 | 64 | private final boolean forwardCompatible; |
65 | 65 | |
66 | 66 | /** Whether the context has been destroyed */ |
91 | 91 | |
92 | 92 | PeerInfo getPeerInfo() { |
93 | 93 | return peer_info; |
94 | } | |
95 | ||
96 | ContextAttribs getContextAttribs() { | |
97 | return contextAttribs; | |
94 | 98 | } |
95 | 99 | |
96 | 100 | static Context getCurrentContext() { |
108 | 112 | GLContext.loadOpenGLLibrary(); |
109 | 113 | try { |
110 | 114 | this.peer_info = peer_info; |
115 | this.contextAttribs = attribs; | |
116 | ||
117 | IntBuffer attribList; | |
111 | 118 | if ( attribs != null ) { |
112 | 119 | attribList = attribs.getAttribList(); |
113 | 120 | forwardCompatible = attribs.isForwardCompatible(); |
36 | 36 | import java.nio.IntBuffer; |
37 | 37 | |
38 | 38 | /** |
39 | * This class represents the context attributes passed to CreateContextAttribs of the XGL_create_context extension. | |
39 | * This class represents the context attributes passed to CreateContextAttribs of the ARB_create_context and | |
40 | * ARB_create_context_profile extensions. | |
40 | 41 | * These attributes can be used to indicate at context creation which OpenGL interface will be used. This includes the |
41 | 42 | * OpenGL version, the layer plane on which rendering takes place and also optional debug and forward combatibility modes. |
42 | * (read the XGL_create_context spec for details) | |
43 | * (read the ARB_create_context spec for details) | |
43 | 44 | * <p/> |
44 | 45 | * Use of this class is optional. If an OpenGL context is created without passing an instance of this class |
45 | * (or XGL_create_context is not supported), the old context creation code will be used. Use of ContextAttribs is required | |
46 | * to create an OpenGL 3.0 or newer context. Support for debug and forward compatible mobes is not guaranteed by the OpenGL | |
47 | * implementation. Developers may encounter debug contexts being the same as non-debug contexts or forward compatible | |
48 | * contexts having support for deprecated functionality. | |
46 | * (or ARB_create_context is not supported), the old context creation code will be used. Support for debug and forward | |
47 | * compatible mobes is not guaranteed by the OpenGL implementation. Developers may encounter debug contexts being the same | |
48 | * as non-debug contexts or forward compatible contexts having support for deprecated functionality. | |
49 | 49 | * <p/> |
50 | 50 | * If the forwardCompatible |
51 | 51 | * attribute is used, LWJGL will not load the deprecated functionality (as defined in the OpenGL 3.0 specification). This |
71 | 71 | } |
72 | 72 | |
73 | 73 | public ContextAttribs(final int majorVersion, final int minorVersion) { |
74 | if ( majorVersion < 0 || | |
75 | 3 < majorVersion || | |
74 | if ( majorVersion < 0 || 4 < majorVersion || | |
76 | 75 | minorVersion < 0 || |
77 | (majorVersion == 3 && 2 < minorVersion) || | |
76 | (majorVersion == 4 && 0 < minorVersion) || | |
77 | (majorVersion == 3 && 3 < minorVersion) || | |
78 | 78 | (majorVersion == 2 && 1 < minorVersion) || |
79 | 79 | (majorVersion == 1 && 5 < minorVersion) ) |
80 | 80 | throw new IllegalArgumentException("Invalid OpenGL version specified: " + majorVersion + '.' + minorVersion); |
87 | 87 | this.debug = false; |
88 | 88 | this.forwardCompatible = false; |
89 | 89 | |
90 | this.profileCore = 3 < majorVersion || (majorVersion == 3 && 2 <= minorVersion) ? true : false; | |
90 | this.profileCore = false; | |
91 | 91 | this.profileCompatibility = false; |
92 | 92 | } |
93 | 93 |
105 | 105 | /** Swap interval */ |
106 | 106 | private static int swap_interval; |
107 | 107 | |
108 | /** A unique context object, so we can track different contexts between creates() and destroys() */ | |
109 | private static PeerInfo peer_info; | |
110 | private static Context context; | |
111 | ||
112 | 108 | /** The Drawable instance that tracks the current Display context */ |
113 | private final static Drawable drawable; | |
114 | ||
115 | private static boolean window_created = false; | |
109 | private static final AbstractDrawable drawable; | |
110 | ||
111 | private static boolean window_created; | |
116 | 112 | |
117 | 113 | private static boolean parent_resized; |
118 | 114 | |
136 | 132 | } catch (LWJGLException e) { |
137 | 133 | throw new RuntimeException(e); |
138 | 134 | } |
139 | drawable = new Drawable() { | |
140 | public Context getContext() { | |
135 | drawable = new AbstractDrawable() { | |
136 | public void destroy() { | |
141 | 137 | synchronized ( GlobalLock.lock ) { |
142 | return isCreated() ? context : null; | |
138 | if ( !isCreated() ) | |
139 | return; | |
140 | ||
141 | releaseDrawable(); | |
142 | super.destroy(); | |
143 | destroyWindow(); | |
144 | x = y = -1; | |
145 | cached_icons = null; | |
146 | reset(); | |
147 | removeShutdownHook(); | |
143 | 148 | } |
144 | 149 | } |
145 | 150 | }; |
237 | 242 | * @throws LWJGLException if the display mode could not be set |
238 | 243 | */ |
239 | 244 | public static void setDisplayMode(DisplayMode mode) throws LWJGLException { |
240 | synchronized (GlobalLock.lock) { | |
241 | if (mode == null) | |
245 | synchronized ( GlobalLock.lock ) { | |
246 | if ( mode == null ) | |
242 | 247 | throw new NullPointerException("mode must be non-null"); |
243 | 248 | boolean was_fullscreen = isFullscreen(); |
244 | 249 | current_mode = mode; |
245 | if (isCreated()) { | |
250 | if ( isCreated() ) { | |
246 | 251 | destroyWindow(); |
247 | 252 | // If mode is not fullscreen capable, make sure we are in windowed mode |
248 | 253 | try { |
249 | if (was_fullscreen && !isFullscreen()) | |
254 | if ( was_fullscreen && !isFullscreen() ) | |
250 | 255 | display_impl.resetDisplayMode(); |
251 | else if (isFullscreen()) | |
256 | else if ( isFullscreen() ) | |
252 | 257 | switchDisplayMode(); |
253 | 258 | createWindow(); |
254 | 259 | makeCurrentAndSetSwapInterval(); |
255 | 260 | } catch (LWJGLException e) { |
256 | destroyContext(); | |
257 | destroyPeerInfo(); | |
261 | drawable.destroy(); | |
258 | 262 | display_impl.resetDisplayMode(); |
259 | 263 | throw e; |
260 | 264 | } |
267 | 271 | } |
268 | 272 | |
269 | 273 | private static int getWindowX() { |
270 | if (!isFullscreen() && parent == null) { | |
274 | if ( !isFullscreen() && parent == null ) { | |
271 | 275 | // if no display location set, center window |
272 | if (x == -1) { | |
276 | if ( x == -1 ) { | |
273 | 277 | return Math.max(0, (initial_mode.getWidth() - current_mode.getWidth()) / 2); |
274 | 278 | } else { |
275 | 279 | return x; |
280 | 284 | } |
281 | 285 | |
282 | 286 | private static int getWindowY() { |
283 | if (!isFullscreen() && parent == null) { | |
287 | if ( !isFullscreen() && parent == null ) { | |
284 | 288 | // if no display location set, center window |
285 | 289 | if ( y == -1 ) { |
286 | 290 | return Math.max(0, (initial_mode.getHeight() - current_mode.getHeight()) / 2); |
323 | 327 | |
324 | 328 | private static void releaseDrawable() { |
325 | 329 | try { |
330 | Context context = drawable.context; | |
326 | 331 | if ( context != null && context.isCurrent() ) { |
327 | 332 | Context.releaseCurrentContext(); |
328 | 333 | context.releaseDrawable(); |
418 | 423 | savedTimeLate = timeLate; |
419 | 424 | } |
420 | 425 | |
421 | while ( gapTo > timeNow + savedTimeLate ) { | |
422 | try { | |
426 | try { | |
427 | while ( gapTo > timeNow + savedTimeLate ) { | |
423 | 428 | Thread.sleep(1); |
424 | } catch (InterruptedException e) { | |
425 | } | |
426 | timeNow = Sys.getTime(); | |
429 | timeNow = Sys.getTime(); | |
430 | } | |
431 | } catch (InterruptedException e) { | |
432 | Thread.currentThread().interrupt(); | |
427 | 433 | } |
428 | 434 | |
429 | 435 | synchronized ( GlobalLock.lock ) { |
462 | 468 | */ |
463 | 469 | public static void setParent(Canvas parent) throws LWJGLException { |
464 | 470 | synchronized ( GlobalLock.lock ) { |
465 | if (Display.parent != parent) { | |
471 | if ( Display.parent != parent ) { | |
466 | 472 | Display.parent = parent; |
467 | 473 | if ( !isCreated() ) |
468 | 474 | return; |
469 | 475 | destroyWindow(); |
470 | 476 | try { |
471 | if (isFullscreen()) { | |
477 | if ( isFullscreen() ) { | |
472 | 478 | switchDisplayMode(); |
473 | 479 | } else { |
474 | 480 | display_impl.resetDisplayMode(); |
476 | 482 | createWindow(); |
477 | 483 | makeCurrentAndSetSwapInterval(); |
478 | 484 | } catch (LWJGLException e) { |
479 | destroyContext(); | |
480 | destroyPeerInfo(); | |
485 | drawable.destroy(); | |
481 | 486 | display_impl.resetDisplayMode(); |
482 | 487 | throw e; |
483 | 488 | } |
518 | 523 | |
519 | 524 | private static void setDisplayModeAndFullscreenInternal(boolean fullscreen, DisplayMode mode) throws LWJGLException { |
520 | 525 | synchronized ( GlobalLock.lock ) { |
521 | if (mode == null) | |
526 | if ( mode == null ) | |
522 | 527 | throw new NullPointerException("mode must be non-null"); |
523 | 528 | DisplayMode old_mode = current_mode; |
524 | 529 | current_mode = mode; |
525 | 530 | boolean was_fullscreen = isFullscreen(); |
526 | 531 | Display.fullscreen = fullscreen; |
527 | if (was_fullscreen != isFullscreen() || !mode.equals(old_mode)) { | |
528 | if (!isCreated()) | |
532 | if ( was_fullscreen != isFullscreen() || !mode.equals(old_mode) ) { | |
533 | if ( !isCreated() ) | |
529 | 534 | return; |
530 | 535 | destroyWindow(); |
531 | 536 | try { |
532 | if (isFullscreen()) { | |
537 | if ( isFullscreen() ) { | |
533 | 538 | switchDisplayMode(); |
534 | 539 | } else { |
535 | 540 | display_impl.resetDisplayMode(); |
537 | 542 | createWindow(); |
538 | 543 | makeCurrentAndSetSwapInterval(); |
539 | 544 | } catch (LWJGLException e) { |
540 | destroyContext(); | |
541 | destroyPeerInfo(); | |
545 | drawable.destroy(); | |
542 | 546 | display_impl.resetDisplayMode(); |
543 | 547 | throw e; |
544 | 548 | } |
548 | 552 | |
549 | 553 | /** @return whether the Display is in fullscreen mode */ |
550 | 554 | public static boolean isFullscreen() { |
551 | synchronized (GlobalLock.lock) { | |
555 | synchronized ( GlobalLock.lock ) { | |
552 | 556 | return fullscreen && current_mode.isFullscreenCapable(); |
553 | 557 | } |
554 | 558 | } |
650 | 654 | * Update the window. If the window is visible clears |
651 | 655 | * the dirty flag and calls swapBuffers() and finally |
652 | 656 | * polls the input devices. |
653 | * | |
654 | 657 | */ |
655 | 658 | public static void update() { |
656 | 659 | update(true); |
709 | 712 | * @throws LWJGLException If the context could not be released |
710 | 713 | */ |
711 | 714 | public static void releaseContext() throws LWJGLException { |
712 | synchronized ( GlobalLock.lock ) { | |
713 | if ( !isCreated() ) | |
714 | throw new IllegalStateException("Display is not created"); | |
715 | if ( context.isCurrent() ) | |
716 | Context.releaseCurrentContext(); | |
717 | } | |
715 | drawable.releaseContext(); | |
716 | } | |
717 | ||
718 | /** Returns true if the Display's context is current in the current thread. */ | |
719 | public static boolean isCurrent() throws LWJGLException { | |
720 | return drawable.isCurrent(); | |
718 | 721 | } |
719 | 722 | |
720 | 723 | /** |
723 | 726 | * @throws LWJGLException If the context could not be made current |
724 | 727 | */ |
725 | 728 | public static void makeCurrent() throws LWJGLException { |
726 | synchronized ( GlobalLock.lock ) { | |
727 | if ( !isCreated() ) | |
728 | throw new IllegalStateException("Display is not created"); | |
729 | context.makeCurrent(); | |
730 | } | |
729 | drawable.makeCurrent(); | |
731 | 730 | } |
732 | 731 | |
733 | 732 | private static void removeShutdownHook() { |
847 | 846 | throw new NullPointerException("pixel_format cannot be null"); |
848 | 847 | removeShutdownHook(); |
849 | 848 | registerShutdownHook(); |
850 | if (isFullscreen()) | |
849 | if ( isFullscreen() ) | |
851 | 850 | switchDisplayMode(); |
852 | 851 | try { |
853 | peer_info = display_impl.createPeerInfo(pixel_format); | |
852 | drawable.peer_info = display_impl.createPeerInfo(pixel_format); | |
854 | 853 | try { |
855 | 854 | createWindow(); |
856 | 855 | try { |
857 | context = new Context(peer_info, attribs, shared_drawable != null ? shared_drawable.getContext() : null); | |
856 | drawable.context = new Context(drawable.peer_info, attribs, shared_drawable != null ? ((AbstractDrawable)shared_drawable).getContext() : null); | |
858 | 857 | try { |
859 | 858 | makeCurrentAndSetSwapInterval(); |
860 | 859 | initContext(); |
861 | 860 | } catch (LWJGLException e) { |
862 | destroyContext(); | |
861 | drawable.destroy(); | |
863 | 862 | throw e; |
864 | 863 | } |
865 | 864 | } catch (LWJGLException e) { |
867 | 866 | throw e; |
868 | 867 | } |
869 | 868 | } catch (LWJGLException e) { |
870 | destroyPeerInfo(); | |
869 | drawable.destroy(); | |
871 | 870 | throw e; |
872 | 871 | } |
873 | 872 | } catch (LWJGLException e) { |
878 | 877 | } |
879 | 878 | |
880 | 879 | /** |
881 | * Set the initial color of the Display. This method is called before the Display is created and will set the | |
882 | * background color to the one specified in this method. | |
883 | * | |
884 | * @param red - color value between 0 - 1 | |
885 | * @param green - color value between 0 - 1 | |
886 | * @param blue - color value between 0 - 1 | |
887 | */ | |
880 | * Set the initial color of the Display. This method is called before the Display is created and will set the | |
881 | * background color to the one specified in this method. | |
882 | * | |
883 | * @param red - color value between 0 - 1 | |
884 | * @param green - color value between 0 - 1 | |
885 | * @param blue - color value between 0 - 1 | |
886 | */ | |
888 | 887 | public static void setInitialBackground(float red, float green, float blue) { |
889 | 888 | r = red; |
890 | 889 | g = green; |
956 | 955 | * regardless of whether the Display was the current rendering context. |
957 | 956 | */ |
958 | 957 | public static void destroy() { |
959 | synchronized ( GlobalLock.lock ) { | |
960 | if ( !isCreated() ) { | |
961 | return; | |
962 | } | |
963 | ||
964 | releaseDrawable(); | |
965 | destroyContext(); | |
966 | destroyWindow(); | |
967 | destroyPeerInfo(); | |
968 | x = y = -1; | |
969 | cached_icons = null; | |
970 | reset(); | |
971 | removeShutdownHook(); | |
972 | } | |
973 | } | |
974 | ||
975 | private static void destroyPeerInfo() { | |
976 | peer_info.destroy(); | |
977 | peer_info = null; | |
978 | } | |
979 | ||
980 | private static void destroyContext() { | |
981 | try { | |
982 | context.forceDestroy(); | |
983 | } catch (LWJGLException e) { | |
984 | throw new RuntimeException(e); | |
985 | } finally { | |
986 | context = null; | |
987 | } | |
958 | drawable.destroy(); | |
988 | 959 | } |
989 | 960 | |
990 | 961 | /* |
991 | 962 | * Reset display mode if fullscreen. This method is also called from the shutdown hook added |
992 | 963 | * in the static constructor |
993 | 964 | */ |
965 | ||
994 | 966 | private static void reset() { |
995 | 967 | display_impl.resetDisplayMode(); |
996 | 968 | current_mode = initial_mode; |
1049 | 1021 | y = new_y; |
1050 | 1022 | |
1051 | 1023 | // offset if already created |
1052 | if (isCreated() && !isFullscreen()) { | |
1024 | if ( isCreated() && !isFullscreen() ) { | |
1053 | 1025 | reshape(); |
1054 | 1026 | } |
1055 | 1027 | } |
30 | 30 | */ |
31 | 31 | package org.lwjgl.opengl; |
32 | 32 | |
33 | import org.lwjgl.LWJGLException; | |
34 | ||
33 | 35 | /** |
34 | 36 | * The Drawable interface describes an OpenGL drawable with an associated |
35 | 37 | * Context. |
38 | 40 | */ |
39 | 41 | |
40 | 42 | public interface Drawable { |
41 | Context getContext(); | |
43 | ||
44 | /** Returns true if the Drawable's context is current in the current thread. */ | |
45 | boolean isCurrent() throws LWJGLException; | |
46 | ||
47 | /** | |
48 | * Makes the Drawable's context current in the current thread. | |
49 | * | |
50 | * @throws LWJGLException | |
51 | */ | |
52 | void makeCurrent() throws LWJGLException; | |
53 | ||
54 | /** | |
55 | * If the Drawable's context is current in the current thread, no context will be current after a call to this method. | |
56 | * | |
57 | * @throws LWJGLException | |
58 | */ | |
59 | void releaseContext() throws LWJGLException; | |
60 | ||
61 | /** Destroys the Drawable. */ | |
62 | void destroy(); | |
63 | ||
42 | 64 | } |
0 | package org.lwjgl.opengl; | |
1 | ||
2 | import org.lwjgl.LWJGLException; | |
3 | ||
4 | /** | |
5 | * @author Spasi | |
6 | */ | |
7 | interface DrawableLWJGL extends Drawable { | |
8 | ||
9 | /** | |
10 | * [INTERNAL USE ONLY] Returns the Drawable's Context. | |
11 | * | |
12 | * @return the Drawable's Context | |
13 | */ | |
14 | Context getContext(); | |
15 | ||
16 | /** | |
17 | * [INTERNAL USE ONLY] Creates a new Context that is shared with the Drawable's Context. | |
18 | * | |
19 | * @return a Context shared with the Drawable's Context. | |
20 | */ | |
21 | Context createSharedContext() throws LWJGLException; | |
22 | ||
23 | } |
34 | 34 | import java.nio.IntBuffer; |
35 | 35 | |
36 | 36 | import org.lwjgl.BufferUtils; |
37 | import org.lwjgl.LWJGLUtil; | |
37 | 38 | |
38 | 39 | /** |
39 | 40 | * A class to check buffer boundaries in GL methods. Many GL |
45 | 46 | * Thrown by the debug build library of the LWJGL if any OpenGL operation causes an error. |
46 | 47 | * |
47 | 48 | * @author cix_foo <cix_foo@users.sourceforge.net> |
48 | * @version $Revision: 3279 $ | |
49 | * $Id: GLChecks.java 3279 2010-03-11 21:06:49Z spasi $ | |
49 | * @version $Revision: 3334 $ | |
50 | * $Id: GLChecks.java 3334 2010-04-22 23:21:48Z spasi $ | |
50 | 51 | */ |
51 | 52 | class GLChecks { |
52 | 53 | |
59 | 60 | } |
60 | 61 | |
61 | 62 | static int getBufferObjectSize(ContextCapabilities caps, int buffer_enum) { |
62 | IntBuffer scratch_buffer = caps.scratch_int_buffer; | |
63 | GL15.glGetBufferParameter(buffer_enum, GL15.GL_BUFFER_SIZE, scratch_buffer); | |
64 | return scratch_buffer.get(0); | |
63 | return GL15.glGetBufferParameter(buffer_enum, GL15.GL_BUFFER_SIZE); | |
65 | 64 | } |
66 | 65 | |
67 | 66 | static int getBufferObjectSizeARB(ContextCapabilities caps, int buffer_enum) { |
68 | IntBuffer scratch_buffer = caps.scratch_int_buffer; | |
69 | ARBBufferObject.glGetBufferParameterARB(buffer_enum, ARBBufferObject.GL_BUFFER_SIZE_ARB, scratch_buffer); | |
70 | return scratch_buffer.get(0); | |
67 | return ARBBufferObject.glGetBufferParameterARB(buffer_enum, ARBBufferObject.GL_BUFFER_SIZE_ARB); | |
71 | 68 | } |
72 | 69 | |
73 | 70 | static int getBufferObjectSizeATI(ContextCapabilities caps, int buffer) { |
74 | IntBuffer scratch_buffer = caps.scratch_int_buffer; | |
75 | ATIVertexArrayObject.glGetObjectBufferATI(buffer, ATIVertexArrayObject.GL_OBJECT_BUFFER_SIZE_ATI, scratch_buffer); | |
76 | return scratch_buffer.get(0); | |
71 | return ATIVertexArrayObject.glGetObjectBufferATI(buffer, ATIVertexArrayObject.GL_OBJECT_BUFFER_SIZE_ATI); | |
77 | 72 | } |
78 | 73 | |
79 | 74 | static int getNamedBufferObjectSize(ContextCapabilities caps, int buffer) { |
80 | IntBuffer scratch_buffer = caps.scratch_int_buffer; | |
81 | EXTDirectStateAccess.glGetNamedBufferParameterEXT(buffer, GL15.GL_BUFFER_SIZE, scratch_buffer); | |
82 | return scratch_buffer.get(0); | |
83 | } | |
84 | ||
85 | private static boolean checkBufferObject(ContextCapabilities caps, int buffer_enum, boolean state) { | |
86 | IntBuffer scratch_buffer = caps.scratch_int_buffer; | |
87 | GL11.glGetInteger(buffer_enum, scratch_buffer); | |
88 | boolean is_enabled = scratch_buffer.get(0) != 0; | |
89 | return state == is_enabled; | |
75 | return EXTDirectStateAccess.glGetNamedBufferParameterEXT(buffer, GL15.GL_BUFFER_SIZE); | |
90 | 76 | } |
91 | 77 | |
92 | 78 | /** Helper method to ensure that array buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */ |
93 | 79 | static void ensureArrayVBOdisabled(ContextCapabilities caps) { |
94 | if(StateTracker.getReferencesStack(caps).getReferences().arrayBuffer != 0) | |
80 | if( LWJGLUtil.CHECKS && StateTracker.getReferencesStack(caps).getReferences().arrayBuffer != 0 ) | |
95 | 81 | throw new OpenGLException("Cannot use Buffers when Array Buffer Object is enabled"); |
96 | 82 | } |
97 | 83 | |
98 | 84 | /** Helper method to ensure that array buffer objects are enabled. If they are disabled, we'll throw an OpenGLException */ |
99 | 85 | static void ensureArrayVBOenabled(ContextCapabilities caps) { |
100 | if(StateTracker.getReferencesStack(caps).getReferences().arrayBuffer == 0) | |
86 | if( LWJGLUtil.CHECKS && StateTracker.getReferencesStack(caps).getReferences().arrayBuffer == 0 ) | |
101 | 87 | throw new OpenGLException("Cannot use offsets when Array Buffer Object is disabled"); |
102 | 88 | } |
103 | 89 | |
104 | 90 | /** Helper method to ensure that element array buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */ |
105 | 91 | static void ensureElementVBOdisabled(ContextCapabilities caps) { |
106 | if(StateTracker.getReferencesStack(caps).getReferences().elementArrayBuffer != 0) | |
92 | if( LWJGLUtil.CHECKS && StateTracker.getReferencesStack(caps).getReferences().elementArrayBuffer != 0 ) | |
107 | 93 | throw new OpenGLException("Cannot use Buffers when Element Array Buffer Object is enabled"); |
108 | 94 | } |
109 | 95 | |
110 | 96 | /** Helper method to ensure that element array buffer objects are enabled. If they are disabled, we'll throw an OpenGLException */ |
111 | 97 | static void ensureElementVBOenabled(ContextCapabilities caps) { |
112 | if(StateTracker.getReferencesStack(caps).getReferences().elementArrayBuffer == 0) | |
98 | if( LWJGLUtil.CHECKS && StateTracker.getReferencesStack(caps).getReferences().elementArrayBuffer == 0 ) | |
113 | 99 | throw new OpenGLException("Cannot use offsets when Element Array Buffer Object is disabled"); |
114 | 100 | } |
115 | 101 | |
116 | 102 | /** Helper method to ensure that array buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */ |
117 | 103 | static void ensureIndirectBOdisabled(ContextCapabilities caps) { |
118 | if ( StateTracker.getReferencesStack(caps).getReferences().indirectBuffer != 0 ) | |
104 | if ( LWJGLUtil.CHECKS && StateTracker.getReferencesStack(caps).getReferences().indirectBuffer != 0 ) | |
119 | 105 | throw new OpenGLException("Cannot use Buffers when Draw Indirect Object is enabled"); |
120 | 106 | } |
121 | 107 | |
122 | 108 | /** Helper method to ensure that array buffer objects are enabled. If they are disabled, we'll throw an OpenGLException */ |
123 | 109 | static void ensureIndirectBOenabled(ContextCapabilities caps) { |
124 | if ( StateTracker.getReferencesStack(caps).getReferences().indirectBuffer == 0 ) | |
110 | if ( LWJGLUtil.CHECKS && StateTracker.getReferencesStack(caps).getReferences().indirectBuffer == 0 ) | |
125 | 111 | throw new OpenGLException("Cannot use offsets when Draw Indirect Object is disabled"); |
126 | 112 | } |
127 | 113 | |
128 | 114 | /** Helper method to ensure that pixel pack buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */ |
129 | 115 | static void ensurePackPBOdisabled(ContextCapabilities caps) { |
130 | if ( StateTracker.getReferencesStack(caps).getReferences().pixelPackBuffer != 0 ) | |
116 | if ( LWJGLUtil.CHECKS && StateTracker.getReferencesStack(caps).getReferences().pixelPackBuffer != 0 ) | |
131 | 117 | throw new OpenGLException("Cannot use Buffers when Pixel Pack Buffer Object is enabled"); |
132 | 118 | } |
133 | 119 | |
134 | 120 | /** Helper method to ensure that pixel pack buffer objects are enabled. If they are disabled, we'll throw an OpenGLException */ |
135 | 121 | static void ensurePackPBOenabled(ContextCapabilities caps) { |
136 | if ( StateTracker.getReferencesStack(caps).getReferences().pixelPackBuffer == 0 ) | |
122 | if ( LWJGLUtil.CHECKS && StateTracker.getReferencesStack(caps).getReferences().pixelPackBuffer == 0 ) | |
137 | 123 | throw new OpenGLException("Cannot use offsets when Pixel Pack Buffer Object is disabled"); |
138 | 124 | } |
139 | 125 | |
140 | 126 | /** Helper method to ensure that pixel unpack buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */ |
141 | 127 | static void ensureUnpackPBOdisabled(ContextCapabilities caps) { |
142 | if ( StateTracker.getReferencesStack(caps).getReferences().pixelUnpackBuffer != 0 ) | |
128 | if ( LWJGLUtil.CHECKS && StateTracker.getReferencesStack(caps).getReferences().pixelUnpackBuffer != 0 ) | |
143 | 129 | throw new OpenGLException("Cannot use Buffers when Pixel Unpack Buffer Object is enabled"); |
144 | 130 | } |
145 | 131 | |
146 | 132 | /** Helper method to ensure that pixel unpack buffer objects are enabled. If they are disabled, we'll throw an OpenGLException */ |
147 | 133 | static void ensureUnpackPBOenabled(ContextCapabilities caps) { |
148 | if ( StateTracker.getReferencesStack(caps).getReferences().pixelUnpackBuffer == 0 ) | |
134 | if ( LWJGLUtil.CHECKS && StateTracker.getReferencesStack(caps).getReferences().pixelUnpackBuffer == 0 ) | |
149 | 135 | throw new OpenGLException("Cannot use offsets when Pixel Unpack Buffer Object is disabled"); |
150 | 136 | } |
151 | 137 | |
161 | 147 | * @return the size, in elements, of the image |
162 | 148 | */ |
163 | 149 | static int calculateImageStorage(Buffer buffer, int format, int type, int width, int height, int depth) { |
164 | return calculateImageStorage(format, type, width, height, depth) >> BufferUtils.getElementSizeExponent(buffer); | |
150 | return LWJGLUtil.CHECKS ? calculateImageStorage(format, type, width, height, depth) >> BufferUtils.getElementSizeExponent(buffer) : 0; | |
165 | 151 | } |
166 | 152 | |
167 | 153 | static int calculateTexImage1DStorage(Buffer buffer, int format, int type, int width) { |
168 | return calculateTexImage1DStorage(format, type, width) >> BufferUtils.getElementSizeExponent(buffer); | |
154 | return LWJGLUtil.CHECKS ? calculateTexImage1DStorage(format, type, width) >> BufferUtils.getElementSizeExponent(buffer) : 0; | |
169 | 155 | } |
170 | 156 | |
171 | 157 | static int calculateTexImage2DStorage(Buffer buffer, int format, int type, int width, int height) { |
172 | return calculateTexImage2DStorage(format, type, width, height) >> BufferUtils.getElementSizeExponent(buffer); | |
158 | return LWJGLUtil.CHECKS ? calculateTexImage2DStorage(format, type, width, height) >> BufferUtils.getElementSizeExponent(buffer) : 0; | |
173 | 159 | } |
174 | 160 | |
175 | 161 | static int calculateTexImage3DStorage(Buffer buffer, int format, int type, int width, int height, int depth) { |
176 | return calculateTexImage3DStorage(format, type, width, height, depth) >> BufferUtils.getElementSizeExponent(buffer); | |
162 | return LWJGLUtil.CHECKS ? calculateTexImage3DStorage(format, type, width, height, depth) >> BufferUtils.getElementSizeExponent(buffer) : 0; | |
177 | 163 | } |
178 | 164 | |
179 | 165 | /** |
53 | 53 | * That way, multiple threads can have multiple contexts current and render to them concurrently. |
54 | 54 | * |
55 | 55 | * @author elias_naur <elias_naur@users.sourceforge.net> |
56 | * @version $Revision: 3279 $ | |
57 | * $Id: GLContext.java 3279 2010-03-11 21:06:49Z spasi $ | |
56 | * @version $Revision: 3355 $ | |
57 | * $Id: GLContext.java 3355 2010-05-27 22:56:29Z spasi $ | |
58 | 58 | */ |
59 | 59 | public final class GLContext { |
60 | 60 | |
168 | 168 | return 0; |
169 | 169 | } |
170 | 170 | |
171 | /** | |
172 | * Helper method to get a pointer to a named function with aliases in the OpenGL library. | |
173 | * | |
174 | * @param aliases the function name aliases. | |
175 | * | |
176 | * @return the function pointer address | |
177 | */ | |
178 | static long getFunctionAddress(String[] aliases) { | |
179 | for ( int i = 0; i < aliases.length; i++ ) { | |
180 | long address = getFunctionAddress(aliases[i]); | |
181 | if ( address != 0 ) | |
182 | return address; | |
183 | } | |
184 | return 0; | |
185 | } | |
186 | ||
171 | 187 | /** Helper method to get a pointer to a named function in the OpenGL library */ |
172 | 188 | static native long getFunctionAddress(String name); |
173 | 189 |
38 | 38 | */ |
39 | 39 | |
40 | 40 | import java.awt.Canvas; |
41 | import java.io.BufferedReader; | |
42 | import java.io.IOException; | |
43 | import java.io.InputStreamReader; | |
41 | 44 | import java.nio.ByteBuffer; |
42 | 45 | import java.nio.FloatBuffer; |
43 | 46 | import java.nio.IntBuffer; |
46 | 49 | import org.lwjgl.LWJGLException; |
47 | 50 | import org.lwjgl.LWJGLUtil; |
48 | 51 | import org.lwjgl.opengl.XRandR.Screen; |
52 | ||
53 | import java.security.AccessController; | |
54 | import java.security.PrivilegedAction; | |
55 | import java.util.ArrayList; | |
56 | import java.util.Iterator; | |
57 | import java.util.List; | |
49 | 58 | |
50 | 59 | final class LinuxDisplay implements DisplayImplementation { |
51 | 60 | /* X11 constants */ |
406 | 415 | ByteBuffer handle = peer_info.lockAndGetHandle(); |
407 | 416 | try { |
408 | 417 | current_window_mode = getWindowMode(Display.isFullscreen()); |
409 | boolean undecorated = Display.getPrivilegedBoolean("org.lwjgl.opengl.Window.undecorated") || current_window_mode != WINDOWED; | |
418 | // Try to enable Lecagy FullScreen Support in Compiz, else | |
419 | // we may have trouble with stuff overlapping our fullscreen window. | |
420 | if ( current_window_mode != WINDOWED ) | |
421 | Compiz.setLegacyFullscreenSupport(true); | |
422 | // Setting _MOTIF_WM_HINTS in fullscreen mode is problematic for certain window | |
423 | // managers. We do not set MWM_HINTS_DECORATIONS in fullscreen mode anymore, | |
424 | // unless org.lwjgl.opengl.Window.undecorated_fs has been specified. | |
425 | // See native/linux/org_lwjgl_opengl_Display.c, createWindow function. | |
426 | boolean undecorated = Display.getPrivilegedBoolean("org.lwjgl.opengl.Window.undecorated") || (current_window_mode != WINDOWED && Display.getPrivilegedBoolean("org.lwjgl.opengl.Window.undecorated_fs")); | |
410 | 427 | this.parent = parent; |
411 | 428 | parent_window = parent != null ? getHandle(parent) : getRootWindow(getDisplay(), getDefaultScreen()); |
412 | 429 | current_window = nCreateWindow(getDisplay(), getDefaultScreen(), handle, mode, current_window_mode, x, y, undecorated, parent_window); |
440 | 457 | private static native void mapRaised(long display, long window); |
441 | 458 | private static native void reparentWindow(long display, long window, long parent, int x, int y); |
442 | 459 | |
443 | private boolean isAncestorXEmbedded(long window) throws LWJGLException { | |
460 | private static boolean isAncestorXEmbedded(long window) throws LWJGLException { | |
444 | 461 | long xembed_atom = internAtom("_XEMBED_INFO", true); |
445 | 462 | if (xembed_atom != None) { |
446 | 463 | long w = window; |
482 | 499 | ungrabKeyboard(); |
483 | 500 | nDestroyWindow(getDisplay(), getWindow()); |
484 | 501 | decDisplay(); |
502 | ||
503 | if ( current_window_mode != WINDOWED ) | |
504 | Compiz.setLegacyFullscreenSupport(false); | |
485 | 505 | } finally { |
486 | 506 | unlockAWT(); |
487 | 507 | } |
523 | 543 | try { |
524 | 544 | if( current_displaymode_extension == XRANDR && savedXrandrConfig.length > 0 ) |
525 | 545 | { |
526 | XRandR.setConfiguration( savedXrandrConfig ); | |
546 | AccessController.doPrivileged(new PrivilegedAction() { | |
547 | public Object run() { | |
548 | XRandR.setConfiguration( savedXrandrConfig ); | |
549 | return null; | |
550 | } | |
551 | }); | |
527 | 552 | } |
528 | 553 | else |
529 | 554 | { |
531 | 556 | } |
532 | 557 | if (isXF86VidModeSupported()) |
533 | 558 | doSetGamma(saved_gamma); |
559 | ||
560 | Compiz.setLegacyFullscreenSupport(false); | |
534 | 561 | } catch (LWJGLException e) { |
535 | 562 | LWJGLUtil.log("Caught exception while resetting mode: " + e); |
536 | 563 | } finally { |
605 | 632 | public DisplayMode init() throws LWJGLException { |
606 | 633 | lockAWT(); |
607 | 634 | try { |
635 | Compiz.init(); | |
636 | ||
608 | 637 | delete_atom = internAtom("WM_DELETE_WINDOW", false); |
609 | 638 | current_displaymode_extension = getBestDisplayModeExtension(); |
610 | 639 | if (current_displaymode_extension == NONE) |
614 | 643 | throw new LWJGLException("No modes available"); |
615 | 644 | switch (current_displaymode_extension) { |
616 | 645 | case XRANDR: |
617 | savedXrandrConfig = XRandR.getConfiguration(); | |
646 | savedXrandrConfig = (Screen[])AccessController.doPrivileged(new PrivilegedAction() { | |
647 | public Object run() { | |
648 | return XRandR.getConfiguration(); | |
649 | } | |
650 | }); | |
618 | 651 | saved_mode = getCurrentXRandrMode(); |
619 | 652 | break; |
620 | 653 | case XF86VIDMODE: |
846 | 879 | setInputFocusUnsafe(current_window); |
847 | 880 | } |
848 | 881 | else if (xembedded) { |
849 | setInputFocusUnsafe(0); | |
850 | } | |
851 | } | |
852 | else if (parent_focus && !focused) { | |
853 | setInputFocusUnsafe(current_window); | |
854 | } | |
882 | setInputFocusUnsafe(1); | |
883 | } | |
884 | } | |
885 | //else if (parent_focus && !focused && !xembedded) { | |
886 | // setInputFocusUnsafe(current_window); | |
887 | //} | |
855 | 888 | } |
856 | 889 | |
857 | 890 | private void setFocused(boolean got_focus, int focus_detail) { |
889 | 922 | try { |
890 | 923 | if( current_displaymode_extension == XRANDR && savedXrandrConfig.length > 0 ) |
891 | 924 | { |
892 | XRandR.setConfiguration( savedXrandrConfig ); | |
925 | AccessController.doPrivileged(new PrivilegedAction() { | |
926 | public Object run() { | |
927 | XRandR.setConfiguration( savedXrandrConfig ); | |
928 | return null; | |
929 | } | |
930 | }); | |
893 | 931 | } |
894 | 932 | else |
895 | 933 | { |
1211 | 1249 | public boolean isInsideWindow() { |
1212 | 1250 | return true; |
1213 | 1251 | } |
1214 | } | |
1252 | ||
1253 | /** | |
1254 | * Helper class for managing Compiz's workarounds. We need this to enable Legacy | |
1255 | * Fullscreen Support in Compiz, else we'll have trouble with fullscreen windows | |
1256 | * when Compiz effects are enabled. | |
1257 | * | |
1258 | * Implementation Note: This code is probably too much for an inner class, but | |
1259 | * keeping it here until we're sure we cannot find a better solution. | |
1260 | */ | |
1261 | private static final class Compiz { | |
1262 | ||
1263 | private static boolean applyFix; | |
1264 | ||
1265 | private static Provider provider; | |
1266 | ||
1267 | private Compiz() { | |
1268 | } | |
1269 | ||
1270 | static void init() { | |
1271 | if ( Display.getPrivilegedBoolean("org.lwjgl.opengl.Window.nocompiz_lfs") ) | |
1272 | return; | |
1273 | ||
1274 | AccessController.doPrivileged(new PrivilegedAction() { | |
1275 | public Object run() { | |
1276 | try { | |
1277 | // Check if Compiz is active | |
1278 | if ( !isProcessActive("compiz") ) | |
1279 | return null; | |
1280 | ||
1281 | provider = null; | |
1282 | ||
1283 | String providerName = null; | |
1284 | ||
1285 | // Check if Dbus is available | |
1286 | if ( isProcessActive("dbus-daemon") ) { | |
1287 | providerName = "Dbus"; | |
1288 | provider = new Provider() { | |
1289 | ||
1290 | private static final String KEY = "/org/freedesktop/compiz/workarounds/allscreens/legacy_fullscreen"; | |
1291 | ||
1292 | public boolean hasLegacyFullscreenSupport() throws LWJGLException { | |
1293 | final List output = Compiz.run(new String[] { | |
1294 | "dbus-send", "--print-reply", "--type=method_call", "--dest=org.freedesktop.compiz", KEY, "org.freedesktop.compiz.get" | |
1295 | }); | |
1296 | ||
1297 | if ( output == null || output.size() < 2 ) | |
1298 | throw new LWJGLException("Invalid Dbus reply."); | |
1299 | ||
1300 | String line = (String)output.get(0); | |
1301 | ||
1302 | if ( !line.startsWith("method return") ) | |
1303 | throw new LWJGLException("Invalid Dbus reply."); | |
1304 | ||
1305 | line = ((String)output.get(1)).trim(); // value | |
1306 | if ( !line.startsWith("boolean") || line.length() < 12) | |
1307 | throw new LWJGLException("Invalid Dbus reply."); | |
1308 | ||
1309 | return "true".equalsIgnoreCase(line.substring("boolean".length() + 1)); | |
1310 | } | |
1311 | ||
1312 | public void setLegacyFullscreenSupport(final boolean state) throws LWJGLException { | |
1313 | if ( Compiz.run(new String[] { | |
1314 | "dbus-send", "--type=method_call", "--dest=org.freedesktop.compiz", KEY, "org.freedesktop.compiz.set", "boolean:" + Boolean.toString(state) | |
1315 | }) == null ) | |
1316 | throw new LWJGLException("Failed to apply Compiz LFS workaround."); | |
1317 | } | |
1318 | }; | |
1319 | } else { | |
1320 | try { | |
1321 | // Check if Gconf is available | |
1322 | Runtime.getRuntime().exec("gconftool"); | |
1323 | ||
1324 | providerName = "gconftool"; | |
1325 | provider = new Provider() { | |
1326 | ||
1327 | private static final String KEY = "/apps/compiz/plugins/workarounds/allscreens/options/legacy_fullscreen"; | |
1328 | ||
1329 | public boolean hasLegacyFullscreenSupport() throws LWJGLException { | |
1330 | final List output = Compiz.run(new String[] { | |
1331 | "gconftool", "-g", KEY | |
1332 | }); | |
1333 | ||
1334 | if ( output == null || output.size() == 0 ) | |
1335 | throw new LWJGLException("Invalid gconftool reply."); | |
1336 | ||
1337 | return Boolean.parseBoolean(((String)output.get(0)).trim()); | |
1338 | } | |
1339 | ||
1340 | public void setLegacyFullscreenSupport(final boolean state) throws LWJGLException { | |
1341 | if ( Compiz.run(new String[] { | |
1342 | "gconftool", "-s", KEY, "-s", Boolean.toString(state), "-t", "bool" | |
1343 | }) == null ) | |
1344 | throw new LWJGLException("Failed to apply Compiz LFS workaround."); | |
1345 | ||
1346 | if ( state ) { | |
1347 | try { | |
1348 | // gconftool will not apply the workaround immediately, sleep a bit | |
1349 | // to make sure it will be ok when we create the window. | |
1350 | Thread.sleep(200); // 100 is too low, 150 works, set to 200 to be safe. | |
1351 | } catch (InterruptedException e) { | |
1352 | e.printStackTrace(); | |
1353 | } | |
1354 | } | |
1355 | } | |
1356 | }; | |
1357 | } catch (IOException e) { | |
1358 | // Ignore | |
1359 | } | |
1360 | } | |
1361 | ||
1362 | if ( provider != null && !provider.hasLegacyFullscreenSupport() ) { // No need to do anything if LFS is already enabled. | |
1363 | applyFix = true; | |
1364 | LWJGLUtil.log("Using " + providerName + " to apply Compiz LFS workaround."); | |
1365 | } | |
1366 | } catch (LWJGLException e) { | |
1367 | // Ignore | |
1368 | } finally { | |
1369 | return null; | |
1370 | } | |
1371 | } | |
1372 | }); | |
1373 | } | |
1374 | ||
1375 | static void setLegacyFullscreenSupport(final boolean enabled) { | |
1376 | if ( !applyFix ) | |
1377 | return; | |
1378 | ||
1379 | AccessController.doPrivileged(new PrivilegedAction() { | |
1380 | public Object run() { | |
1381 | try { | |
1382 | provider.setLegacyFullscreenSupport(enabled); | |
1383 | } catch (LWJGLException e) { | |
1384 | LWJGLUtil.log("Failed to change Compiz Legacy Fullscreen Support. Reason: " + e.getMessage()); | |
1385 | } | |
1386 | return null; | |
1387 | } | |
1388 | }); | |
1389 | } | |
1390 | ||
1391 | private static List run(final String[] command) throws LWJGLException { | |
1392 | final List output = new ArrayList(); | |
1393 | ||
1394 | try { | |
1395 | final Process p = Runtime.getRuntime().exec(command); | |
1396 | try { | |
1397 | final int exitValue = p.waitFor(); | |
1398 | if ( exitValue != 0 ) | |
1399 | return null; | |
1400 | } catch (InterruptedException e) { | |
1401 | throw new LWJGLException("Process interrupted.", e); | |
1402 | } | |
1403 | ||
1404 | final BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); | |
1405 | ||
1406 | String line; | |
1407 | while ( (line = br.readLine()) != null ) | |
1408 | output.add(line); | |
1409 | ||
1410 | br.close(); | |
1411 | } catch (final IOException e) { | |
1412 | throw new LWJGLException("Process failed.", e); | |
1413 | } | |
1414 | ||
1415 | return output; | |
1416 | } | |
1417 | ||
1418 | private static boolean isProcessActive(final String processName) throws LWJGLException { | |
1419 | final List output = run(new String[] { "ps", "-C", processName }); | |
1420 | if ( output == null ) | |
1421 | return false; | |
1422 | ||
1423 | for ( Iterator iter = output.iterator(); iter.hasNext(); ) { | |
1424 | final String line = (String)iter.next(); | |
1425 | if ( line.contains(processName) ); | |
1426 | return true; | |
1427 | } | |
1428 | ||
1429 | return false; | |
1430 | } | |
1431 | ||
1432 | private interface Provider { | |
1433 | ||
1434 | boolean hasLegacyFullscreenSupport() throws LWJGLException; | |
1435 | ||
1436 | void setLegacyFullscreenSupport(boolean state) throws LWJGLException; | |
1437 | ||
1438 | } | |
1439 | } | |
1440 | ||
1441 | }⏎ |
77 | 77 | AccessController.doPrivileged(new PrivilegedExceptionAction() { |
78 | 78 | public Object run() throws Exception { |
79 | 79 | Application.getApplication().addApplicationListener(new ApplicationAdapter() { |
80 | public final void handleQuit(ApplicationEvent event) { | |
80 | public void handleQuit(ApplicationEvent event) { | |
81 | 81 | doHandleQuit(); |
82 | 82 | } |
83 | 83 | }); |
270 | 270 | * |
271 | 271 | * - elias |
272 | 272 | */ |
273 | AbstractDrawable drawable = (AbstractDrawable)Display.getDrawable(); | |
273 | 274 | if (Display.isFullscreen() && (frame != null && frame.getCanvas().syncCanvasPainted() || should_update)) { |
274 | 275 | try { |
275 | MacOSXContextImplementation.resetView(Display.getDrawable().getContext().getPeerInfo(), Display.getDrawable().getContext()); | |
276 | MacOSXContextImplementation.resetView(drawable.peer_info, drawable.context); | |
276 | 277 | } catch (LWJGLException e) { |
277 | 278 | LWJGLUtil.log("Failed to reset context: " + e); |
278 | 279 | } |
279 | 280 | } |
280 | 281 | if (should_update) { |
281 | Display.getDrawable().getContext().update(); | |
282 | drawable.context.update(); | |
282 | 283 | /* This is necessary to make sure the context won't "forget" about the view size */ |
283 | 284 | GL11.glGetInteger(GL11.GL_VIEWPORT, current_viewport); |
284 | 285 | GL11.glViewport(current_viewport.get(0), current_viewport.get(1), current_viewport.get(2), current_viewport.get(3)); |
34 | 34 | |
35 | 35 | import org.lwjgl.BufferUtils; |
36 | 36 | import org.lwjgl.LWJGLException; |
37 | import org.lwjgl.LWJGLUtil; | |
38 | 37 | import org.lwjgl.Sys; |
39 | 38 | |
40 | 39 | /** |
45 | 44 | * This class is thread-safe. |
46 | 45 | * |
47 | 46 | * @author elias_naur <elias_naur@users.sourceforge.net> |
48 | * @version $Revision: 3116 $ | |
49 | * $Id: Pbuffer.java 3116 2008-08-19 16:46:03Z spasi $ | |
47 | * @version $Revision: 3334 $ | |
48 | * $Id: Pbuffer.java 3334 2010-04-22 23:21:48Z spasi $ | |
50 | 49 | */ |
51 | public final class Pbuffer implements Drawable { | |
50 | public final class Pbuffer extends AbstractDrawable { | |
52 | 51 | /** |
53 | 52 | * Indicates that Pbuffers can be created. |
54 | 53 | */ |
135 | 134 | public static final int DEPTH_BUFFER = RenderTexture.WGL_DEPTH_COMPONENT_NV; |
136 | 135 | |
137 | 136 | /** |
138 | * Handle to the native GL rendering context | |
139 | */ | |
140 | private final PeerInfo peer_info; | |
141 | ||
142 | /** | |
143 | 137 | * Width |
144 | 138 | */ |
145 | 139 | private final int width; |
148 | 142 | * Height |
149 | 143 | */ |
150 | 144 | private final int height; |
151 | ||
152 | private final Context context; | |
153 | ||
154 | private boolean destroyed; | |
155 | 145 | |
156 | 146 | static { |
157 | 147 | Sys.initialize(); |
226 | 216 | this.width = width; |
227 | 217 | this.height = height; |
228 | 218 | this.peer_info = createPbuffer(width, height, pixel_format, renderTexture); |
229 | Context shared_context = null; | |
230 | if (shared_drawable != null) { | |
231 | shared_context = shared_drawable.getContext(); | |
232 | } else { | |
233 | Drawable display_drawable = Display.getDrawable(); | |
234 | if (display_drawable != null) | |
235 | shared_context = display_drawable.getContext(); | |
236 | } | |
219 | Context shared_context; | |
220 | if (shared_drawable != null) | |
221 | shared_context = ((DrawableLWJGL)shared_drawable).getContext(); | |
222 | else | |
223 | shared_context = ((DrawableLWJGL)Display.getDrawable()).getContext(); // May be null | |
237 | 224 | this.context = new Context(peer_info, attribs, shared_context); |
238 | 225 | } |
239 | 226 | |
250 | 237 | renderTexture.pBufferAttribs); |
251 | 238 | } |
252 | 239 | |
253 | public Context getContext() { | |
254 | return context; | |
255 | } | |
256 | ||
257 | private void checkDestroyed() { | |
258 | if (destroyed) | |
259 | throw new IllegalStateException("Pbuffer is destroyed"); | |
260 | } | |
261 | ||
262 | 240 | /** |
263 | 241 | * Method to test for validity of the buffer. If this function returns true, the buffer contents is lost. The buffer can still |
264 | 242 | * be used, but the results are undefined. The application is expected to release the buffer if needed, destroy it and recreate |
272 | 250 | } |
273 | 251 | |
274 | 252 | /** |
275 | * Method to make the Pbuffer context current. All subsequent OpenGL calls will go to this buffer. | |
276 | * @throws LWJGLException if the context could not be made current | |
277 | */ | |
278 | public synchronized void makeCurrent() throws LWJGLException { | |
279 | checkDestroyed(); | |
280 | context.makeCurrent(); | |
281 | } | |
282 | ||
283 | /** | |
284 | 253 | * Gets the Pbuffer capabilities. |
285 | 254 | * |
286 | 255 | * @return a bitmask of Pbuffer capabilities. |
287 | 256 | */ |
288 | 257 | public static int getCapabilities() { |
289 | 258 | return Display.getImplementation().getPbufferCapabilities(); |
290 | } | |
291 | ||
292 | /** | |
293 | * Destroys the Pbuffer. After this call, there will be no valid GL rendering context - regardless of whether this Pbuffer was | |
294 | * the current rendering context or not. | |
295 | */ | |
296 | public synchronized void destroy() { | |
297 | if (destroyed) | |
298 | return; | |
299 | try { | |
300 | context.forceDestroy(); | |
301 | peer_info.destroy(); | |
302 | destroyed = true; | |
303 | } catch (LWJGLException e) { | |
304 | LWJGLUtil.log("Exception occurred while destroying pbuffer: " + e); | |
305 | } | |
306 | 259 | } |
307 | 260 | |
308 | 261 | // ----------------------------------------------------------------------------------------- |
44 | 44 | * pixel format selection path, which could trigger a crash. |
45 | 45 | * |
46 | 46 | * @author elias_naur@sourceforge.net |
47 | * @version $Revision: 3116 $ | |
47 | * @version $Revision: 3355 $ | |
48 | 48 | */ |
49 | 49 | |
50 | 50 | public final class PixelFormat { |
65 | 65 | * 0 means that anti-aliasing is disabled. |
66 | 66 | */ |
67 | 67 | private int samples; |
68 | /** | |
69 | * The number of COLOR_SAMPLES_NV to use for Coverage Sample Anti-aliasing (CSAA). | |
70 | * When this number is greater than 0, the {@code samples} property will be treated | |
71 | * as if it were the COVERAGE_SAMPLES_NV property. | |
72 | * <p/> | |
73 | * This property is currently a no-op for the MacOS implementation. | |
74 | */ | |
75 | private int colorSamples; | |
68 | 76 | /** The number of auxiliary buffers */ |
69 | 77 | private int num_aux_buffers; |
70 | 78 | /** The number of bits per pixel in the accumulation buffer */ |
75 | 83 | private boolean stereo; |
76 | 84 | /** Whether this format specifies a floating point format */ |
77 | 85 | private boolean floating_point; |
78 | /** Whether this format specifies a packed floating point format (32 bit unsigned - R11F_G11F_B10F) */ | |
86 | /** | |
87 | * Whether this format specifies a packed floating point format (32 bit unsigned - R11F_G11F_B10F) | |
88 | * This property is currently a no-op for the MacOS implementation. | |
89 | */ | |
79 | 90 | private boolean floating_point_packed; |
80 | /** Whether this format specifies an sRGB format */ | |
91 | /** | |
92 | * Whether this format specifies an sRGB format | |
93 | * This property is currently a no-op for the MacOS implementation. | |
94 | */ | |
81 | 95 | private boolean sRGB; |
82 | 96 | |
83 | 97 | /** |
131 | 145 | this.stencil = pf.stencil; |
132 | 146 | |
133 | 147 | this.samples = pf.samples; |
148 | this.colorSamples = pf.colorSamples; | |
134 | 149 | |
135 | 150 | this.num_aux_buffers = pf.num_aux_buffers; |
136 | 151 | |
244 | 259 | return pf; |
245 | 260 | } |
246 | 261 | |
262 | /** | |
263 | * Returns a new PixelFormat object with the same properties as this PixelFormat and the new color samples values. | |
264 | * A value greater than 0 is valid only if the {@code samples} property is also greater than 0. Additionally, the | |
265 | * color samples value needs to be lower than or equal to the {@code samples} property. | |
266 | * | |
267 | * @param colorSamples the new color samples value. | |
268 | * | |
269 | * @return the new PixelFormat | |
270 | */ | |
271 | public PixelFormat withCoverageSamples(final int colorSamples) { | |
272 | return withCoverageSamples(colorSamples, samples); | |
273 | } | |
274 | ||
275 | /** | |
276 | * Returns a new PixelFormat object with the same properties as this PixelFormat and the new color samples | |
277 | * and coverage samples values. | |
278 | * | |
279 | * @param colorSamples the new color samples value. This value must be lower than or equal to the coverage samples value. | |
280 | * @param coverageSamples the new coverage samples value. | |
281 | * | |
282 | * @return the new PixelFormat | |
283 | */ | |
284 | public PixelFormat withCoverageSamples(final int colorSamples, final int coverageSamples) { | |
285 | if ( coverageSamples < 0 || colorSamples < 0 || (coverageSamples == 0 && 0 < colorSamples) || coverageSamples < colorSamples ) | |
286 | throw new IllegalArgumentException("Invalid number of coverage samples specified: " + coverageSamples + " - " + colorSamples); | |
287 | ||
288 | final PixelFormat pf = new PixelFormat(this); | |
289 | pf.samples = coverageSamples; | |
290 | pf.colorSamples = colorSamples; | |
291 | return pf; | |
292 | } | |
293 | ||
247 | 294 | public int getAuxBuffers() { |
248 | 295 | return num_aux_buffers; |
249 | 296 | } |
0 | /* | |
1 | * Copyright (c) 2002-2008 LWJGL Project | |
2 | * All rights reserved. | |
3 | * | |
4 | * Redistribution and use in source and binary forms, with or without | |
5 | * modification, are permitted provided that the following conditions are | |
6 | * met: | |
7 | * | |
8 | * * Redistributions of source code must retain the above copyright | |
9 | * notice, this list of conditions and the following disclaimer. | |
10 | * | |
11 | * * Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | |
14 | * | |
15 | * * Neither the name of 'LWJGL' nor the names of | |
16 | * its contributors may be used to endorse or promote products derived | |
17 | * from this software without specific prior written permission. | |
18 | * | |
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | |
23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
24 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
25 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
26 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | |
27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | |
31 | package org.lwjgl.opengl; | |
32 | ||
33 | import org.lwjgl.LWJGLException; | |
34 | ||
35 | /** | |
36 | * @author Spasi | |
37 | */ | |
38 | ||
39 | /** | |
40 | * A Drawable implementation that shares its context with another Drawable. This is useful | |
41 | * for background loading of resources. See org.lwjgl.test.opengl.multithread.BackgroundLoad | |
42 | * for an example. | |
43 | * | |
44 | * @author Spasi | |
45 | */ | |
46 | public final class SharedDrawable extends AbstractDrawable { | |
47 | ||
48 | public SharedDrawable(final Drawable drawable) throws LWJGLException { | |
49 | this.context = ((DrawableLWJGL)drawable).createSharedContext(); | |
50 | } | |
51 | ||
52 | public Context createSharedContext() { | |
53 | throw new UnsupportedOperationException(); | |
54 | } | |
55 | ||
56 | } |
436 | 436 | * is maximized helps some gfx cards recover from fullscreen |
437 | 437 | */ |
438 | 438 | try { |
439 | if (Display.getDrawable().getContext() != null && Display.getDrawable().getContext().isCurrent()) | |
440 | Display.getDrawable().getContext().makeCurrent(); | |
439 | Context context = ((DrawableLWJGL)Display.getDrawable()).getContext(); | |
440 | if (context != null && context.isCurrent()) | |
441 | context.makeCurrent(); | |
441 | 442 | } catch (LWJGLException e) { |
442 | 443 | LWJGLUtil.log("Exception occurred while trying to make context current: " + e); |
443 | 444 | } |
972 | 973 | return "Rect: top = " + top + " bottom = " + bottom + " left = " + left + " right = " + right; |
973 | 974 | } |
974 | 975 | } |
975 | } | |
976 | }⏎ |
0 | 0 | /* |
1 | * Copyright (c) 2002-2010 LWJGL Project | |
2 | * All rights reserved. | |
3 | * | |
1 | * Copyright (c) 2002-2010 LWJGL Project All rights reserved. | |
4 | 2 | * Redistribution and use in source and binary forms, with or without |
5 | * modification, are permitted provided that the following conditions are | |
6 | * met: | |
7 | * | |
8 | * * Redistributions of source code must retain the above copyright | |
9 | * notice, this list of conditions and the following disclaimer. | |
10 | * | |
11 | * * Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | |
14 | * | |
15 | * * Neither the name of 'LWJGL' nor the names of | |
16 | * its contributors may be used to endorse or promote products derived | |
17 | * from this software without specific prior written permission. | |
18 | * | |
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | |
23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
24 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
3 | * modification, are permitted provided that the following conditions | |
4 | * are met: * Redistributions of source code must retain the above | |
5 | * copyright notice, this list of conditions and the following | |
6 | * disclaimer. * Redistributions in binary form must reproduce the | |
7 | * above copyright notice, this list of conditions and the following | |
8 | * disclaimer in the documentation and/or other materials provided | |
9 | * with the distribution. * Neither the name of 'LWJGL' nor the names | |
10 | * of its contributors may be used to endorse or promote products | |
11 | * derived from this software without specific prior written | |
12 | * permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND | |
13 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, | |
14 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |
15 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
16 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS | |
17 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, | |
18 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
25 | 19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
26 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | |
27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | |
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE | |
23 | * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH | |
24 | * DAMAGE. | |
30 | 25 | */ |
31 | 26 | |
32 | 27 | package org.lwjgl.opengl; |
38 | 33 | import java.util.HashMap; |
39 | 34 | import java.util.List; |
40 | 35 | import java.util.Map; |
36 | import java.util.regex.Matcher; | |
41 | 37 | import java.util.regex.Pattern; |
42 | import java.security.AccessController; | |
43 | import java.security.PrivilegedAction; | |
38 | ||
39 | import org.lwjgl.LWJGLUtil; | |
44 | 40 | |
45 | 41 | /** |
46 | 42 | * Utility for working with the xrandr commmand-line utility. Assumes |
48 | 44 | * |
49 | 45 | * @author ryanm |
50 | 46 | */ |
51 | public class XRandR { | |
52 | ||
53 | private static Screen[] current; | |
54 | ||
55 | private static Map /* <String, Screen[]> */screens; | |
56 | ||
57 | private static void populate() { | |
58 | if (screens == null) { | |
47 | public class XRandR | |
48 | { | |
49 | private static Screen[] current; | |
50 | ||
51 | private static Map /* <String, Screen[]> */screens; | |
52 | ||
53 | private static void populate() | |
54 | { | |
55 | if( screens == null ) | |
56 | { | |
59 | 57 | screens = new HashMap/* <String, Screen[]> */(); |
60 | 58 | |
61 | 59 | // ProcessBuilder pb = new ProcessBuilder( "xrandr", "-q" ); |
62 | 60 | // pb.redirectErrorStream(); |
63 | try { | |
61 | try | |
62 | { | |
64 | 63 | // Process p= pb.start(); |
65 | Process p = Runtime.getRuntime().exec(new String[] { "xrandr", "-q"}); | |
64 | Process p = Runtime.getRuntime().exec( new String[] { "xrandr", "-q" } ); | |
66 | 65 | |
67 | 66 | List/* <Screen> */currentList = new ArrayList/* <Screen> */(); |
68 | 67 | List/* <Screen> */possibles = new ArrayList/* <Screen> */(); |
69 | 68 | String name = null; |
70 | 69 | |
71 | BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); | |
70 | BufferedReader br = new BufferedReader( new InputStreamReader( p.getInputStream() ) ); | |
72 | 71 | String line; |
73 | while ((line = br.readLine()) != null) { | |
72 | while( ( line = br.readLine() ) != null ) | |
73 | { | |
74 | 74 | line = line.trim(); |
75 | String[] sa = line.split("\\s+"); | |
76 | ||
77 | if (sa[1].equals("connected")) { | |
75 | String[] sa = line.split( "\\s+" ); | |
76 | ||
77 | if( sa[ 1 ].equals( "connected" ) ) | |
78 | { | |
78 | 79 | // found a new screen block |
79 | if (name != null) { | |
80 | screens.put(name, possibles.toArray(new Screen[possibles.size()])); | |
80 | if( name != null ) | |
81 | { | |
82 | screens.put( name, possibles.toArray( new Screen[ possibles.size() ] ) ); | |
81 | 83 | possibles.clear(); |
82 | 84 | } |
83 | name = sa[0]; | |
85 | name = sa[ 0 ]; | |
84 | 86 | |
85 | 87 | // record the current config |
86 | currentList.add(new Screen(name, sa[2])); | |
87 | } else if (Pattern.matches("\\d*x\\d*", sa[0])) { | |
88 | parseScreen( currentList, name, sa[ 2 ] ); | |
89 | } | |
90 | else if( Pattern.matches( "\\d*x\\d*", sa[ 0 ] ) ) | |
91 | { | |
88 | 92 | // found a new mode line |
89 | possibles.add(new Screen(name, sa[0])); | |
93 | parseScreen( possibles, name, sa[ 0 ] ); | |
90 | 94 | } |
91 | 95 | } |
92 | 96 | |
93 | screens.put(name, possibles.toArray(new Screen[possibles.size()])); | |
97 | screens.put( name, possibles.toArray( new Screen[ possibles.size() ] ) ); | |
94 | 98 | |
95 | 99 | current = (Screen[]) currentList.toArray(new Screen[currentList.size()]); |
96 | } catch (IOException e) { | |
97 | e.printStackTrace(); | |
100 | } | |
101 | catch( Throwable e ) | |
102 | { | |
103 | LWJGLUtil.log( "Exception in XRandR.populate(): " + e.getMessage() ); | |
104 | screens.clear(); | |
105 | current = new Screen[ 0 ]; | |
98 | 106 | } |
99 | 107 | } |
100 | 108 | } |
103 | 111 | * @return The current screen configuration, or an empty array if |
104 | 112 | * xrandr is not supported |
105 | 113 | */ |
106 | public static Screen[] getConfiguration() { | |
107 | AccessController.doPrivileged(new PrivilegedAction() { | |
108 | public Object run() { | |
109 | populate(); | |
110 | return null; | |
111 | } | |
112 | }); | |
114 | public static Screen[] getConfiguration() | |
115 | { | |
116 | populate(); | |
113 | 117 | |
114 | 118 | return (Screen[]) current.clone(); |
115 | 119 | } |
117 | 121 | /** |
118 | 122 | * @param screens |
119 | 123 | * The desired screen set, may not be <code>null</code> |
120 | */ | |
121 | public static void setConfiguration(Screen[]/* ... */screens) { | |
122 | if (screens.length == 0) { | |
123 | throw new IllegalArgumentException("Must specify at least one screen"); | |
124 | * @throws IllegalArgumentException | |
125 | * if no screens are specified | |
126 | */ | |
127 | public static void setConfiguration( Screen[]/* ... */screens ) | |
128 | { | |
129 | if( screens.length == 0 ) | |
130 | { | |
131 | throw new IllegalArgumentException( "Must specify at least one screen" ); | |
124 | 132 | } |
125 | 133 | |
126 | 134 | List/* <String> */cmd = new ArrayList/* <String> */(); |
127 | cmd.add("xrandr"); | |
135 | cmd.add( "xrandr" ); | |
128 | 136 | |
129 | 137 | // switch off those in the current set not in the new set |
130 | for (int i = 0; i < current.length; i++) { | |
138 | for( int i = 0; i < current.length; i++ ) | |
139 | { | |
131 | 140 | boolean found = false; |
132 | for (int j = 0; j < screens.length; j++) { | |
133 | if (screens[j].name.equals(current[i].name)) { | |
141 | for( int j = 0; j < screens.length; j++ ) | |
142 | { | |
143 | if( screens[ j ].name.equals( current[ i ].name ) ) | |
144 | { | |
134 | 145 | found = true; |
135 | 146 | break; |
136 | 147 | } |
137 | 148 | } |
138 | 149 | |
139 | if (!found) { | |
140 | cmd.add("--output"); | |
141 | cmd.add(current[i].name); | |
142 | cmd.add("--off"); | |
150 | if( !found ) | |
151 | { | |
152 | cmd.add( "--output" ); | |
153 | cmd.add( current[ i ].name ); | |
154 | cmd.add( "--off" ); | |
143 | 155 | } |
144 | 156 | } |
145 | 157 | |
146 | 158 | // set up new set |
147 | for (int i = 0; i < screens.length; i++) { | |
148 | screens[i].getArgs(cmd); | |
149 | } | |
150 | ||
151 | try { | |
159 | for( int i = 0; i < screens.length; i++ ) | |
160 | { | |
161 | screens[ i ].getArgs( cmd ); | |
162 | } | |
163 | ||
164 | try | |
165 | { | |
152 | 166 | // ProcessBuilder pb = new ProcessBuilder( cmd ); |
153 | 167 | // pb.redirectErrorStream(); |
154 | 168 | // Process p = pb.start(); |
155 | Process p = Runtime.getRuntime().exec((String[]) cmd.toArray(new String[cmd.size()])); | |
169 | Process p = | |
170 | Runtime.getRuntime().exec( ( String[] ) cmd.toArray( new String[ cmd.size() ] ) ); | |
156 | 171 | // no output is expected, but check anyway |
157 | BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); | |
172 | BufferedReader br = new BufferedReader( new InputStreamReader( p.getInputStream() ) ); | |
158 | 173 | String line; |
159 | while ((line = br.readLine()) != null) { | |
160 | System.out.println(line); | |
174 | while( ( line = br.readLine() ) != null ) | |
175 | { | |
176 | LWJGLUtil.log( "Unexpected output from xrandr process: " + line ); | |
161 | 177 | } |
162 | 178 | current = screens; |
163 | } catch (IOException e) { | |
164 | e.printStackTrace(); | |
165 | } | |
166 | ||
179 | } | |
180 | catch( IOException e ) | |
181 | { | |
182 | LWJGLUtil.log( "XRandR exception in setConfiguration(): " + e.getMessage() ); | |
183 | } | |
167 | 184 | } |
168 | 185 | |
169 | 186 | /** |
170 | 187 | * @return the name of connected screens, or an empty array if |
171 | 188 | * xrandr is not supported |
172 | 189 | */ |
173 | public static String[] getScreenNames() { | |
190 | public static String[] getScreenNames() | |
191 | { | |
174 | 192 | populate(); |
175 | return (String[]) screens.keySet().toArray(new String[screens.size()]); | |
193 | return ( String[] ) screens.keySet().toArray( new String[ screens.size() ] ); | |
176 | 194 | } |
177 | 195 | |
178 | 196 | /** |
180 | 198 | * @return the possible resolutions of the named screen, or |
181 | 199 | * <code>null</code> if there is no such screen |
182 | 200 | */ |
183 | public static Screen[] getResolutions(String name) { | |
201 | public static Screen[] getResolutions( String name ) | |
202 | { | |
184 | 203 | populate(); |
185 | 204 | // clone the array to prevent held copies being altered |
186 | 205 | return (Screen[]) ((Screen[]) screens.get(name)).clone(); |
206 | } | |
207 | ||
208 | private static final Pattern SCREEN_PATTERN1 = | |
209 | Pattern.compile( "^(\\d+)x(\\d+)\\+(\\d+)\\+(\\d+)$" ); | |
210 | ||
211 | private static final Pattern SCREEN_PATTERN2 = Pattern.compile( "^(\\d+)x(\\d+)$" ); | |
212 | ||
213 | /** | |
214 | * Parses a screen configuration and adds it to the list if it's | |
215 | * valid. | |
216 | * | |
217 | * @param list | |
218 | * the list to add the Screen to if it's valid | |
219 | * @param name | |
220 | * the name of this screen | |
221 | * @param what | |
222 | * config string, format either widthxheight or | |
223 | * widthxheight+xPos+yPos | |
224 | */ | |
225 | private static void parseScreen( List /* <Screen> */list, String name, String what ) | |
226 | { | |
227 | Matcher m = SCREEN_PATTERN1.matcher( what ); | |
228 | if( !m.matches() ) | |
229 | { | |
230 | m = SCREEN_PATTERN2.matcher( what ); | |
231 | if( !m.matches() ) | |
232 | { | |
233 | LWJGLUtil.log( "Did not match: " + what ); | |
234 | return; | |
235 | } | |
236 | } | |
237 | int width = Integer.parseInt( m.group( 1 ) ); | |
238 | int height = Integer.parseInt( m.group( 2 ) ); | |
239 | int xpos, ypos; | |
240 | if( m.groupCount() > 3 ) | |
241 | { | |
242 | xpos = Integer.parseInt( m.group( 3 ) ); | |
243 | ypos = Integer.parseInt( m.group( 4 ) ); | |
244 | } | |
245 | else | |
246 | { | |
247 | xpos = 0; | |
248 | ypos = 0; | |
249 | } | |
250 | list.add( new Screen( name, width, height, xpos, ypos ) ); | |
187 | 251 | } |
188 | 252 | |
189 | 253 | /** |
192 | 256 | * |
193 | 257 | * @author ryanm |
194 | 258 | */ |
195 | public static class Screen implements Cloneable { | |
196 | ||
259 | public static class Screen implements Cloneable | |
260 | { | |
197 | 261 | /** |
198 | 262 | * Name for this output |
199 | 263 | */ |
200 | public final String name; | |
264 | public final String name; | |
201 | 265 | |
202 | 266 | /** |
203 | 267 | * Width in pixels |
204 | 268 | */ |
205 | public final int width; | |
269 | public final int width; | |
206 | 270 | |
207 | 271 | /** |
208 | 272 | * Height in pixels |
209 | 273 | */ |
210 | public final int height; | |
274 | public final int height; | |
211 | 275 | |
212 | 276 | /** |
213 | 277 | * Position on the x-axis, in pixels |
214 | 278 | */ |
215 | public int xPos = 0; | |
279 | public int xPos = 0; | |
216 | 280 | |
217 | 281 | /** |
218 | 282 | * Position on the y-axis, in pixels |
219 | 283 | */ |
220 | public int yPos = 0; | |
221 | ||
222 | /** | |
223 | * @param name | |
224 | * name of the screen | |
225 | * @param conf | |
226 | * config string, format either widthxheight or | |
227 | * widthxheight+xPos+yPos | |
228 | */ | |
229 | private Screen(String name, String conf) { | |
284 | public int yPos = 0; | |
285 | ||
286 | private Screen( String name, int width, int height, int xPos, int yPos ) | |
287 | { | |
230 | 288 | this.name = name; |
231 | ||
232 | String[] sa = conf.split("\\D"); | |
233 | width = Integer.parseInt(sa[0]); | |
234 | height = Integer.parseInt(sa[1]); | |
235 | ||
236 | if (sa.length > 2) { | |
237 | xPos = Integer.parseInt(sa[2]); | |
238 | yPos = Integer.parseInt(sa[3]); | |
239 | } | |
240 | } | |
241 | ||
242 | private void getArgs(List/* <String> */argList) { | |
243 | argList.add("--output"); | |
244 | argList.add(name); | |
245 | argList.add("--mode"); | |
246 | argList.add(width + "x" + height); | |
247 | argList.add("--pos"); | |
248 | argList.add(xPos + "x" + yPos); | |
249 | } | |
250 | ||
251 | // @Override | |
252 | public String toString() { | |
289 | this.width = width; | |
290 | this.height = height; | |
291 | this.xPos = xPos; | |
292 | this.yPos = yPos; | |
293 | } | |
294 | ||
295 | private void getArgs( List/* <String> */argList ) | |
296 | { | |
297 | argList.add( "--output" ); | |
298 | argList.add( name ); | |
299 | argList.add( "--mode" ); | |
300 | argList.add( width + "x" + height ); | |
301 | argList.add( "--pos" ); | |
302 | argList.add( xPos + "x" + yPos ); | |
303 | } | |
304 | ||
305 | //@Override | |
306 | public String toString() | |
307 | { | |
253 | 308 | return name + " " + width + "x" + height + " @ " + xPos + "x" + yPos; |
254 | 309 | } |
255 | 310 | } |
256 | } | |
311 | }⏎ |
0 | /* | |
1 | * Copyright (c) 2002-2010 LWJGL Project | |
2 | * All rights reserved. | |
3 | * | |
4 | * Redistribution and use in source and binary forms, with or without | |
5 | * modification, are permitted provided that the following conditions are | |
6 | * met: | |
7 | * | |
8 | * * Redistributions of source code must retain the above copyright | |
9 | * notice, this list of conditions and the following disclaimer. | |
10 | * | |
11 | * * Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | |
14 | * | |
15 | * * Neither the name of 'LWJGL' nor the names of | |
16 | * its contributors may be used to endorse or promote products derived | |
17 | * from this software without specific prior written permission. | |
18 | * | |
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | |
23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
24 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
25 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
26 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | |
27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | |
31 | package org.lwjgl.test.openal; | |
32 | ||
33 | import java.nio.IntBuffer; | |
34 | ||
35 | import org.lwjgl.BufferUtils; | |
36 | import org.lwjgl.openal.AL; | |
37 | import org.lwjgl.openal.AL10; | |
38 | import org.lwjgl.openal.AL11; | |
39 | import org.lwjgl.openal.ALC10; | |
40 | import org.lwjgl.openal.ALCcontext; | |
41 | import org.lwjgl.openal.ALCdevice; | |
42 | import org.lwjgl.openal.EFX10; | |
43 | import org.lwjgl.openal.EFXUtil; | |
44 | import org.lwjgl.util.WaveData; | |
45 | ||
46 | /** | |
47 | * Class with a few examples testing and demonstrating the use of the OpenAL extension ALC_EXT_EFX. | |
48 | * <p> | |
49 | * This class is not compatible with the LWJGL debug build (lwjgl-debug.jar), as the debug build | |
50 | * throws exceptions instead of alGetError checks. The redundant exception handling code was not | |
51 | * added in order to keep these examples simple. | |
52 | * | |
53 | * @author Ciardhubh <ciardhubh[at]ciardhubh.de> | |
54 | * @version $Revision$ | |
55 | * $Id$ | |
56 | */ | |
57 | public final class EFX10Test { | |
58 | ||
59 | public static void main(final String[] args) throws Exception { | |
60 | silentTests(); | |
61 | playbackTest(); | |
62 | efxUtilTest(); | |
63 | } | |
64 | ||
65 | /** | |
66 | * Loads OpenAL and makes sure ALC_EXT_EFX is supported. | |
67 | */ | |
68 | private static void setupEfx() throws Exception { | |
69 | // Load and create OpenAL | |
70 | if (!AL.isCreated()) { | |
71 | AL.create(); | |
72 | } | |
73 | // Query for Effect Extension | |
74 | if (!ALC10.alcIsExtensionPresent(AL.getDevice(), EFX10.ALC_EXT_EFX_NAME)) { | |
75 | throw new Exception("No ALC_EXT_EFX supported by driver."); | |
76 | } | |
77 | System.out.println("ALC_EXT_EFX found."); | |
78 | } | |
79 | ||
80 | /** | |
81 | * Runs a series of API calls similar to the tutorials in the Effects Extension Guide of the | |
82 | * OpenAL SDK. Nothing is played in this method. | |
83 | */ | |
84 | private static void silentTests() throws Exception { | |
85 | setupEfx(); | |
86 | ||
87 | final ALCdevice device = AL.getDevice(); | |
88 | ||
89 | // Create context (only necessary if LWJGL context isn't sufficient, done as example) | |
90 | final IntBuffer contextAttribList = BufferUtils.createIntBuffer(8); | |
91 | contextAttribList.put(ALC10.ALC_FREQUENCY); | |
92 | contextAttribList.put(44100); | |
93 | contextAttribList.put(ALC10.ALC_REFRESH); | |
94 | contextAttribList.put(60); | |
95 | contextAttribList.put(ALC10.ALC_SYNC); | |
96 | contextAttribList.put(ALC10.ALC_FALSE); | |
97 | contextAttribList.rewind(); | |
98 | // ALC_MAX_AUXILIARY_SENDS won't go above compile-time max. Set to compile-time max if | |
99 | // greater. | |
100 | contextAttribList.put(EFX10.ALC_MAX_AUXILIARY_SENDS); | |
101 | contextAttribList.put(2); | |
102 | final ALCcontext newContext = ALC10.alcCreateContext(device, contextAttribList); | |
103 | if (newContext == null) { | |
104 | throw new Exception("Failed to create context."); | |
105 | } | |
106 | final int contextCurResult = ALC10.alcMakeContextCurrent(newContext); | |
107 | if (contextCurResult == ALC10.ALC_FALSE) { | |
108 | throw new Exception("Failed to make context current."); | |
109 | } | |
110 | ||
111 | // Query EFX ALC values | |
112 | System.out.println("AL_VERSION: " + AL10.alGetString(AL10.AL_VERSION)); | |
113 | final IntBuffer buff = BufferUtils.createIntBuffer(1); | |
114 | ALC10.alcGetInteger(device, EFX10.ALC_EFX_MAJOR_VERSION, buff); | |
115 | System.out.println("ALC_EFX_MAJOR_VERSION: " + buff.get(0)); | |
116 | ALC10.alcGetInteger(device, EFX10.ALC_EFX_MINOR_VERSION, buff); | |
117 | System.out.println("ALC_EFX_MINOR_VERSION: " + buff.get(0)); | |
118 | ALC10.alcGetInteger(device, EFX10.ALC_MAX_AUXILIARY_SENDS, buff); | |
119 | final int maxAuxSends = buff.get(0); | |
120 | System.out.println("ALC_MAX_AUXILIARY_SENDS: " + maxAuxSends); | |
121 | ||
122 | ||
123 | // Try to create 4 Auxiliary Effect Slots | |
124 | int numAuxSlots = 0; | |
125 | final int[] auxEffectSlots = new int[4]; // try more to test | |
126 | AL10.alGetError(); | |
127 | for (numAuxSlots = 0; numAuxSlots < 4; numAuxSlots++) { | |
128 | auxEffectSlots[numAuxSlots] = EFX10.alGenAuxiliaryEffectSlots(); | |
129 | if (AL10.alGetError() != AL10.AL_NO_ERROR) { | |
130 | break; | |
131 | } | |
132 | } | |
133 | System.out.println("Created " + numAuxSlots + " aux effect slots."); | |
134 | ||
135 | // Try to create 2 Effects | |
136 | int numEffects = 0; | |
137 | final int[] effects = new int[2]; | |
138 | for (numEffects = 0; numEffects < 2; numEffects++) { | |
139 | effects[numEffects] = EFX10.alGenEffects(); | |
140 | if (AL10.alGetError() != AL10.AL_NO_ERROR) { | |
141 | break; | |
142 | } | |
143 | } | |
144 | System.out.println("Created " + numEffects + " effects."); | |
145 | ||
146 | // Set first Effect Type to Reverb and change Decay Time | |
147 | AL10.alGetError(); | |
148 | if (EFX10.alIsEffect(effects[0])) { | |
149 | EFX10.alEffecti(effects[0], EFX10.AL_EFFECT_TYPE, EFX10.AL_EFFECT_REVERB); | |
150 | if (AL10.alGetError() != AL10.AL_NO_ERROR) { | |
151 | System.out.println("Reverb effect not supported."); | |
152 | } else { | |
153 | EFX10.alEffectf(effects[0], EFX10.AL_REVERB_DECAY_TIME, 5.0f); | |
154 | System.out.println("Reverb effect created."); | |
155 | } | |
156 | } else { | |
157 | throw new Exception("First effect not a valid effect."); | |
158 | } | |
159 | ||
160 | // Set second Effect Type to Flanger and change Phase | |
161 | AL10.alGetError(); | |
162 | if (EFX10.alIsEffect(effects[1])) { | |
163 | EFX10.alEffecti(effects[1], EFX10.AL_EFFECT_TYPE, EFX10.AL_EFFECT_FLANGER); | |
164 | if (AL10.alGetError() != AL10.AL_NO_ERROR) { | |
165 | System.out.println("Flanger effect not support."); | |
166 | } else { | |
167 | EFX10.alEffecti(effects[1], EFX10.AL_FLANGER_PHASE, 180); | |
168 | System.out.println("Flanger effect created."); | |
169 | } | |
170 | } else { | |
171 | throw new Exception("Second effect not a valid effect."); | |
172 | } | |
173 | ||
174 | // Try to create a Filter | |
175 | AL10.alGetError(); | |
176 | final int filter = EFX10.alGenFilters(); | |
177 | if (AL10.alGetError() != AL10.AL_NO_ERROR) { | |
178 | throw new Exception("Failed to create filter."); | |
179 | } | |
180 | System.out.println("Generated a filter."); | |
181 | if (EFX10.alIsFilter(filter)) { | |
182 | // Set Filter type to Low-Pass and set parameters | |
183 | EFX10.alFilteri(filter, EFX10.AL_FILTER_TYPE, EFX10.AL_FILTER_LOWPASS); | |
184 | if (AL10.alGetError() != AL10.AL_NO_ERROR) { | |
185 | System.out.println("Low pass filter not supported."); | |
186 | } else { | |
187 | EFX10.alFilterf(filter, EFX10.AL_LOWPASS_GAIN, 0.5f); | |
188 | EFX10.alFilterf(filter, EFX10.AL_LOWPASS_GAINHF, 0.5f); | |
189 | System.out.println("Low pass filter created."); | |
190 | } | |
191 | } | |
192 | ||
193 | // Attach Effect to Auxiliary Effect Slot | |
194 | AL10.alGetError(); | |
195 | EFX10.alAuxiliaryEffectSloti(auxEffectSlots[0], EFX10.AL_EFFECTSLOT_EFFECT, effects[0]); | |
196 | if (AL10.alGetError() != AL10.AL_NO_ERROR) { | |
197 | throw new Exception("Failed to attach effect to aux effect slot."); | |
198 | } | |
199 | System.out.println("Successfully loaded effect into effect slot."); | |
200 | ||
201 | // Configure Source Auxiliary Effect Slot Sends | |
202 | final int source = AL10.alGenSources(); | |
203 | // Set Source Send 0 to feed auxEffectSlots[0] without filtering | |
204 | AL11.alSource3i(source, EFX10.AL_AUXILIARY_SEND_FILTER, auxEffectSlots[0], 0, | |
205 | EFX10.AL_FILTER_NULL); | |
206 | if (AL10.alGetError() != AL10.AL_NO_ERROR) { | |
207 | throw new Exception("Failed to configure Source Send 0"); | |
208 | } | |
209 | System.out.println("Linked aux effect slot to soutce slot 0"); | |
210 | // Set Source Send 1 to feed uiEffectSlot[1] with filter filter | |
211 | AL11.alSource3i(source, EFX10.AL_AUXILIARY_SEND_FILTER, auxEffectSlots[1], 1, filter); | |
212 | if (AL10.alGetError() != AL10.AL_NO_ERROR) { | |
213 | // e.g. if only 1 send per source is available | |
214 | throw new Exception("Failed to configure Source Send 1"); | |
215 | } | |
216 | System.out.println("Linked aux effect slot to soutce slot 1"); | |
217 | // Disable Send 0 | |
218 | AL11.alSource3i(source, EFX10.AL_AUXILIARY_SEND_FILTER, EFX10.AL_EFFECTSLOT_NULL, 0, | |
219 | EFX10.AL_FILTER_NULL); | |
220 | if (AL10.alGetError() != AL10.AL_NO_ERROR) { | |
221 | throw new Exception("Failed to disable Source Send 0"); | |
222 | } | |
223 | System.out.println("Disabled source send 0"); | |
224 | // Disable Send 1 | |
225 | AL11.alSource3i(source, EFX10.AL_AUXILIARY_SEND_FILTER, EFX10.AL_EFFECTSLOT_NULL, 1, | |
226 | EFX10.AL_FILTER_NULL); | |
227 | if (AL10.alGetError() != AL10.AL_NO_ERROR) { | |
228 | throw new Exception("Failed to disable Source Send 1"); | |
229 | } | |
230 | System.out.println("Disabled source send 1"); | |
231 | ||
232 | ||
233 | // Filter 'source', a generated Source | |
234 | AL10.alSourcei(source, EFX10.AL_DIRECT_FILTER, filter); | |
235 | if (AL10.alGetError() == AL10.AL_NO_ERROR) { | |
236 | { | |
237 | System.out.println("Successfully applied a direct path filter"); | |
238 | // Remove filter from 'source' | |
239 | AL10.alSourcei(source, EFX10.AL_DIRECT_FILTER, EFX10.AL_FILTER_NULL); | |
240 | if (AL10.alGetError() == AL10.AL_NO_ERROR) { | |
241 | System.out.println("Successfully removed direct filter"); | |
242 | } | |
243 | } | |
244 | // Filter the Source send 0 from 'source' to Auxiliary Effect Slot auxEffectSlot[0] | |
245 | // using Filter uiFilter[0] | |
246 | AL11.alSource3i(source, EFX10.AL_AUXILIARY_SEND_FILTER, auxEffectSlots[0], 0, filter); | |
247 | if (AL10.alGetError() == AL10.AL_NO_ERROR) { | |
248 | { | |
249 | System.out.println("Successfully applied aux send filter"); | |
250 | // Remove Filter from Source Auxiliary Send | |
251 | AL11.alSource3i(source, EFX10.AL_AUXILIARY_SEND_FILTER, auxEffectSlots[0], 0, | |
252 | EFX10.AL_FILTER_NULL); | |
253 | if (AL10.alGetError() == AL10.AL_NO_ERROR) { | |
254 | System.out.println("Successfully removed filter"); | |
255 | } | |
256 | } | |
257 | } | |
258 | } | |
259 | ||
260 | // Set Source Cone Outer Gain HF value | |
261 | AL10.alSourcef(source, EFX10.AL_CONE_OUTER_GAINHF, 0.5f); | |
262 | if (AL10.alGetError() == AL10.AL_NO_ERROR) { | |
263 | System.out.println("Successfully set cone outside gain filter"); | |
264 | } | |
265 | ||
266 | // Set distance units to be in feet | |
267 | AL10.alListenerf(EFX10.AL_METERS_PER_UNIT, 0.3f); | |
268 | if (AL10.alGetError() == AL10.AL_NO_ERROR) { | |
269 | System.out.println("Successfully set distance units"); | |
270 | } | |
271 | ||
272 | // Cleanup | |
273 | final IntBuffer auxEffectSlotsBuf = (IntBuffer) BufferUtils.createIntBuffer( | |
274 | auxEffectSlots.length).put(auxEffectSlots).rewind(); | |
275 | EFX10.alDeleteAuxiliaryEffectSlots(auxEffectSlotsBuf); | |
276 | final IntBuffer effectsBuf = (IntBuffer) BufferUtils.createIntBuffer( | |
277 | effects.length).put(effects).rewind(); | |
278 | EFX10.alDeleteEffects(effectsBuf); | |
279 | EFX10.alDeleteFilters(filter); | |
280 | AL.destroy(); | |
281 | } | |
282 | ||
283 | /** | |
284 | * Plays a sound with various effects applied to it. | |
285 | */ | |
286 | private static void playbackTest() throws Exception { | |
287 | setupEfx(); | |
288 | ||
289 | // Create a source and buffer audio data | |
290 | final int source = AL10.alGenSources(); | |
291 | final int buffer = AL10.alGenBuffers(); | |
292 | WaveData waveFile = WaveData.create(WaveData.class.getClassLoader().getResourceAsStream("Footsteps.wav")); | |
293 | if (waveFile == null) { | |
294 | System.out.println("Failed to load Footsteps.wav! Skipping playback test."); | |
295 | AL.destroy(); | |
296 | return; | |
297 | } | |
298 | AL10.alBufferData(buffer, waveFile.format, waveFile.data, waveFile.samplerate); | |
299 | waveFile.dispose(); | |
300 | AL10.alSourcei(source, AL10.AL_BUFFER, buffer); | |
301 | AL10.alSourcei(source, AL10.AL_LOOPING, AL10.AL_TRUE); | |
302 | ||
303 | System.out.println("Playing sound unaffected by EFX ..."); | |
304 | AL10.alSourcePlay(source); | |
305 | Thread.sleep(7500); | |
306 | ||
307 | // Add reverb effect | |
308 | final int effectSlot = EFX10.alGenAuxiliaryEffectSlots(); | |
309 | final int reverbEffect = EFX10.alGenEffects(); | |
310 | EFX10.alEffecti(reverbEffect, EFX10.AL_EFFECT_TYPE, EFX10.AL_EFFECT_REVERB); | |
311 | EFX10.alEffectf(reverbEffect, EFX10.AL_REVERB_DECAY_TIME, 5.0f); | |
312 | EFX10.alAuxiliaryEffectSloti(effectSlot, EFX10.AL_EFFECTSLOT_EFFECT, reverbEffect); | |
313 | AL11.alSource3i(source, EFX10.AL_AUXILIARY_SEND_FILTER, effectSlot, 0, | |
314 | EFX10.AL_FILTER_NULL); | |
315 | ||
316 | System.out.println("Playing sound with reverb ..."); | |
317 | AL10.alSourcePlay(source); | |
318 | Thread.sleep(7500); | |
319 | ||
320 | // Add low-pass filter directly to source | |
321 | final int filter = EFX10.alGenFilters(); | |
322 | EFX10.alFilteri(filter, EFX10.AL_FILTER_TYPE, EFX10.AL_FILTER_LOWPASS); | |
323 | EFX10.alFilterf(filter, EFX10.AL_LOWPASS_GAIN, 0.5f); | |
324 | EFX10.alFilterf(filter, EFX10.AL_LOWPASS_GAINHF, 0.5f); | |
325 | AL10.alSourcei(source, EFX10.AL_DIRECT_FILTER, filter); | |
326 | ||
327 | System.out.println("Playing sound with reverb and direct low pass filter ..."); | |
328 | AL10.alSourcePlay(source); | |
329 | Thread.sleep(7500); | |
330 | AL10.alSourcei(source, EFX10.AL_DIRECT_FILTER, EFX10.AL_FILTER_NULL); | |
331 | ||
332 | // Add low-pass filter to source send | |
333 | //AL11.alSource3i(source, EFX10.AL_AUXILIARY_SEND_FILTER, effectSlot, 0, filter); | |
334 | // | |
335 | //System.out.println("Playing sound with reverb and aux send low pass filter ..."); | |
336 | //AL10.alSourcePlay(source); | |
337 | //Thread.sleep(7500); | |
338 | ||
339 | // Cleanup | |
340 | AL11.alSource3i(source, EFX10.AL_AUXILIARY_SEND_FILTER, EFX10.AL_EFFECTSLOT_NULL, 0, | |
341 | EFX10.AL_FILTER_NULL); | |
342 | EFX10.alAuxiliaryEffectSloti(effectSlot, EFX10.AL_EFFECTSLOT_EFFECT, EFX10.AL_EFFECT_NULL); | |
343 | EFX10.alDeleteEffects(reverbEffect); | |
344 | EFX10.alDeleteFilters(filter); | |
345 | ||
346 | // Echo effect | |
347 | final int echoEffect = EFX10.alGenEffects(); | |
348 | EFX10.alEffecti(echoEffect, EFX10.AL_EFFECT_TYPE, EFX10.AL_EFFECT_ECHO); | |
349 | //EFX10.alEffectf(echoEffect, EFX10.AL_ECHO_DELAY, 5.0f); | |
350 | EFX10.alAuxiliaryEffectSloti(effectSlot, EFX10.AL_EFFECTSLOT_EFFECT, echoEffect); | |
351 | AL11.alSource3i(source, EFX10.AL_AUXILIARY_SEND_FILTER, effectSlot, 0, | |
352 | EFX10.AL_FILTER_NULL); | |
353 | ||
354 | System.out.println("Playing sound with echo effect ..."); | |
355 | AL10.alSourcePlay(source); | |
356 | Thread.sleep(7500); | |
357 | ||
358 | AL.destroy(); | |
359 | } | |
360 | ||
361 | /** | |
362 | * Checks OpenAL for every EFX 1.0 effect and filter and prints the result to the console. | |
363 | */ | |
364 | private static void efxUtilTest() throws Exception { | |
365 | setupEfx(); | |
366 | ||
367 | System.out.println(); | |
368 | System.out.println("Checking supported effects ..."); | |
369 | if (EFXUtil.isEffectSupported(EFX10.AL_EFFECT_NULL)) { | |
370 | System.out.println("AL_EFFECT_NULL is supported."); | |
371 | } else { | |
372 | System.out.println("AL_EFFECT_NULL is NOT supported."); | |
373 | } | |
374 | if (EFXUtil.isEffectSupported(EFX10.AL_EFFECT_EAXREVERB)) { | |
375 | System.out.println("AL_EFFECT_EAXREVERB is supported."); | |
376 | } else { | |
377 | System.out.println("AL_EFFECT_EAXREVERB is NOT supported."); | |
378 | } | |
379 | if (EFXUtil.isEffectSupported(EFX10.AL_EFFECT_REVERB)) { | |
380 | System.out.println("AL_EFFECT_REVERB is supported."); | |
381 | } else { | |
382 | System.out.println("AL_EFFECT_REVERB is NOT supported."); | |
383 | } | |
384 | if (EFXUtil.isEffectSupported(EFX10.AL_EFFECT_CHORUS)) { | |
385 | System.out.println("AL_EFFECT_CHORUS is supported."); | |
386 | } else { | |
387 | System.out.println("AL_EFFECT_CHORUS is NOT supported."); | |
388 | } | |
389 | if (EFXUtil.isEffectSupported(EFX10.AL_EFFECT_DISTORTION)) { | |
390 | System.out.println("AL_EFFECT_DISTORTION is supported."); | |
391 | } else { | |
392 | System.out.println("AL_EFFECT_DISTORTION is NOT supported."); | |
393 | } | |
394 | if (EFXUtil.isEffectSupported(EFX10.AL_EFFECT_ECHO)) { | |
395 | System.out.println("AL_EFFECT_ECHO is supported."); | |
396 | } else { | |
397 | System.out.println("AL_EFFECT_ECHO is NOT supported."); | |
398 | } | |
399 | if (EFXUtil.isEffectSupported(EFX10.AL_EFFECT_FLANGER)) { | |
400 | System.out.println("AL_EFFECT_FLANGER is supported."); | |
401 | } else { | |
402 | System.out.println("AL_EFFECT_FLANGER is NOT supported."); | |
403 | } | |
404 | if (EFXUtil.isEffectSupported(EFX10.AL_EFFECT_FREQUENCY_SHIFTER)) { | |
405 | System.out.println("AL_EFFECT_FREQUENCY_SHIFTER is supported."); | |
406 | } else { | |
407 | System.out.println("AL_EFFECT_FREQUENCY_SHIFTER is NOT supported."); | |
408 | } | |
409 | if (EFXUtil.isEffectSupported(EFX10.AL_EFFECT_VOCAL_MORPHER)) { | |
410 | System.out.println("AL_EFFECT_VOCAL_MORPHER is supported."); | |
411 | } else { | |
412 | System.out.println("AL_EFFECT_VOCAL_MORPHER is NOT supported."); | |
413 | } | |
414 | if (EFXUtil.isEffectSupported(EFX10.AL_EFFECT_PITCH_SHIFTER)) { | |
415 | System.out.println("AL_EFFECT_PITCH_SHIFTER is supported."); | |
416 | } else { | |
417 | System.out.println("AL_EFFECT_PITCH_SHIFTER is NOT supported."); | |
418 | } | |
419 | if (EFXUtil.isEffectSupported(EFX10.AL_EFFECT_RING_MODULATOR)) { | |
420 | System.out.println("AL_EFFECT_RING_MODULATOR is supported."); | |
421 | } else { | |
422 | System.out.println("AL_EFFECT_RING_MODULATOR is NOT supported."); | |
423 | } | |
424 | if (EFXUtil.isEffectSupported(EFX10.AL_EFFECT_AUTOWAH)) { | |
425 | System.out.println("AL_EFFECT_AUTOWAH is supported."); | |
426 | } else { | |
427 | System.out.println("AL_EFFECT_AUTOWAH is NOT supported."); | |
428 | } | |
429 | if (EFXUtil.isEffectSupported(EFX10.AL_EFFECT_COMPRESSOR)) { | |
430 | System.out.println("AL_EFFECT_COMPRESSOR is supported."); | |
431 | } else { | |
432 | System.out.println("AL_EFFECT_COMPRESSOR is NOT supported."); | |
433 | } | |
434 | if (EFXUtil.isEffectSupported(EFX10.AL_EFFECT_EQUALIZER)) { | |
435 | System.out.println("AL_EFFECT_EQUALIZER is supported."); | |
436 | } else { | |
437 | System.out.println("AL_EFFECT_EQUALIZER is NOT supported."); | |
438 | } | |
439 | ||
440 | System.out.println(); | |
441 | System.out.println("Checking supported filters ..."); | |
442 | if (EFXUtil.isFilterSupported(EFX10.AL_FILTER_NULL)) { | |
443 | System.out.println("AL_FILTER_NULL is supported."); | |
444 | } else { | |
445 | System.out.println("AL_FILTER_NULL is NOT supported."); | |
446 | } | |
447 | if (EFXUtil.isFilterSupported(EFX10.AL_FILTER_LOWPASS)) { | |
448 | System.out.println("AL_FILTER_LOWPASS is supported."); | |
449 | } else { | |
450 | System.out.println("AL_FILTER_LOWPASS is NOT supported."); | |
451 | } | |
452 | if (EFXUtil.isFilterSupported(EFX10.AL_FILTER_HIGHPASS)) { | |
453 | System.out.println("AL_FILTER_HIGHPASS is supported."); | |
454 | } else { | |
455 | System.out.println("AL_FILTER_HIGHPASS is NOT supported."); | |
456 | } | |
457 | if (EFXUtil.isFilterSupported(EFX10.AL_FILTER_BANDPASS)) { | |
458 | System.out.println("AL_FILTER_BANDPASS is supported."); | |
459 | } else { | |
460 | System.out.println("AL_FILTER_BANDPASS is NOT supported."); | |
461 | } | |
462 | } | |
463 | } |
31 | 31 | package org.lwjgl.test.openal; |
32 | 32 | |
33 | 33 | import java.nio.IntBuffer; |
34 | import java.util.HashMap; | |
35 | import java.util.Iterator; | |
36 | import java.util.Map; | |
37 | import java.util.Set; | |
38 | import java.util.Map.Entry; | |
34 | 39 | |
35 | 40 | import org.lwjgl.BufferUtils; |
36 | 41 | import org.lwjgl.LWJGLException; |
39 | 44 | import org.lwjgl.openal.ALC10; |
40 | 45 | import org.lwjgl.openal.ALC11; |
41 | 46 | import org.lwjgl.openal.ALCdevice; |
47 | import org.lwjgl.openal.EFX10; | |
48 | import org.lwjgl.openal.EFXUtil; | |
42 | 49 | |
43 | 50 | /** |
44 | 51 | * |
69 | 76 | |
70 | 77 | printALCInfo(); |
71 | 78 | printALInfo(); |
79 | printEFXInfo(); | |
72 | 80 | |
73 | 81 | checkForErrors(); |
74 | 82 | |
93 | 101 | device = ALC10.alcGetContextsDevice(ALC10.alcGetCurrentContext()); |
94 | 102 | checkForErrors(); |
95 | 103 | |
96 | System.out.println("Default device: " + ALC10.alcGetString(device, ALC10.ALC_DEFAULT_DEVICE_SPECIFIER)); | |
104 | System.out.println("Default playback device: " + ALC10.alcGetString(device, ALC10.ALC_DEFAULT_DEVICE_SPECIFIER)); | |
97 | 105 | |
98 | 106 | System.out.println("Default capture device: " + ALC10.alcGetString(device, ALC11.ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER)); |
99 | 107 | |
129 | 137 | checkForErrors(); |
130 | 138 | } |
131 | 139 | |
140 | private void printEFXInfo() { | |
141 | if(!EFXUtil.isEfxSupported()) { | |
142 | System.out.println("EFX not available"); | |
143 | return; | |
144 | } | |
145 | ||
146 | ALCdevice device = AL.getDevice(); | |
147 | IntBuffer major = BufferUtils.createIntBuffer(1); | |
148 | IntBuffer minor = BufferUtils.createIntBuffer(1); | |
149 | IntBuffer sends = BufferUtils.createIntBuffer(1); | |
150 | ALC10.alcGetInteger(device, EFX10.ALC_EFX_MAJOR_VERSION, major); | |
151 | ALC10.alcGetInteger(device, EFX10.ALC_EFX_MINOR_VERSION, minor); | |
152 | if(ALC10.alcGetError(device) == ALC10.ALC_NO_ERROR) { | |
153 | System.out.println("EFX version: " + major.get() + "." + minor.get()); | |
154 | } | |
155 | ||
156 | ALC10.alcGetInteger(device, EFX10.ALC_MAX_AUXILIARY_SENDS, sends); | |
157 | if(ALC10.alcGetError(device) == ALC10.ALC_NO_ERROR) { | |
158 | System.out.println("Max auxiliary sends: " + sends.get()); | |
159 | } | |
160 | ||
161 | System.out.println("Supported filters: "); | |
162 | HashMap filters = new HashMap(); | |
163 | filters.put("Low-pass", new Integer(EFX10.AL_FILTER_LOWPASS)); | |
164 | filters.put("High-pass", new Integer(EFX10.AL_FILTER_HIGHPASS)); | |
165 | filters.put("Band-pass", new Integer(EFX10.AL_FILTER_BANDPASS)); | |
166 | ||
167 | Set entries = filters.entrySet(); | |
168 | for(Iterator i = entries.iterator(); i.hasNext();) { | |
169 | Map.Entry entry = (Entry) i.next(); | |
170 | int value = ((Integer)entry.getValue()).intValue(); | |
171 | String key = (String) entry.getKey(); | |
172 | if(EFXUtil.isFilterSupported(value)) { | |
173 | System.out.println(" " + key); | |
174 | } | |
175 | } | |
176 | ||
177 | System.out.println("Supported effects: "); | |
178 | HashMap effects = new HashMap(); | |
179 | effects.put("EAX Reverb", new Integer(EFX10.AL_EFFECT_EAXREVERB)); | |
180 | effects.put("Reverb", new Integer(EFX10.AL_EFFECT_REVERB)); | |
181 | effects.put("Chorus", new Integer(EFX10.AL_EFFECT_CHORUS)); | |
182 | effects.put("Distortion", new Integer(EFX10.AL_EFFECT_DISTORTION)); | |
183 | effects.put("Echo", new Integer(EFX10.AL_EFFECT_ECHO)); | |
184 | effects.put("Flanger", new Integer(EFX10.AL_EFFECT_FLANGER)); | |
185 | effects.put("Frequency Shifter", new Integer(EFX10.AL_EFFECT_FREQUENCY_SHIFTER)); | |
186 | effects.put("Vocal Morpher", new Integer(EFX10.AL_EFFECT_VOCAL_MORPHER)); | |
187 | effects.put("Pitch Shifter", new Integer(EFX10.AL_EFFECT_PITCH_SHIFTER)); | |
188 | effects.put("Ring Modulator", new Integer(EFX10.AL_EFFECT_RING_MODULATOR)); | |
189 | effects.put("Autowah", new Integer(EFX10.AL_EFFECT_AUTOWAH)); | |
190 | effects.put("Compressor", new Integer(EFX10.AL_EFFECT_COMPRESSOR)); | |
191 | effects.put("Equalizer", new Integer(EFX10.AL_EFFECT_EQUALIZER)); | |
192 | ||
193 | entries = effects.entrySet(); | |
194 | for(Iterator i = entries.iterator(); i.hasNext();) { | |
195 | Map.Entry entry = (Entry) i.next(); | |
196 | int value = ((Integer)entry.getValue()).intValue(); | |
197 | String key = (String) entry.getKey(); | |
198 | if(EFXUtil.isEffectSupported(value)) { | |
199 | System.out.println(" " + key); | |
200 | } | |
201 | } | |
202 | } | |
203 | ||
132 | 204 | private void printDevices(int which, String kind) { |
133 | 205 | String[] devices = ALC10.alcGetString(null, which).split("\0"); |
134 | 206 | checkForErrors(); |
32 | 32 | |
33 | 33 | import org.lwjgl.LWJGLException; |
34 | 34 | import org.lwjgl.input.Keyboard; |
35 | import org.lwjgl.input.Mouse; | |
35 | 36 | import org.lwjgl.opengl.Display; |
36 | 37 | import org.lwjgl.opengl.DisplayMode; |
37 | 38 | import org.lwjgl.opengl.GL11; |
43 | 44 | * Tests switching between windowed and fullscreen |
44 | 45 | * |
45 | 46 | * @author Brian Matzon <brian@matzon.dk> |
46 | * @version $Revision: 3172 $ | |
47 | * $Id: FullScreenWindowedTest.java 3172 2008-12-28 19:30:43Z elias_naur $ | |
47 | * @version $Revision: 3365 $ | |
48 | * $Id: FullScreenWindowedTest.java 3365 2010-07-04 18:24:53Z spasi $ | |
48 | 49 | */ |
49 | 50 | public class FullScreenWindowedTest { |
50 | 51 | /** Intended deiplay mode */ |
221 | 222 | if (angleRotation > MAX_SPEED) { |
222 | 223 | angleRotation = MAX_SPEED; |
223 | 224 | } |
225 | ||
226 | while ( Mouse.next() ); | |
224 | 227 | } |
225 | 228 | /** |
226 | 229 | * Cleans up the test |
30 | 30 | */ |
31 | 31 | |
32 | 32 | /** |
33 | * $Id: VBOIndexTest.java 2983 2008-04-07 18:36:09Z matzon $ | |
33 | * $Id: VBOIndexTest.java 3344 2010-05-22 16:53:49Z spasi $ | |
34 | 34 | * |
35 | 35 | * Simple java test program. |
36 | 36 | * |
37 | 37 | * @author elias_naur <elias_naur@users.sourceforge.net> |
38 | * @version $Revision: 2983 $ | |
38 | * @version $Revision: 3344 $ | |
39 | 39 | */ |
40 | 40 | |
41 | 41 | package org.lwjgl.test.opengl; |
178 | 178 | mapped_indices_buffer); |
179 | 179 | if ( new_mapped_buffer != mapped_indices_buffer ) |
180 | 180 | mapped_indices_int_buffer = new_mapped_buffer.order(ByteOrder.nativeOrder()).asIntBuffer(); |
181 | mapped_indices_buffer = new_mapped_buffer; | |
181 | 182 | |
182 | 183 | mapped_float_buffer.rewind(); |
183 | 184 | vertices.rewind(); |
28 | 28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
29 | 29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
30 | 30 | */ |
31 | /* | |
32 | * Created by LWJGL. | |
33 | * User: spasi | |
34 | * Date: 2009-04-04 | |
35 | * Time: 21:20:24 pm | |
36 | */ | |
37 | ||
38 | 31 | package org.lwjgl.test.opengl; |
39 | 32 | |
40 | 33 | import org.lwjgl.LWJGLException; |
43 | 36 | import java.util.StringTokenizer; |
44 | 37 | import java.util.regex.Pattern; |
45 | 38 | |
39 | /** | |
40 | * Tests the ARB_create_context extension through the use of the ContextAttribs class. | |
41 | * | |
42 | * @author Spasi | |
43 | */ | |
46 | 44 | public final class VersionTest { |
47 | 45 | |
48 | 46 | private VersionTest() { |
109 | 107 | |
110 | 108 | System.out.println("\n---------\n"); |
111 | 109 | |
110 | System.out.println("Requested " + ca); | |
111 | ||
112 | 112 | final String version = GL11.glGetString(GL11.GL_VERSION); |
113 | 113 | |
114 | System.out.print("GL Version requested: " + majorInput + '.' + minorInput); | |
115 | if ( ca.isProfileCore() ) | |
116 | System.out.print(" - Core Profile"); | |
117 | else if ( ca.isProfileCompatibility() ) | |
118 | System.out.print(" - Compatibility Profile"); | |
119 | System.out.println("\nGL Version returned : " + version); | |
114 | boolean deprecated = false; | |
115 | try { | |
116 | GL11.glVertex3f(0.0f, 0.0f, 0.0f); | |
117 | deprecated = true; | |
118 | } catch (Throwable t) {} | |
120 | 119 | |
121 | 120 | final StringTokenizer version_tokenizer = new StringTokenizer(version, ". "); |
122 | 121 | |
123 | 122 | int majorVersion = Integer.parseInt(version_tokenizer.nextToken()); |
124 | 123 | int minorVersion = Integer.parseInt(version_tokenizer.nextToken()); |
125 | 124 | |
126 | if ( majorVersion != majorInput || minorVersion != minorInput ) { | |
127 | if ( majorInput == 1 && minorInput == 0 ) | |
128 | System.out.println("\tThe maximum supported version has been returned. The driver is well-behaved. :)"); | |
129 | else if ( majorInput < 3 && majorVersion < 3 ) | |
130 | System.out.println("\tThe maximum supported version pre-3.0 has been returned. The driver is well-behaved. :)"); | |
131 | else | |
132 | System.out.println("\tThe requested version was not returned. The driver is buggy! :("); | |
133 | } else | |
134 | System.out.println("\tThe requested version was returned. :)"); | |
135 | ||
136 | if ( ca.isProfileCompatibility() && !GLContext.getCapabilities().GL_ARB_compatibility ) | |
137 | System.out.println("\tThe driver does not support the Compatibility Profile."); | |
138 | ||
139 | System.out.println("\n---------\n"); | |
140 | ||
141 | System.out.println("Debug mode: " + ca.isDebug()); | |
142 | System.out.println("Forward compatible mode: " + ca.isForwardCompatible()); | |
143 | System.out.println("ARB_compatibility: " + GLContext.getCapabilities().GL_ARB_compatibility); | |
144 | try { | |
145 | GL11.glVertex3f(0.0f, 0.0f, 0.0f); | |
146 | System.out.println("Deprecated functionality present: " + true); | |
147 | } catch (Throwable t) { | |
148 | System.out.println("Deprecated functionality present: " + false); | |
149 | if ( GLContext.getCapabilities().GL_ARB_compatibility ) { | |
150 | System.out.println("\tARB_compatibility is present, but LWJGL has enabled pseudo-forward compatible mode."); | |
151 | } | |
125 | final boolean compatibilityProfile; | |
126 | final boolean coreProfile; | |
127 | ||
128 | if ( 3 < majorVersion || (majorVersion == 3 && 2 <= minorVersion) ) { | |
129 | final int profileMask = GL11.glGetInteger(GL32.GL_CONTEXT_PROFILE_MASK); | |
130 | ||
131 | compatibilityProfile = (profileMask & GL32.GL_CONTEXT_COMPATIBILITY_PROFILE_BIT) != 0; | |
132 | coreProfile = (profileMask & GL32.GL_CONTEXT_CORE_PROFILE_BIT) != 0; | |
133 | } else { | |
134 | compatibilityProfile = false; | |
135 | coreProfile = false; | |
136 | } | |
137 | ||
138 | System.out.println("\nGL_VERSION returned : " + version); | |
139 | System.out.println("\tCore profile: " + coreProfile); | |
140 | System.out.println("\tCompatibility profile: " + compatibilityProfile); | |
141 | System.out.println("ARB_compatibility present: " + GLContext.getCapabilities().GL_ARB_compatibility); | |
142 | System.out.println("Deprecated functionality present: " + deprecated); | |
143 | if ( !deprecated && GLContext.getCapabilities().GL_ARB_compatibility ) | |
144 | System.out.println("\tARB_compatibility is present, but LWJGL has enabled pseudo-forward compatible mode."); | |
145 | ||
146 | System.out.println("\n---------"); | |
147 | ||
148 | boolean success = false; | |
149 | boolean check; | |
150 | if ( majorInput < 3 || (majorInput == 3 && minorInput == 0) ) { | |
151 | System.out.println("\nA version less than or equal to 3.0 is requested, the context\n" + | |
152 | "returned may implement any of the following versions:"); | |
153 | ||
154 | System.out.println("\n1) Any version no less than that requested and no greater than 3.0."); | |
155 | check = (majorInput < majorVersion || (majorInput == majorVersion && minorInput <= minorVersion)) // Satisfies requested version | |
156 | && (majorVersion < 3 || (majorVersion == 3 && minorVersion == 0)); // 3.0 or earlier | |
157 | System.out.println("\t" + check); | |
158 | success |= check; | |
159 | ||
160 | System.out.println("\n2) Version 3.1, if the GL_ARB_compatibility extension is also implemented."); | |
161 | check = majorVersion == 3 && minorVersion == 1 && GLContext.getCapabilities().GL_ARB_compatibility; | |
162 | System.out.println("\t" + check); | |
163 | success |= check; | |
164 | ||
165 | System.out.println("\n3) The compatibility profile of version 3.2 or greater."); | |
166 | check = compatibilityProfile; // No need to check version, profiles are only available with 3.2+. | |
167 | System.out.println("\t" + check); | |
168 | success |= check; | |
169 | ||
170 | System.out.println("\nTEST " + (success ? "SUCCEEDED" : "FAILED")); | |
171 | if ( !success && ca.isForwardCompatible() ) | |
172 | System.out.println("\t(probably because the forward compatible flag was set)"); | |
173 | } else if ( majorInput == 3 && minorInput == 1 ) { | |
174 | System.out.println("\nVersion 3.1 is requested, the context returned may implement\n" + | |
175 | "any of the following versions:"); | |
176 | ||
177 | System.out.println("\n1) Version 3.1. The GL_ARB_compatibility extension may or may not\n" + | |
178 | "be implemented, as determined by the implementation."); | |
179 | check = majorVersion == 3 && minorVersion == 1; | |
180 | System.out.println("\t" + check); | |
181 | success |= check; | |
182 | ||
183 | System.out.println("\n2) The core profile of version 3.2 or greater."); | |
184 | check = coreProfile; // No need to check version, profiles are only available with 3.2+. | |
185 | System.out.println("\t" + check); | |
186 | success |= check; | |
187 | ||
188 | System.out.println("\nTEST " + (success ? "SUCCEEDED" : "FAILED")); | |
189 | } else { | |
190 | System.out.println("\nVersion 3.2 or greater is requested, the context returned may\n" + | |
191 | "implement any of the following versions:"); | |
192 | ||
193 | System.out.println("\n1) The requested profile of the requested version."); | |
194 | check = majorInput == majorVersion && minorInput == minorVersion | |
195 | && (!ca.isProfileCompatibility() || compatibilityProfile) | |
196 | && (!ca.isProfileCore() || coreProfile); | |
197 | System.out.println("\t" + check); | |
198 | success |= check; | |
199 | ||
200 | System.out.println("\n2) The requested profile of any later version, so long as no\n" + | |
201 | "features have been removed from that later version and profile."); | |
202 | check = majorInput < majorVersion || (majorInput == majorVersion && minorInput < minorVersion) | |
203 | && (!ca.isProfileCompatibility() || compatibilityProfile) | |
204 | && (!ca.isProfileCore() || coreProfile); | |
205 | System.out.println("\t" + check); | |
206 | success |= check; | |
207 | ||
208 | System.out.println("\nTEST " + (success ? "SUCCEEDED" : "FAILED")); | |
152 | 209 | } |
153 | 210 | } |
154 | 211 | |
173 | 230 | |
174 | 231 | private static void argsError(final String msg) { |
175 | 232 | System.out.println("\nInvalid arguments error: " + msg); |
176 | System.out.println("\nUsage: VersionTest <majorVersion> <minorVersion> {<layer>, 'debug', 'fc'}:\n"); | |
233 | System.out.println("\nUsage: VersionTest <majorVersion> <minorVersion> {'core'|'compatibility', <layer>, 'debug', 'fc'}:\n"); | |
177 | 234 | System.out.println("majorVersion\t- Major OpenGL version."); |
178 | 235 | System.out.println("majorVersion\t- Minor OpenGL version."); |
236 | System.out.println("core\t- Sets the Core Profile bit (optional, requires 3.2+)."); | |
237 | System.out.println("compatibility\t- Sets the Compatibility Profile bit (optional, requires 3.2+)."); | |
179 | 238 | System.out.println("layer\t- Layer plane (optional)."); |
180 | 239 | System.out.println("debug\t- Enables debug mode (optional)."); |
181 | System.out.println("fc\t- Enables forward compatibility mode (optional)."); | |
240 | System.out.println("fc\t- Enables forward compatibility mode (optional, requires 3.0+)."); | |
182 | 241 | |
183 | 242 | cleanup(); |
184 | 243 | System.exit(-1); |
192 | 251 | System.exit(-1); |
193 | 252 | } |
194 | 253 | |
195 | }⏎ | |
254 | } |
149 | 149 | addWindowListener(new WindowAdapter() { |
150 | 150 | |
151 | 151 | public void windowClosing(WindowEvent e) { |
152 | demoCanvas.destroy(); | |
152 | demoCanvas.destroyCanvas(); | |
153 | 153 | dispose(); |
154 | 154 | System.exit(0); |
155 | 155 | } |
268 | 268 | } |
269 | 269 | } |
270 | 270 | |
271 | public void destroy() { | |
271 | public void destroyCanvas() { | |
272 | 272 | setActiveDemo(null); |
273 | 273 | renderThread = null; |
274 | 274 | } |
0 | /* | |
1 | * Copyright (c) 2002-2008 LWJGL Project | |
2 | * All rights reserved. | |
3 | * | |
4 | * Redistribution and use in source and binary forms, with or without | |
5 | * modification, are permitted provided that the following conditions are | |
6 | * met: | |
7 | * | |
8 | * * Redistributions of source code must retain the above copyright | |
9 | * notice, this list of conditions and the following disclaimer. | |
10 | * | |
11 | * * Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | |
14 | * | |
15 | * * Neither the name of 'LWJGL' nor the names of | |
16 | * its contributors may be used to endorse or promote products derived | |
17 | * from this software without specific prior written permission. | |
18 | * | |
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | |
23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
24 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
25 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
26 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | |
27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | |
31 | package org.lwjgl.test.opengl.multithread; | |
32 | ||
33 | import org.lwjgl.BufferUtils; | |
34 | import org.lwjgl.LWJGLException; | |
35 | import org.lwjgl.input.Keyboard; | |
36 | import org.lwjgl.input.Mouse; | |
37 | import org.lwjgl.opengl.*; | |
38 | import org.lwjgl.util.glu.GLU; | |
39 | import org.lwjgl.util.glu.Sphere; | |
40 | ||
41 | import java.nio.FloatBuffer; | |
42 | ||
43 | /** | |
44 | * A test of loading textures in a background thread. This can be achieved in 2 ways: | |
45 | * <br> | |
46 | * a) A dummy Pbuffer is created and its context shares the rendering context.<br> | |
47 | * b) A SharedDrawable is used.<br> | |
48 | * <br> | |
49 | * When the test starts, there's no texture created and rendering is done with texturing disabled. | |
50 | * 2 seconds later a "dummy" texture is created in the background thread and texturing is enabled. This dummy texture | |
51 | * can by anything the developer wants to have as a placeholder while textures are being loaded. | |
52 | * Finally, 5 seconds later the "true" texture is loaded and displayed. This texture will change every 5 seconds after | |
53 | * that, until the test is terminated (ESC key). | |
54 | * | |
55 | * @author Spasi | |
56 | */ | |
57 | public final class BackgroundLoadTest { | |
58 | ||
59 | private static boolean run = true; | |
60 | ||
61 | private static BackgroundLoader backgroundLoader; | |
62 | ||
63 | private static Sphere sphere; | |
64 | ||
65 | private BackgroundLoadTest() { | |
66 | } | |
67 | ||
68 | public static void main(String[] args) { | |
69 | initialize(args); | |
70 | ||
71 | Util.checkGLError(); | |
72 | ||
73 | try { | |
74 | backgroundLoader.start(); | |
75 | } catch (LWJGLException e) { | |
76 | kill("Failed to start background thread.", e); | |
77 | } | |
78 | ||
79 | Util.checkGLError(); | |
80 | ||
81 | while ( run ) { | |
82 | if ( !Display.isVisible() ) | |
83 | Thread.yield(); | |
84 | else { | |
85 | handleIO(); | |
86 | ||
87 | GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); | |
88 | ||
89 | renderObject(); | |
90 | ||
91 | Util.checkGLError(); | |
92 | ||
93 | // Restore camera position. | |
94 | GL11.glPopMatrix(); | |
95 | GL11.glPushMatrix(); | |
96 | } | |
97 | ||
98 | Display.update(); | |
99 | ||
100 | if ( Display.isCloseRequested() ) | |
101 | break; | |
102 | } | |
103 | ||
104 | cleanup(); | |
105 | System.exit(0); | |
106 | } | |
107 | ||
108 | private static void initialize(String[] args) { | |
109 | if ( args.length != 1 ) | |
110 | argsError(); | |
111 | ||
112 | DisplayMode displayMode = null; | |
113 | ||
114 | try { | |
115 | DisplayMode[] modes = Display.getAvailableDisplayModes(); | |
116 | ||
117 | displayMode = chooseMode(modes, 1024, 768); | |
118 | if ( displayMode == null ) | |
119 | displayMode = chooseMode(modes, 800, 600); | |
120 | if ( displayMode == null ) | |
121 | displayMode = chooseMode(modes, 640, 480); | |
122 | if ( displayMode == null ) | |
123 | kill("Failed to set an appropriate display mode."); | |
124 | ||
125 | System.out.println("Setting display mode to: " + displayMode); | |
126 | Display.setDisplayMode(displayMode); | |
127 | Display.setTitle("Background Loading Test"); | |
128 | Display.create(new PixelFormat(8, 24, 0)); | |
129 | } catch (LWJGLException e) { | |
130 | kill(e.getMessage()); | |
131 | } | |
132 | ||
133 | GL11.glViewport(0, 0, displayMode.getWidth(), displayMode.getHeight()); | |
134 | ||
135 | GL11.glMatrixMode(GL11.GL_PROJECTION); | |
136 | GL11.glLoadIdentity(); | |
137 | GLU.gluPerspective(45, displayMode.getWidth() / (float)displayMode.getHeight(), 1.0f, 10.0f); | |
138 | ||
139 | GL11.glMatrixMode(GL11.GL_MODELVIEW); | |
140 | GL11.glLoadIdentity(); | |
141 | ||
142 | // Setup camera position. | |
143 | GL11.glTranslatef(0.0f, 0.0f, -4.0f); | |
144 | GL11.glRotatef(90.0f, 1.0f, 0.0f, 0.0f); | |
145 | GL11.glPushMatrix(); | |
146 | ||
147 | GL11.glClearDepth(1.0f); | |
148 | GL11.glDepthFunc(GL11.GL_LEQUAL); | |
149 | ||
150 | GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST); | |
151 | ||
152 | GL11.glFrontFace(GL11.GL_CCW); | |
153 | GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_FILL); | |
154 | ||
155 | GL11.glCullFace(GL11.GL_BACK); | |
156 | GL11.glEnable(GL11.GL_CULL_FACE); | |
157 | ||
158 | GL11.glAlphaFunc(GL11.GL_GREATER, 0.0f); | |
159 | GL11.glEnable(GL11.GL_ALPHA_TEST); | |
160 | ||
161 | GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); | |
162 | GL11.glDisable(GL11.GL_BLEND); | |
163 | ||
164 | GL11.glShadeModel(GL11.GL_SMOOTH); | |
165 | ||
166 | final FloatBuffer vectorBuffer = BufferUtils.createFloatBuffer(4); | |
167 | ||
168 | vectorBuffer.clear(); | |
169 | vectorBuffer.put(0, 1.0f).put(1, 1.0f).put(2, 1.0f).put(3, 1.0f); | |
170 | GL11.glLight(GL11.GL_LIGHT0, GL11.GL_DIFFUSE, vectorBuffer); | |
171 | ||
172 | vectorBuffer.put(0, 1.0f).put(1, 1.0f).put(2, 1.0f).put(3, 1.0f); | |
173 | GL11.glLight(GL11.GL_LIGHT0, GL11.GL_AMBIENT, vectorBuffer); | |
174 | ||
175 | vectorBuffer.put(0, 1.0f).put(1, 1.0f).put(2, 0.5f).put(3, 1.0f); | |
176 | GL11.glLight(GL11.GL_LIGHT0, GL11.GL_SPECULAR, vectorBuffer); | |
177 | ||
178 | vectorBuffer.put(0, -1.0f / 3.0f).put(1, 1.0f / 3.0f).put(2, 1.0f / 3.0f).put(3, 0.0f); // Infinite | |
179 | GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, vectorBuffer); | |
180 | ||
181 | vectorBuffer.put(0, 0.2f).put(1, 0.2f).put(2, 0.2f).put(3, 1.0f); | |
182 | GL11.glLightModel(GL11.GL_LIGHT_MODEL_AMBIENT, vectorBuffer); | |
183 | ||
184 | GL11.glEnable(GL11.GL_LIGHT0); | |
185 | GL11.glEnable(GL11.GL_LIGHTING); | |
186 | ||
187 | sphere = new Sphere(); | |
188 | ||
189 | if ( "PB".equalsIgnoreCase(args[0]) ) { | |
190 | backgroundLoader = new BackgroundLoader() { | |
191 | Drawable getDrawable() throws LWJGLException { | |
192 | return new Pbuffer(2, 2, new PixelFormat(8, 24, 0), Display.getDrawable()); | |
193 | } | |
194 | }; | |
195 | } else if ( "SD".equalsIgnoreCase(args[0]) ) { | |
196 | backgroundLoader = new BackgroundLoader() { | |
197 | Drawable getDrawable() throws LWJGLException { | |
198 | return new SharedDrawable(Display.getDrawable()); | |
199 | } | |
200 | }; | |
201 | } else { | |
202 | argsError(); | |
203 | } | |
204 | } | |
205 | ||
206 | private static void handleIO() { | |
207 | if ( Keyboard.getNumKeyboardEvents() != 0 ) { | |
208 | while ( Keyboard.next() ) { | |
209 | if ( Keyboard.getEventKeyState() ) | |
210 | continue; | |
211 | ||
212 | switch ( Keyboard.getEventKey() ) { | |
213 | case Keyboard.KEY_ESCAPE: | |
214 | run = false; | |
215 | break; | |
216 | } | |
217 | } | |
218 | } | |
219 | ||
220 | while ( Mouse.next() ) ; | |
221 | } | |
222 | ||
223 | static void renderObject() { | |
224 | GL11.glColor3f(1.0f, 1.0f, 1.0f); | |
225 | ||
226 | int texID = backgroundLoader.getTexID(); | |
227 | if ( texID == 0 ) { | |
228 | sphere.setTextureFlag(false); | |
229 | GL11.glDisable(GL11.GL_TEXTURE_2D); | |
230 | } else { | |
231 | sphere.setTextureFlag(true); | |
232 | GL11.glEnable(GL11.GL_TEXTURE_2D); | |
233 | GL11.glBindTexture(GL11.GL_TEXTURE_2D, texID); | |
234 | } | |
235 | ||
236 | sphere.draw(1.0f, 32, 32); | |
237 | ||
238 | if ( texID != 0 ) { // Unbind so we can update from the background thread. | |
239 | GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); | |
240 | GL11.glDisable(GL11.GL_TEXTURE_2D); | |
241 | } | |
242 | } | |
243 | ||
244 | private static DisplayMode chooseMode(DisplayMode[] modes, int width, int height) { | |
245 | DisplayMode bestMode = null; | |
246 | ||
247 | for ( int i = 0; i < modes.length; i++ ) { | |
248 | DisplayMode mode = modes[i]; | |
249 | if ( mode.getWidth() == width && mode.getHeight() == height && mode.getFrequency() <= 85 ) { | |
250 | if ( bestMode == null || (mode.getBitsPerPixel() >= bestMode.getBitsPerPixel() && mode.getFrequency() > bestMode.getFrequency()) ) | |
251 | bestMode = mode; | |
252 | } | |
253 | } | |
254 | ||
255 | return bestMode; | |
256 | } | |
257 | ||
258 | private static void cleanup() { | |
259 | backgroundLoader.cleanup(); | |
260 | ||
261 | Thread.yield(); // Let background thread finish. | |
262 | ||
263 | if ( Display.isCreated() ) | |
264 | Display.destroy(); | |
265 | } | |
266 | ||
267 | private static void argsError() { | |
268 | System.out.println("\nInvalid program arguments."); | |
269 | System.out.println("\nUsage: BackgroundLoadTest <testType>, where <testType> argument can be one of the following:\n"); | |
270 | System.out.println("PB\t- Use a Pbuffer context for the background thread."); | |
271 | System.out.println("SD\t- Use a SharedDrawable context for the background thread."); | |
272 | ||
273 | cleanup(); | |
274 | System.exit(-1); | |
275 | } | |
276 | ||
277 | static void kill(String reason) { | |
278 | System.out.println("The BackgroundLoadTest program was terminated because an error occured.\n"); | |
279 | System.out.println("Reason: " + (reason == null ? "Unknown" : reason)); | |
280 | ||
281 | cleanup(); | |
282 | System.exit(-1); | |
283 | } | |
284 | ||
285 | static void kill(String reason, Throwable t) { | |
286 | System.out.println("The BackgroundLoadTest program was terminated because an exception occured.\n"); | |
287 | System.out.println("Reason: " + (reason == null ? "Unknown" : reason)); | |
288 | ||
289 | System.out.println("Exception message: " + t.getMessage()); | |
290 | ||
291 | cleanup(); | |
292 | System.exit(-1); | |
293 | } | |
294 | ||
295 | }⏎ |
0 | /* | |
1 | * Copyright (c) 2002-2008 LWJGL Project | |
2 | * All rights reserved. | |
3 | * | |
4 | * Redistribution and use in source and binary forms, with or without | |
5 | * modification, are permitted provided that the following conditions are | |
6 | * met: | |
7 | * | |
8 | * * Redistributions of source code must retain the above copyright | |
9 | * notice, this list of conditions and the following disclaimer. | |
10 | * | |
11 | * * Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | |
14 | * | |
15 | * * Neither the name of 'LWJGL' nor the names of | |
16 | * its contributors may be used to endorse or promote products derived | |
17 | * from this software without specific prior written permission. | |
18 | * | |
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | |
23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
24 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
25 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
26 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | |
27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | |
31 | /* | |
32 | * Created by LWJGL. | |
33 | * User: spasi | |
34 | * Date: 2004-03-30 | |
35 | * Time: 8:41:42 pm | |
36 | */ | |
37 | package org.lwjgl.test.opengl.multithread; | |
38 | ||
39 | import org.lwjgl.BufferUtils; | |
40 | import org.lwjgl.LWJGLException; | |
41 | import org.lwjgl.opengl.Drawable; | |
42 | import org.lwjgl.opengl.GL11; | |
43 | import org.lwjgl.util.Color; | |
44 | import org.lwjgl.util.ReadableColor; | |
45 | ||
46 | import java.nio.ByteBuffer; | |
47 | ||
48 | abstract class BackgroundLoader { | |
49 | ||
50 | private static final int WIDTH = 32; | |
51 | private static final int HEIGHT = 32; | |
52 | ||
53 | private static final Object lock = new Object(); | |
54 | ||
55 | private Drawable drawable; | |
56 | ||
57 | private boolean running; | |
58 | ||
59 | private ByteBuffer texture; | |
60 | private int texID; | |
61 | ||
62 | protected BackgroundLoader() { | |
63 | running = true; | |
64 | texture = BufferUtils.createByteBuffer(WIDTH * HEIGHT * 3); | |
65 | } | |
66 | ||
67 | abstract Drawable getDrawable() throws LWJGLException; | |
68 | ||
69 | void cleanup() { | |
70 | running = false; | |
71 | } | |
72 | ||
73 | void start() throws LWJGLException { | |
74 | new Thread(new Runnable() { | |
75 | public void run() { | |
76 | System.out.println("-- Background Thread started --"); | |
77 | ||
78 | System.out.println("** Sleeping, no texture created yet **"); | |
79 | ||
80 | try { | |
81 | Thread.sleep(2000); | |
82 | } catch (InterruptedException e) { | |
83 | e.printStackTrace(); | |
84 | } | |
85 | ||
86 | try { | |
87 | drawable = getDrawable(); | |
88 | drawable.makeCurrent(); | |
89 | } catch (LWJGLException e) { | |
90 | throw new RuntimeException(e); | |
91 | } | |
92 | ||
93 | System.out.println("** Drawable created **"); | |
94 | ||
95 | synchronized ( lock ) { | |
96 | // Create a "dummy" texture while we wait for texture IO | |
97 | createCheckerTexture(Color.RED, Color.WHITE, 2); | |
98 | ||
99 | texID = GL11.glGenTextures(); | |
100 | GL11.glBindTexture(GL11.GL_TEXTURE_2D, texID); | |
101 | GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB, WIDTH, HEIGHT, 0, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, texture); | |
102 | ||
103 | GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); | |
104 | GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); | |
105 | ||
106 | GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); | |
107 | } | |
108 | ||
109 | System.out.println("** Dummy texture created **"); | |
110 | ||
111 | long lastTextureCreated = System.currentTimeMillis(); // Delay first texture creation | |
112 | int count = 0; | |
113 | while ( running ) { | |
114 | long time = System.currentTimeMillis(); | |
115 | if ( time - lastTextureCreated < 5000 ) { // Update the texture every 5 seconds | |
116 | try { | |
117 | Thread.sleep(200); | |
118 | } catch (InterruptedException e) { | |
119 | e.printStackTrace(); | |
120 | } | |
121 | continue; | |
122 | } | |
123 | ||
124 | // Create the "true" texture | |
125 | if ( count % 2 == 0 ) | |
126 | createGradientTexture(Color.RED, Color.BLUE); | |
127 | else | |
128 | createGradientTexture(Color.GREEN, Color.YELLOW); | |
129 | ||
130 | GL11.glBindTexture(GL11.GL_TEXTURE_2D, texID); | |
131 | GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB, WIDTH, HEIGHT, 0, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, texture); | |
132 | ||
133 | GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); | |
134 | GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); | |
135 | ||
136 | GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); | |
137 | ||
138 | System.out.println("** Created new gradient texture **"); | |
139 | ||
140 | lastTextureCreated = System.currentTimeMillis(); | |
141 | count++; | |
142 | } | |
143 | ||
144 | drawable.destroy(); | |
145 | ||
146 | System.out.println("-- Background Thread finished --"); | |
147 | } | |
148 | }).start(); | |
149 | } | |
150 | ||
151 | int getTexID() { | |
152 | synchronized ( lock ) { | |
153 | return texID; | |
154 | } | |
155 | } | |
156 | ||
157 | private void createCheckerTexture(final ReadableColor a, final ReadableColor b, final int size) { | |
158 | int i = 0; | |
159 | for ( int y = 0; y < HEIGHT; y++ ) { | |
160 | for ( int x = 0; x < WIDTH; x++ ) { | |
161 | ReadableColor c = (x / size) % 2 == 0 ? ((y / size) % 2 == 0 ? a : b) : ((y / size) % 2 == 0 ? b : a); | |
162 | texture.put(i + 0, c.getRedByte()); | |
163 | texture.put(i + 1, c.getGreenByte()); | |
164 | texture.put(i + 2, c.getBlueByte()); | |
165 | i += 3; | |
166 | } | |
167 | } | |
168 | } | |
169 | ||
170 | private void createGradientTexture(final ReadableColor a, final ReadableColor b) { | |
171 | float l = 0.0f; | |
172 | int i = 0; | |
173 | for ( int y = 0; y < HEIGHT; y++ ) { | |
174 | for ( int x = 0; x < WIDTH; x++ ) { | |
175 | texture.put(i + 0, lerp(a.getRed(), b.getRed(), l)); | |
176 | texture.put(i + 1, lerp(a.getGreen(), b.getGreen(), l)); | |
177 | texture.put(i + 2, lerp(a.getBlue(), b.getBlue(), l)); | |
178 | i += 3; | |
179 | } | |
180 | l += (1.0f / (HEIGHT - 1)); | |
181 | } | |
182 | } | |
183 | ||
184 | private static byte lerp(final int a, final int b, final float l) { | |
185 | return (byte)Math.round(((1.0f - l) * a + l * b)); | |
186 | } | |
187 | ||
188 | }⏎ |
50 | 50 | * Utitlity class for loading wavefiles. |
51 | 51 | * |
52 | 52 | * @author Brian Matzon <brian@matzon.dk> |
53 | * @version $Revision: 3274 $ | |
54 | * $Id: WaveData.java 3274 2010-02-20 10:43:22Z matzon $ | |
53 | * @version $Revision: 3336 $ | |
54 | * $Id: WaveData.java 3336 2010-04-26 21:52:59Z matzon $ | |
55 | 55 | */ |
56 | 56 | public class WaveData { |
57 | 57 | /** actual wave data */ |
107 | 107 | * @return WaveData containing data, or null if a failure occured |
108 | 108 | */ |
109 | 109 | public static WaveData create(String path) { |
110 | return create(WaveData.class.getClassLoader().getResource(path)); | |
110 | return create(Thread.currentThread().getContextClassLoader().getResource(path)); | |
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
38 | 38 | import java.awt.Graphics; |
39 | 39 | import java.awt.Image; |
40 | 40 | import java.awt.MediaTracker; |
41 | import java.awt.image.ImageObserver; | |
41 | 42 | import java.io.DataInputStream; |
42 | 43 | import java.io.DataOutputStream; |
43 | 44 | import java.io.File; |
46 | 47 | import java.io.FilePermission; |
47 | 48 | import java.io.IOException; |
48 | 49 | import java.io.InputStream; |
50 | import java.io.ObjectInputStream; | |
51 | import java.io.ObjectOutputStream; | |
49 | 52 | import java.io.OutputStream; |
50 | 53 | import java.io.PrintWriter; |
51 | 54 | import java.io.StringWriter; |
67 | 70 | import java.security.SecureClassLoader; |
68 | 71 | import java.security.cert.Certificate; |
69 | 72 | import java.util.Enumeration; |
73 | import java.util.HashMap; | |
70 | 74 | import java.util.StringTokenizer; |
71 | 75 | import java.util.Vector; |
72 | 76 | import java.util.jar.JarEntry; |
105 | 109 | * <ul> |
106 | 110 | * <li>al_version - [int or float] Version of deployment. If this is specified, the jars will be cached and |
107 | 111 | * reused if the version matches. If version doesn't match all of the files are reloaded.</li> |
108 | * <li>al_bgcolor - [String] Hex formated color to use as background. <i>Default: ffffff</i>.</li> | |
109 | * <li>al_fgcolor - [String] Hex formated color to use as foreground. <i>Default: 000000</i>.</li> | |
110 | * <li>al_errorcolor - [String] Hex formated color to use as foreground color on error. <i>Default: ff0000</i>.</li> | |
112 | * <li>al_cache - [boolean] Whether to use cache system. <i>Default: true</i>.</li> | |
111 | 113 | * <li>al_debug - [boolean] Whether to enable debug mode. <i>Default: false</i>.</li> |
112 | 114 | * <li>al_prepend_host - [boolean] Whether to limit caching to this domain, disable if your applet is hosted on multple domains and needs to share the cache. <i>Default: true</i>.</li> |
115 | * <ul> | |
116 | * <li>al_windows64 - [String] If specified it will be used instead of al_windows on 64bit windows systems.</li> | |
117 | * <li>al_windows32 - [String] If specifed it will be used instead of al_windows on 32bit windows systems.</li> | |
118 | * <li>al_linux64 - [String] If specifed it will be used instead of al_linux on 64bit linux systems.</li> | |
119 | * <li>al_linux32 - [String] If specifed it will be used instead of al_linux on 32bit linux systems.</li> | |
120 | * <ul> | |
121 | * <li>boxbgcolor - [String] any String AWT color ("red", "blue", etc), RGB (0-255) or hex formated color (#RRGGBB) to use as background. <i>Default: #ffffff</i>.</li> | |
122 | * <li>boxfgcolor - [String] any String AWT color ("red", "blue", etc), RGB (0-255) or hex formated color (#RRGGBB) to use as foreground. <i>Default: #000000</i>.</li> | |
113 | 123 | * </ul> |
114 | 124 | * </p> |
115 | 125 | * @author kappaOne |
165 | 175 | protected int totalSizeExtract; |
166 | 176 | |
167 | 177 | /** logo to be shown while loading */ |
168 | protected Image logo; | |
178 | protected Image logo, logoBuffer; | |
169 | 179 | |
170 | 180 | /** progressbar to render while loading */ |
171 | protected Image progressbar; | |
181 | protected Image progressbar, progressbarBuffer; | |
172 | 182 | |
173 | 183 | /** offscreen image used */ |
174 | 184 | protected Image offscreen; |
175 | 185 | |
186 | /** set to true while painting is done */ | |
187 | protected boolean painting; | |
188 | ||
176 | 189 | /** background color of applet */ |
177 | 190 | protected Color bgColor = Color.white; |
178 | ||
179 | /** Color to write errors in */ | |
180 | protected Color errorColor = Color.red; | |
181 | 191 | |
182 | 192 | /** color to write foreground in */ |
183 | 193 | protected Color fgColor = Color.black; |
208 | 218 | |
209 | 219 | /** whether to prepend host to cache path */ |
210 | 220 | protected boolean prependHost; |
221 | ||
222 | /** Used to store file names with lastModified time */ | |
223 | protected HashMap filesLastModified; | |
224 | ||
225 | /** Sizes of files to download */ | |
226 | protected int[] fileSizes; | |
227 | ||
228 | /** whether to use caching system, only download files that have changed */ | |
229 | protected boolean cacheEnabled; | |
211 | 230 | |
212 | 231 | /** String to display as a subtask */ |
213 | 232 | protected String subtaskMessage = ""; |
251 | 270 | return; |
252 | 271 | } |
253 | 272 | } |
254 | ||
273 | ||
274 | // whether to use cache system | |
275 | cacheEnabled = getBooleanParameter("al_cache", true); | |
276 | ||
255 | 277 | // whether to run in debug mode |
256 | 278 | debugMode = getBooleanParameter("al_debug", false); |
257 | 279 | |
259 | 281 | prependHost = getBooleanParameter("al_prepend_host", true); |
260 | 282 | |
261 | 283 | // get colors of applet |
262 | bgColor = getColor("al_bgcolor", Color.white); | |
284 | bgColor = getColor("boxbgcolor", Color.white); | |
263 | 285 | setBackground(bgColor); |
264 | ||
265 | fgColor = getColor("al_fgcolor", Color.black); | |
266 | errorColor = getColor("al_errorcolor", Color.red); | |
286 | fgColor = getColor("boxfgcolor", Color.black); | |
267 | 287 | |
268 | 288 | // load logos |
269 | 289 | logo = getImage(getParameter("al_logo")); |
338 | 358 | if (lwjglApplet != null) { |
339 | 359 | lwjglApplet.stop(); |
340 | 360 | } |
341 | super.stop(); | |
342 | 361 | } |
343 | 362 | |
344 | 363 | /* |
352 | 371 | progressbar = null; |
353 | 372 | logo = null; |
354 | 373 | |
355 | super.destroy(); | |
374 | logoBuffer = null; | |
375 | progressbarBuffer = null; | |
356 | 376 | } |
357 | 377 | |
358 | 378 | /** |
389 | 409 | // create offscreen if missing |
390 | 410 | if (offscreen == null) { |
391 | 411 | offscreen = createImage(getWidth(), getHeight()); |
412 | ||
413 | // create buffers for animated gifs | |
414 | logoBuffer = createImage(logo.getWidth(null), logo.getHeight(null)); | |
415 | progressbarBuffer = createImage(logo.getWidth(null), logo.getHeight(null)); | |
416 | ||
417 | // add image observer, it will notify when next animated gif frame is ready | |
418 | offscreen.getGraphics().drawImage(logo, 0, 0, this); | |
419 | offscreen.getGraphics().drawImage(progressbar, 0, 0, this); | |
420 | ||
421 | // in case image is not animated fill image buffers once | |
422 | imageUpdate(logo, ImageObserver.FRAMEBITS, 0, 0, 0, 0); | |
423 | imageUpdate(progressbar, ImageObserver.FRAMEBITS, 0, 0, 0, 0); | |
392 | 424 | } |
393 | 425 | |
394 | 426 | // draw everything onto an image before drawing to avoid flicker |
395 | 427 | Graphics og = offscreen.getGraphics(); |
396 | 428 | FontMetrics fm = og.getFontMetrics(); |
397 | 429 | |
398 | // set background color | |
430 | // clear background color | |
399 | 431 | og.setColor(bgColor); |
400 | og.fillRect(0, 0, getWidth(), getHeight()); | |
432 | og.fillRect(0, 0, offscreen.getWidth(null), offscreen.getHeight(null)); | |
401 | 433 | |
402 | 434 | // get logo position so its in the middle of applet |
403 | 435 | int x = 0, y = 0; |
404 | 436 | |
405 | 437 | if(logo != null && !fatalError) { |
406 | x = (getWidth() - logo.getWidth(this)) / 2; | |
407 | y = (getHeight() - logo.getHeight(this)) / 2; | |
438 | x = (offscreen.getWidth(null) - logo.getWidth(null)) / 2; | |
439 | y = (offscreen.getHeight(null) - logo.getHeight(null)) / 2; | |
408 | 440 | } |
409 | 441 | |
410 | 442 | og.setColor(fgColor); |
420 | 452 | |
421 | 453 | for(int i=0; i<errorMessage.length; i++) { |
422 | 454 | if(errorMessage[i] != null) { |
423 | int messageX = (getWidth() - fm.stringWidth(errorMessage[i])) / 2; | |
424 | int messageY = (getHeight() - (fm.getHeight() * errorMessage.length)) / 2; | |
455 | int messageX = (offscreen.getWidth(null) - fm.stringWidth(errorMessage[i])) / 2; | |
456 | int messageY = (offscreen.getHeight(null) - (fm.getHeight() * errorMessage.length)) / 2; | |
425 | 457 | |
426 | og.setColor(errorColor); | |
427 | 458 | og.drawString(errorMessage[i], messageX, messageY + i*fm.getHeight()); |
428 | 459 | } |
429 | 460 | } |
430 | 461 | } else { |
431 | 462 | og.setColor(fgColor); |
432 | ||
463 | ||
464 | painting = true; | |
465 | ||
433 | 466 | // draw logo |
434 | og.drawImage(logo, x, y, null); | |
467 | og.drawImage(logoBuffer, x, y, this); | |
435 | 468 | |
436 | 469 | // draw message |
437 | int messageX = (getWidth() - fm.stringWidth(message)) / 2; | |
438 | int messageY = y + logo.getHeight(null) + 20; | |
470 | int messageX = (offscreen.getWidth(null) - fm.stringWidth(message)) / 2; | |
471 | int messageY = y + logoBuffer.getHeight(null) + 20; | |
439 | 472 | og.drawString(message, messageX, messageY); |
440 | 473 | |
441 | 474 | // draw subtaskmessage, if any |
442 | 475 | if(subtaskMessage.length() > 0) { |
443 | messageX = (getWidth() - fm.stringWidth(subtaskMessage)) / 2; | |
476 | messageX = (offscreen.getWidth(null) - fm.stringWidth(subtaskMessage)) / 2; | |
444 | 477 | og.drawString(subtaskMessage, messageX, messageY+20); |
445 | 478 | } |
446 | 479 | |
447 | 480 | // draw loading bar, clipping it depending on percentage done |
448 | int barSize = (progressbar.getWidth(this) * percentage) / 100; | |
449 | og.clipRect(0, 0, x + barSize, getHeight()); | |
450 | og.drawImage(progressbar, x, y, null); | |
481 | int barSize = (progressbarBuffer.getWidth(null) * percentage) / 100; | |
482 | og.clipRect(0, 0, x + barSize, offscreen.getHeight(null)); | |
483 | og.drawImage(progressbarBuffer, x, y, this); | |
484 | ||
485 | painting = false; | |
451 | 486 | } |
452 | 487 | |
453 | 488 | og.dispose(); |
454 | ||
455 | // finally draw it all | |
456 | g.drawImage(offscreen, 0, 0, null); | |
457 | } | |
489 | ||
490 | // finally draw it all centred | |
491 | g.drawImage(offscreen, (getWidth() - offscreen.getWidth(null))/2, (getHeight() - offscreen.getHeight(null))/2, null); | |
492 | } | |
493 | ||
494 | /** | |
495 | * When an animated gif frame is ready to be drawn the ImageObserver | |
496 | * will call this method. | |
497 | * | |
498 | * The Image frame is copied into a buffer, which is then drawn. | |
499 | * This is done to prevent image tearing on gif animations. | |
500 | */ | |
501 | public boolean imageUpdate(Image img, int flag, int x, int y, int width, int height) { | |
502 | ||
503 | // if image frame is ready to be drawn and is currently not being painted | |
504 | if (flag == ImageObserver.FRAMEBITS && !painting) { | |
505 | Image buffer; | |
506 | ||
507 | // select which buffer to fill | |
508 | if (img == logo) buffer = logoBuffer; | |
509 | else buffer = progressbarBuffer; | |
510 | ||
511 | Graphics g = buffer.getGraphics(); | |
512 | ||
513 | // clear background on buffer | |
514 | g.setColor(bgColor); | |
515 | g.fillRect(0, 0, buffer.getWidth(null), buffer.getHeight(null)); | |
516 | ||
517 | // buffer background is cleared, so draw logo under progressbar | |
518 | if (img == progressbar) g.drawImage(logoBuffer, 0, 0, null); | |
519 | ||
520 | g.drawImage(img, 0, 0, this); | |
521 | g.dispose(); | |
522 | ||
523 | repaint(); | |
524 | } | |
525 | ||
526 | return true; | |
527 | } | |
458 | 528 | |
459 | 529 | /** |
460 | 530 | * @return string describing the state of the loader |
466 | 536 | case STATE_DETERMINING_PACKAGES: |
467 | 537 | return "Determining packages to load"; |
468 | 538 | case STATE_CHECKING_CACHE: |
469 | return "Checking cache for existing files"; | |
539 | return "Calculating download size"; | |
470 | 540 | case STATE_DOWNLOADING: |
471 | 541 | return "Downloading packages"; |
472 | 542 | case STATE_EXTRACTING_PACKAGES: |
533 | 603 | String nativeJar = null; |
534 | 604 | |
535 | 605 | if (osName.startsWith("Win")) { |
536 | nativeJar = getParameter("al_windows"); | |
606 | ||
607 | // check if arch specific natives have been specified | |
608 | if (System.getProperty("os.arch").endsWith("64")) { | |
609 | nativeJar = getParameter("al_windows64"); | |
610 | } else { | |
611 | nativeJar = getParameter("al_windows32"); | |
612 | } | |
613 | ||
614 | if (nativeJar == null) { | |
615 | nativeJar = getParameter("al_windows"); | |
616 | } | |
617 | ||
537 | 618 | } else if (osName.startsWith("Linux")) { |
538 | nativeJar = getParameter("al_linux"); | |
619 | ||
620 | // check if arch specific natives have been specified | |
621 | if (System.getProperty("os.arch").endsWith("64")) { | |
622 | nativeJar = getParameter("al_linux64"); | |
623 | } else { | |
624 | nativeJar = getParameter("al_linux32"); | |
625 | } | |
626 | ||
627 | if (nativeJar == null) { | |
628 | nativeJar = getParameter("al_linux"); | |
629 | } | |
630 | ||
539 | 631 | } else if (osName.startsWith("Mac")) { |
540 | 632 | nativeJar = getParameter("al_mac"); |
541 | 633 | } else if (osName.startsWith("Solaris") || osName.startsWith("SunOS")) { |
597 | 689 | if (!dir.exists()) { |
598 | 690 | dir.mkdirs(); |
599 | 691 | } |
600 | dir = new File(dir, "version"); | |
601 | ||
602 | // if applet already available don't download anything | |
603 | boolean cacheAvailable = false; | |
692 | ||
693 | File versionFile = new File(dir, "version"); | |
694 | ||
695 | // if specified applet version already available don't download anything | |
696 | boolean versionAvailable = false; | |
604 | 697 | |
605 | 698 | // version of applet |
606 | 699 | String version = getParameter("al_version"); |
612 | 705 | latestVersion = Float.parseFloat(version); |
613 | 706 | |
614 | 707 | // if version file exists |
615 | if (dir.exists()) { | |
708 | if (versionFile.exists()) { | |
616 | 709 | // compare to new version |
617 | if (latestVersion <= readVersionFile(dir)) { | |
618 | cacheAvailable = true; | |
710 | if (latestVersion <= readVersionFile(versionFile)) { | |
711 | versionAvailable = true; | |
619 | 712 | percentage = 90; |
620 | 713 | |
621 | 714 | if(debugMode) { |
627 | 720 | } |
628 | 721 | |
629 | 722 | // if jars not available or need updating download them |
630 | if (!cacheAvailable) { | |
723 | if (!versionAvailable) { | |
724 | // get jars file sizes and check cache | |
725 | getJarInfo(dir); // 5-15% | |
726 | ||
631 | 727 | // downloads jars from the server |
632 | downloadJars(path); // 10-55% | |
728 | downloadJars(path); // 15-55% | |
633 | 729 | |
634 | 730 | // Extract Pack and LZMA files |
635 | 731 | extractJars(path); // 55-65% |
637 | 733 | // Extracts Native Files |
638 | 734 | extractNatives(path); // 65-85% |
639 | 735 | |
640 | // add version information once jars downloaded successfully | |
736 | // save version information once jars downloaded successfully | |
641 | 737 | if (version != null) { |
642 | 738 | percentage = 90; |
643 | 739 | writeVersionFile(dir, latestVersion); |
644 | 740 | } |
741 | ||
742 | // save file names with last modified info once downloaded successfully | |
743 | writeCacheFile(new File(dir, "cache"), filesLastModified); | |
645 | 744 | } |
646 | 745 | |
647 | 746 | // add the downloaded jars and natives to classpath |
685 | 784 | protected void writeVersionFile(File file, float version) throws Exception { |
686 | 785 | DataOutputStream dos = new DataOutputStream(new FileOutputStream(file)); |
687 | 786 | dos.writeFloat(version); |
787 | dos.close(); | |
788 | } | |
789 | ||
790 | /** | |
791 | * read the current cache file | |
792 | * | |
793 | * @param file the file to read | |
794 | * @return the hashmap containing the files names and lastModified times | |
795 | * @throws Exception if it fails to read hashmap | |
796 | */ | |
797 | protected HashMap readCacheFile(File file) throws Exception { | |
798 | ObjectInputStream dis = new ObjectInputStream(new FileInputStream(file)); | |
799 | HashMap hashMap = (HashMap)dis.readObject(); | |
800 | dis.close(); | |
801 | return hashMap; | |
802 | } | |
803 | ||
804 | /** | |
805 | * write out cache file of applet | |
806 | * | |
807 | * @param file the file to write out to | |
808 | * @param filesLastModified the hashmap containing files names and lastModified times | |
809 | * @throws Exception if it fails to write file | |
810 | */ | |
811 | protected void writeCacheFile(File file, HashMap filesLastModified) throws Exception { | |
812 | ObjectOutputStream dos = new ObjectOutputStream(new FileOutputStream(file)); | |
813 | dos.writeObject(filesLastModified); | |
688 | 814 | dos.close(); |
689 | 815 | } |
690 | 816 | |
764 | 890 | * Due to the way applets on plugin1 work, one jvm must |
765 | 891 | * be used for all applets. We need to use multiple |
766 | 892 | * classloaders in the same jvm due to LWJGL's static |
767 | * nature. I order to solver this we simply remove the | |
893 | * nature. I order to solve this we simply remove the | |
768 | 894 | * natives from a previous classloader allowing a new |
769 | 895 | * classloader to use those natives in the same jvm. |
770 | 896 | * |
829 | 955 | state = STATE_START_REAL_APPLET; |
830 | 956 | lwjglApplet.start(); |
831 | 957 | } |
832 | ||
833 | /** | |
834 | * Will download the jars from the server using the list of urls | |
835 | * in urlList, while at the same time updating progress bar | |
836 | * | |
837 | * @param path location of the directory to save to | |
838 | * @throws Exception if download fails | |
839 | */ | |
840 | protected void downloadJars(String path) throws Exception { | |
841 | ||
842 | state = STATE_DOWNLOADING; | |
843 | ||
958 | ||
959 | /** | |
960 | * This method will get the files sizes of the files to download. | |
961 | * It wil further get the lastModified time of files | |
962 | * and save it in a hashmap, if cache is enabled it will mark | |
963 | * those files that have not changed since last download to not | |
964 | * redownloaded. | |
965 | * | |
966 | * @param dir - location to read cache file from | |
967 | * @throws Exception - if fails to get infomation | |
968 | */ | |
969 | protected void getJarInfo(File dir) throws Exception { | |
970 | ||
971 | filesLastModified = new HashMap(); | |
972 | ||
973 | // store file sizes and mark which files not to download | |
974 | fileSizes = new int[urlList.length]; | |
975 | ||
844 | 976 | URLConnection urlconnection; |
845 | 977 | |
846 | // store file sizes, used for download verification | |
847 | int[] fileSizes = new int[urlList.length]; | |
978 | File cacheFile = new File(dir, "cache"); | |
979 | ||
980 | // if cache file exists, load it | |
981 | if (cacheFile.exists()) { | |
982 | filesLastModified = readCacheFile(cacheFile); | |
983 | } | |
848 | 984 | |
849 | 985 | // calculate total size of jars to download |
850 | 986 | for (int i = 0; i < urlList.length; i++) { |
853 | 989 | if (urlconnection instanceof HttpURLConnection) { |
854 | 990 | ((HttpURLConnection) urlconnection).setRequestMethod("HEAD"); |
855 | 991 | } |
992 | ||
856 | 993 | fileSizes[i] = urlconnection.getContentLength(); |
857 | totalSizeDownload += fileSizes[i]; | |
858 | } | |
859 | ||
860 | int initialPercentage = percentage = 10; | |
994 | ||
995 | long lastModified = urlconnection.getLastModified(); | |
996 | String fileName = getFileName(urlList[i]); | |
997 | ||
998 | ||
999 | if (cacheEnabled && lastModified != 0 && | |
1000 | filesLastModified.containsKey(fileName)) { | |
1001 | long savedLastModified = ((Long)filesLastModified.get(fileName)).longValue(); | |
1002 | ||
1003 | // if lastModifed time is the same, don't redownload | |
1004 | if (savedLastModified == lastModified) { | |
1005 | fileSizes[i] = -2; // mark it to not redownload | |
1006 | } | |
1007 | } | |
1008 | ||
1009 | if (fileSizes[i] >= 0) { | |
1010 | totalSizeDownload += fileSizes[i]; | |
1011 | } | |
1012 | ||
1013 | // put key and value in the hashmap | |
1014 | filesLastModified.put(fileName, new Long(lastModified)); | |
1015 | ||
1016 | // update progress bar | |
1017 | percentage = 5 + (int)(10 * i/(float)urlList.length); | |
1018 | } | |
1019 | } | |
1020 | ||
1021 | /** | |
1022 | * Will download the jars from the server using the list of urls | |
1023 | * in urlList, while at the same time updating progress bar | |
1024 | * | |
1025 | * @param path location of the directory to save to | |
1026 | * @throws Exception if download fails | |
1027 | */ | |
1028 | protected void downloadJars(String path) throws Exception { | |
1029 | ||
1030 | state = STATE_DOWNLOADING; | |
1031 | ||
1032 | URLConnection urlconnection; | |
1033 | ||
1034 | int initialPercentage = percentage = 15; | |
861 | 1035 | |
862 | 1036 | // download each jar |
863 | 1037 | byte buffer[] = new byte[65536]; |
864 | 1038 | for (int i = 0; i < urlList.length; i++) { |
1039 | ||
1040 | // skip file if marked as -2 (already downloaded and not changed) | |
1041 | if (fileSizes[i] == -2) continue; | |
865 | 1042 | |
866 | 1043 | int unsuccessfulAttempts = 0; |
867 | 1044 | int maxUnsuccessfulAttempts = 3; |
908 | 1085 | // round to two decimal places |
909 | 1086 | downloadSpeed = ((int)(downloadSpeed*100))/100f; |
910 | 1087 | // set current speed message |
911 | downloadSpeedMessage = " @ " + downloadSpeed + " KB/sec"; | |
1088 | downloadSpeedMessage = " - " + downloadSpeed + " KB/sec"; | |
912 | 1089 | // reset downloaded amount |
913 | 1090 | downloadedAmount = 0; |
914 | 1091 | // reset start time |
1066 | 1243 | float increment = (float) 10.0 / urlList.length; |
1067 | 1244 | // extract all lzma and pack.lzma files |
1068 | 1245 | for (int i = 0; i < urlList.length; i++) { |
1246 | ||
1247 | // if file has not changed, skip it | |
1248 | if (fileSizes[i] == -2) continue; | |
1249 | ||
1069 | 1250 | percentage = 55 + (int) (increment * (i+1)); |
1070 | 1251 | String filename = getFileName(urlList[i]); |
1071 | 1252 | |
1101 | 1282 | */ |
1102 | 1283 | protected void extractNatives(String path) throws Exception { |
1103 | 1284 | |
1285 | // if no new native jar was downloaded, no extracting needed | |
1286 | if (fileSizes[fileSizes.length-1] == -2) { | |
1287 | return; | |
1288 | } | |
1289 | ||
1104 | 1290 | state = STATE_EXTRACTING_PACKAGES; |
1105 | 1291 | |
1106 | 1292 | int initialPercentage = percentage; |
1292 | 1478 | * @param defaultColor Default color to use if no color to load |
1293 | 1479 | * @return Color to use |
1294 | 1480 | */ |
1295 | protected Color getColor(String color, Color defaultColor) { | |
1296 | String param_color = getParameter(color); | |
1297 | if (param_color != null) { | |
1298 | return new Color(Integer.parseInt(param_color, 16)); | |
1299 | } | |
1300 | return defaultColor; | |
1481 | protected Color getColor(String param, Color defaultColor) { | |
1482 | String color = getParameter(param); | |
1483 | ||
1484 | if (color == null) return defaultColor; | |
1485 | ||
1486 | // Check if RGB format | |
1487 | if (color.indexOf(",") != -1) { | |
1488 | StringTokenizer st = new StringTokenizer(color, ","); | |
1489 | ||
1490 | // We've got three components for the color | |
1491 | try { | |
1492 | return new Color(Integer.parseInt(st.nextToken().trim()), | |
1493 | Integer.parseInt(st.nextToken().trim()), | |
1494 | Integer.parseInt(st.nextToken().trim())); | |
1495 | } catch (Exception e) { | |
1496 | // failed to parse | |
1497 | return defaultColor; | |
1498 | } | |
1499 | } | |
1500 | ||
1501 | // Check & decode if the color is in hexadecimal color format (i.e. #808000) | |
1502 | try { | |
1503 | return Color.decode(color); | |
1504 | } catch (NumberFormatException e) { | |
1505 | // ignore exception | |
1506 | } | |
1507 | ||
1508 | // Get the color by name if it exists | |
1509 | try { | |
1510 | return (Color)Color.class.getField(color).get(null); | |
1511 | } catch (Exception e) { | |
1512 | return defaultColor; | |
1513 | } | |
1301 | 1514 | } |
1302 | 1515 | |
1303 | 1516 | /** |
1321 | 1534 | */ |
1322 | 1535 | protected void fatalErrorOccured(String error, Exception e) { |
1323 | 1536 | fatalError = true; |
1324 | fatalErrorDescription = "Fatal error occured (" + state + "): " + error; | |
1537 | fatalErrorDescription = "This occurred while '" + getDescriptionForState() + "'"; | |
1325 | 1538 | System.out.println(fatalErrorDescription); |
1326 | 1539 | if(e != null) { |
1327 | 1540 | System.out.println(generateStacktrace(e)); |
0 | /* | |
1 | * Copyright (c) 2002-2008 LWJGL Project | |
2 | * All rights reserved. | |
3 | * | |
4 | * Redistribution and use in source and binary forms, with or without | |
5 | * modification, are permitted provided that the following conditions are | |
6 | * met: | |
7 | * | |
8 | * * Redistributions of source code must retain the above copyright | |
9 | * notice, this list of conditions and the following disclaimer. | |
10 | * | |
11 | * * Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | |
14 | * | |
15 | * * Neither the name of 'LWJGL' nor the names of | |
16 | * its contributors may be used to endorse or promote products derived | |
17 | * from this software without specific prior written permission. | |
18 | * | |
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | |
23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
24 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
25 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
26 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | |
27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | |
31 | package org.lwjgl.util.generator; | |
32 | ||
33 | /** | |
34 | * This annotation can be used for extensions that have aliases | |
35 | * with the exact same functionality. | |
36 | * <p/> | |
37 | * This is currently only implemented for context-specific functionality. | |
38 | * | |
39 | * @author Spasi <spasi@users.sourceforge.net> | |
40 | */ | |
41 | import java.lang.annotation.ElementType; | |
42 | import java.lang.annotation.Target; | |
43 | ||
44 | @Target(ElementType.TYPE) | |
45 | public @interface Alias { | |
46 | ||
47 | /** The aliased extension name. */ | |
48 | String value(); | |
49 | ||
50 | /** The function name postfix for the aliased version. (optional) */ | |
51 | String postfix() default ""; | |
52 | ||
53 | }⏎ |
36 | 36 | * according to the remaining() of a Buffer parameter. |
37 | 37 | * |
38 | 38 | * @author elias_naur <elias_naur@users.sourceforge.net> |
39 | * @version $Revision: 2983 $ | |
40 | * $Id: AutoSize.java 2983 2008-04-07 18:36:09Z matzon $ | |
39 | * @version $Revision: 3355 $ | |
40 | * $Id: AutoSize.java 3355 2010-05-27 22:56:29Z spasi $ | |
41 | 41 | */ |
42 | 42 | |
43 | 43 | import java.lang.annotation.Target; |
48 | 48 | public @interface AutoSize { |
49 | 49 | String value(); // The name of the Buffer parameter |
50 | 50 | String expression() default ""; // This value is added after the argument |
51 | boolean canBeNull() default false; // When this is true and the Buffer parameter is null, 0 will be used. | |
51 | 52 | } |
45 | 45 | * Generator visitor for the context capabilities generator tool |
46 | 46 | * |
47 | 47 | * @author elias_naur <elias_naur@users.sourceforge.net> |
48 | * @version $Revision: 3316 $ | |
49 | * $Id: ContextCapabilitiesGenerator.java 3316 2010-04-09 23:57:40Z spasi $ | |
48 | * @version $Revision: 3355 $ | |
49 | * $Id: ContextCapabilitiesGenerator.java 3355 2010-05-27 22:56:29Z spasi $ | |
50 | 50 | */ |
51 | 51 | public class ContextCapabilitiesGenerator { |
52 | 52 | |
53 | private final static String STUBS_LOADED_NAME = "loaded_stubs"; | |
54 | private final static String ALL_INIT_METHOD_NAME = "initAllStubs"; | |
55 | private final static String POINTER_INITIALIZER_POSTFIX = "_initNativeFunctionAddresses"; | |
56 | private final static String CACHED_EXTS_VAR_NAME = "supported_extensions"; | |
57 | private final static String PROFILE_MASK_VAR_NAME = "profileMask"; | |
58 | private final static String EXTENSION_PREFIX = "GL_"; | |
59 | private final static String CORE_PREFIX = "Open"; | |
53 | private static final String STUBS_LOADED_NAME = "loaded_stubs"; | |
54 | private static final String ALL_INIT_METHOD_NAME = "initAllStubs"; | |
55 | private static final String POINTER_INITIALIZER_POSTFIX = "_initNativeFunctionAddresses"; | |
56 | private static final String CACHED_EXTS_VAR_NAME = "supported_extensions"; | |
57 | private static final String PROFILE_MASK_VAR_NAME = "profileMask"; | |
58 | private static final String EXTENSION_PREFIX = "GL_"; | |
59 | private static final String CORE_PREFIX = "Open"; | |
60 | 60 | |
61 | 61 | public static void generateClassPrologue(PrintWriter writer, boolean context_specific, boolean generate_error_checks) { |
62 | 62 | writer.println("public class " + Utils.CONTEXT_CAPS_CLASS_NAME + " {"); |
63 | 63 | writer.println("\tstatic final boolean DEBUG = " + Boolean.toString(generate_error_checks) + ";"); |
64 | 64 | writer.println("\tfinal StateTracker tracker = new StateTracker();"); |
65 | writer.println("\tfinal IntBuffer scratch_int_buffer = BufferUtils.createIntBuffer(16);"); | |
66 | 65 | writer.println(); |
67 | 66 | if ( !context_specific ) { |
68 | 67 | writer.println("\tprivate static boolean " + STUBS_LOADED_NAME + " = false;"); |
108 | 107 | writer.print("\t\t\t&& " + CACHED_EXTS_VAR_NAME + ".contains(\""); |
109 | 108 | writer.print(translateFieldName(super_interface.getDeclaration().getSimpleName()) + "\")"); |
110 | 109 | } |
110 | Alias alias_annotation = d.getAnnotation(Alias.class); | |
111 | if ( alias_annotation != null ) { | |
112 | writer.println(); | |
113 | writer.print("\t\t\t|| " + CACHED_EXTS_VAR_NAME + ".contains(\""); | |
114 | writer.print(translateFieldName(alias_annotation.value()) + "\")"); | |
115 | } | |
111 | 116 | writer.println(";"); |
112 | 117 | } |
113 | 118 | |
164 | 169 | public static void generateInitStubs(PrintWriter writer, InterfaceDeclaration d, boolean context_specific) { |
165 | 170 | if ( d.getMethods().size() > 0 ) { |
166 | 171 | if ( context_specific ) { |
172 | final Alias alias_annotation = d.getAnnotation(Alias.class); | |
173 | ||
167 | 174 | if ( d.getAnnotation(ForceInit.class) != null ) |
168 | 175 | writer.println("\t\t" + CACHED_EXTS_VAR_NAME + ".add(\"" + translateFieldName(d.getSimpleName()) + "\");"); |
169 | writer.print("\t\tif (" + CACHED_EXTS_VAR_NAME + ".contains(\""); | |
176 | writer.print("\t\tif ("); | |
177 | if ( alias_annotation != null ) | |
178 | writer.print("("); | |
179 | writer.print(CACHED_EXTS_VAR_NAME + ".contains(\""); | |
170 | 180 | writer.print(translateFieldName(d.getSimpleName()) + "\")"); |
181 | if ( alias_annotation != null ) { | |
182 | writer.print(" || " + CACHED_EXTS_VAR_NAME + ".contains(\""); | |
183 | writer.print(translateFieldName(alias_annotation.value()) + "\"))"); | |
184 | } | |
171 | 185 | writer.print(" && !" + getAddressesInitializerName(d.getSimpleName()) + "("); |
172 | 186 | if ( d.getAnnotation(DeprecatedGL.class) != null ) |
173 | 187 | writer.print("forwardCompatible"); |
176 | 190 | writer.print(","); |
177 | 191 | writer.print("supported_extensions"); |
178 | 192 | } |
179 | writer.println("))"); | |
180 | //writer.print("\t\t\t" + CACHED_EXTS_VAR_NAME + ".remove(\""); | |
193 | if ( alias_annotation != null ) { | |
194 | writer.println(")) {"); | |
195 | writer.print("\t\t\tremove(" + CACHED_EXTS_VAR_NAME + ", \""); | |
196 | writer.println(translateFieldName(alias_annotation.value()) + "\");"); | |
197 | } else | |
198 | writer.println("))"); | |
181 | 199 | writer.print("\t\t\tremove(" + CACHED_EXTS_VAR_NAME + ", \""); |
182 | 200 | writer.println(translateFieldName(d.getSimpleName()) + "\");"); |
201 | if ( alias_annotation != null ) | |
202 | writer.println("\t\t}"); | |
183 | 203 | } else { |
184 | 204 | writer.print("\t\tGLContext." + Utils.STUB_INITIALIZER_NAME + "(" + Utils.getSimpleClassName(d)); |
185 | 205 | writer.println(".class, " + CACHED_EXTS_VAR_NAME + ", \"" + translateFieldName(d.getSimpleName()) + "\");"); |
209 | 229 | writer.print(","); |
210 | 230 | writer.print("Set supported_extensions"); |
211 | 231 | } |
232 | ||
233 | Alias alias_annotation = d.getAnnotation(Alias.class); | |
234 | boolean aliased = alias_annotation != null && alias_annotation.postfix().length() > 0; | |
212 | 235 | |
213 | 236 | writer.println(") {"); |
214 | 237 | writer.println("\t\treturn "); |
266 | 289 | writer.print(", "); |
267 | 290 | } |
268 | 291 | writer.print("}, "); |
292 | } else if ( aliased ) { | |
293 | writer.print("GLContext.getFunctionAddress(new String[] {\"" + method.getSimpleName() + "\",\"" + method.getSimpleName() + alias_annotation.postfix() + "\"})) != 0"); | |
269 | 294 | } else |
270 | 295 | writer.print("GLContext.getFunctionAddress("); |
271 | writer.print("\"" + method.getSimpleName() + "\")) != 0"); | |
296 | if ( !aliased ) | |
297 | writer.print("\"" + method.getSimpleName() + "\")) != 0"); | |
272 | 298 | if ( deprecated || dependent != null ) |
273 | 299 | writer.print(')'); |
274 | 300 | if ( optional ) |
31 | 31 | |
32 | 32 | package org.lwjgl.util.generator; |
33 | 33 | |
34 | import com.sun.mirror.declaration.*; | |
35 | import com.sun.mirror.type.*; | |
34 | import java.io.PrintWriter; | |
35 | import java.util.Collection; | |
36 | 36 | |
37 | import java.io.*; | |
38 | import java.util.*; | |
37 | import com.sun.mirror.declaration.FieldDeclaration; | |
38 | import com.sun.mirror.declaration.Modifier; | |
39 | import com.sun.mirror.type.PrimitiveType; | |
40 | import com.sun.mirror.type.TypeMirror; | |
39 | 41 | |
40 | 42 | public class FieldsGenerator { |
43 | ||
41 | 44 | private static void validateField(FieldDeclaration field) { |
45 | // Check if field is "public static final" | |
42 | 46 | Collection<Modifier> modifiers = field.getModifiers(); |
43 | if (modifiers.size() != 3 || !modifiers.contains(Modifier.PUBLIC) || !modifiers.contains(Modifier.STATIC) || | |
44 | !modifiers.contains(Modifier.FINAL)) | |
47 | if ( modifiers.size() != 3 | |
48 | || !modifiers.contains(Modifier.PUBLIC) | |
49 | || !modifiers.contains(Modifier.STATIC) | |
50 | || !modifiers.contains(Modifier.FINAL) ) { | |
45 | 51 | throw new RuntimeException("Field " + field.getSimpleName() + " is not declared public static final"); |
52 | } | |
53 | ||
54 | // Check suported types (int, long, float, String) | |
46 | 55 | TypeMirror field_type = field.getType(); |
47 | if (!(field_type instanceof PrimitiveType)) | |
48 | throw new RuntimeException("Field " + field.getSimpleName() + " is not a primitive type"); | |
49 | PrimitiveType field_type_prim = (PrimitiveType)field_type; | |
50 | if (field_type_prim.getKind() != PrimitiveType.Kind.INT && field_type_prim.getKind() != PrimitiveType.Kind.LONG) | |
51 | throw new RuntimeException("Field " + field.getSimpleName() + " is not of type 'int' or 'long'"); | |
56 | if ( field_type instanceof PrimitiveType ) { | |
57 | PrimitiveType field_type_prim = (PrimitiveType)field_type; | |
58 | PrimitiveType.Kind field_kind = field_type_prim.getKind(); | |
59 | if ( field_kind != PrimitiveType.Kind.INT | |
60 | && field_kind != PrimitiveType.Kind.LONG | |
61 | && field_kind != PrimitiveType.Kind.FLOAT ) { | |
62 | throw new RuntimeException("Field " + field.getSimpleName() + " is not of type 'int', 'long' or 'float'"); | |
63 | } | |
64 | } else if ( "java.lang.String".equals(field_type.toString()) ) { | |
65 | } else { | |
66 | throw new RuntimeException("Field " + field.getSimpleName() + " is not a primitive type or String"); | |
67 | } | |
68 | ||
52 | 69 | Object field_value = field.getConstantValue(); |
53 | if (field_value == null) | |
70 | if ( field_value == null ) { | |
54 | 71 | throw new RuntimeException("Field " + field.getSimpleName() + " has no initial value"); |
72 | } | |
55 | 73 | } |
56 | 74 | |
57 | private static void generateField(PrintWriter writer, FieldDeclaration field) { | |
75 | private static void generateField(PrintWriter writer, FieldDeclaration field, FieldDeclaration prev_field) { | |
58 | 76 | validateField(field); |
59 | 77 | |
60 | 78 | Object value = field.getConstantValue(); |
61 | 79 | String field_value_string; |
62 | if ( value.getClass().equals(Integer.class) ) | |
63 | field_value_string = Integer.toHexString((Integer)field.getConstantValue()); | |
64 | else | |
65 | field_value_string = Long.toHexString((Long)field.getConstantValue()) + 'l'; | |
80 | Class field_value_class = value.getClass(); | |
81 | if ( field_value_class.equals(Integer.class) ) { | |
82 | field_value_string = "0x" + Integer.toHexString((Integer)field.getConstantValue()).toUpperCase(); | |
83 | } else if ( field_value_class.equals(Long.class) ) { | |
84 | field_value_string = "0x" + Long.toHexString((Long)field.getConstantValue()).toUpperCase() + 'L'; | |
85 | } else if ( field_value_class.equals(Float.class) ) { | |
86 | field_value_string = field.getConstantValue() + "f"; | |
87 | } else if ( field_value_class.equals(String.class) ) { | |
88 | field_value_string = "\"" + field.getConstantValue() + "\""; | |
89 | } else { | |
90 | throw new RuntimeException("Field is of unexpected type. This means there is a bug in validateField()."); | |
91 | } | |
66 | 92 | |
67 | Utils.printDocComment(writer, field); | |
93 | boolean hadDoc = prev_field != null && prev_field.getDocComment() != null; | |
94 | boolean hasDoc = field.getDocComment() != null; | |
95 | boolean newBatch = prev_field == null || !prev_field.getType().equals(field.getType()) || (!hadDoc && field.getDocComment() != null) || (hadDoc && hasDoc && !prev_field.getDocComment().equals(field.getDocComment())); | |
96 | ||
68 | 97 | // Print field declaration |
69 | writer.println("\tpublic static final " + field.getType().toString() + " " + field.getSimpleName() + " = 0x" + field_value_string + ";"); | |
98 | if ( newBatch ) { | |
99 | if ( prev_field != null ) | |
100 | writer.println(";\n"); | |
101 | ||
102 | Utils.printDocComment(writer, field); | |
103 | writer.print("\tpublic static final " + field.getType().toString() + " " + field.getSimpleName() + " = " + field_value_string); | |
104 | } else | |
105 | writer.print(",\n\t\t" + field.getSimpleName() + " = " + field_value_string); | |
70 | 106 | } |
71 | 107 | |
72 | 108 | public static void generateFields(PrintWriter writer, Collection<FieldDeclaration> fields) { |
73 | for (FieldDeclaration field : fields) | |
74 | generateField(writer, field); | |
109 | if ( 0 < fields.size() ) { | |
110 | writer.println(); | |
111 | FieldDeclaration prev_field = null; | |
112 | for ( FieldDeclaration field : fields ) { | |
113 | generateField(writer, field, prev_field); | |
114 | prev_field = field; | |
115 | } | |
116 | writer.println(";"); | |
117 | } | |
75 | 118 | } |
76 | 119 | |
77 | 120 | } |
39 | 39 | @Target({ElementType.PARAMETER, ElementType.METHOD}) |
40 | 40 | public @interface GLpointer { |
41 | 41 | String value(); // The native pointer type. |
42 | boolean canBeNull() default false; // Whether the pointer may be null. | |
42 | 43 | }⏎ |
49 | 49 | * Generator visitor for the generator tool |
50 | 50 | * |
51 | 51 | * @author elias_naur <elias_naur@users.sourceforge.net> |
52 | * @version $Revision: 3299 $ | |
53 | * $Id: GeneratorVisitor.java 3299 2010-03-31 15:46:16Z spasi $ | |
52 | * @version $Revision: 3355 $ | |
53 | * $Id: GeneratorVisitor.java 3355 2010-05-27 22:56:29Z spasi $ | |
54 | 54 | */ |
55 | 55 | public class GeneratorVisitor extends SimpleDeclarationVisitor { |
56 | 56 | private final AnnotationProcessorEnvironment env; |
179 | 179 | java_writer.println(); |
180 | 180 | java_writer.println("package " + d.getPackage().getQualifiedName() + ";"); |
181 | 181 | java_writer.println(); |
182 | java_writer.println("import org.lwjgl.LWJGLException;"); | |
183 | java_writer.println("import org.lwjgl.BufferChecks;"); | |
184 | // DISABLED: indirect buffer support | |
185 | //java_writer.println("import org.lwjgl.NondirectBufferWrapper;"); | |
182 | java_writer.println("import org.lwjgl.*;"); | |
186 | 183 | java_writer.println("import java.nio.*;"); |
187 | 184 | java_writer.println(); |
188 | 185 | Utils.printDocComment(java_writer, d); |
203 | 200 | java_writer.println(); |
204 | 201 | if (is_final) { |
205 | 202 | // Write private constructor to avoid instantiation |
206 | java_writer.println("\tprivate " + Utils.getSimpleClassName(d) + "() {"); | |
207 | java_writer.println("\t}"); | |
203 | java_writer.println("\tprivate " + Utils.getSimpleClassName(d) + "() {}"); | |
204 | } | |
205 | if (d.getMethods().size() > 0 && !context_specific) { | |
208 | 206 | java_writer.println(); |
209 | } | |
210 | if (d.getMethods().size() > 0 && !context_specific) | |
211 | 207 | java_writer.println("\tstatic native void " + Utils.STUB_INITIALIZER_NAME + "() throws LWJGLException;"); |
208 | } | |
212 | 209 | JavaMethodsGenerator.generateMethodsJava(env, type_map, java_writer, d, generate_error_checks, context_specific); |
213 | 210 | java_writer.println("}"); |
214 | 211 | java_writer.close(); |
36 | 36 | * This class generates the methods in the generated java source files. |
37 | 37 | * |
38 | 38 | * @author elias_naur <elias_naur@users.sourceforge.net> |
39 | * @version $Revision: 3293 $ | |
40 | * $Id: JavaMethodsGenerator.java 3293 2010-03-23 12:43:44Z spasi $ | |
39 | * @version $Revision: 3355 $ | |
40 | * $Id: JavaMethodsGenerator.java 3355 2010-05-27 22:56:29Z spasi $ | |
41 | 41 | */ |
42 | 42 | |
43 | 43 | import com.sun.mirror.apt.*; |
260 | 260 | // DISABLED: indirect buffer support |
261 | 261 | //printNondirectParameterCopies(writer, method, mode); |
262 | 262 | if (has_result) { |
263 | if ( method.getAnnotation(GLreturn.class) == null ) | |
264 | writer.println("\t\treturn " + Utils.RESULT_VAR_NAME + ";"); | |
265 | else | |
263 | if ( method.getAnnotation(GLreturn.class) == null ) { | |
264 | if ( ByteBuffer.class.equals(Utils.getJavaType(result_type)) ) | |
265 | writer.println("\t\treturn " + Utils.RESULT_VAR_NAME + ".order(ByteOrder.nativeOrder());"); // safeNewBuffer returns a direct ByteBuffer with BIG_ENDIAN order. | |
266 | else | |
267 | writer.println("\t\treturn " + Utils.RESULT_VAR_NAME + ";"); | |
268 | } else | |
266 | 269 | Utils.printGLReturnPost(writer, method, method.getAnnotation(GLreturn.class)); |
267 | 270 | } |
268 | 271 | writer.println("\t}"); |
383 | 386 | String auto_parameter_name = auto_type_annotation.value(); |
384 | 387 | ParameterDeclaration auto_target_param = Utils.findParameter(method, auto_parameter_name); |
385 | 388 | TypeInfo auto_target_type_info = typeinfos_instance.get(auto_target_param); |
386 | writer.print("(" + auto_parameter_name + ".remaining()"); | |
389 | if ( auto_type_annotation.canBeNull() ) | |
390 | writer.print("((" + auto_parameter_name + " == null ? 0 : " + auto_parameter_name + ".remaining())"); | |
391 | else | |
392 | writer.print("(" + auto_parameter_name + ".remaining()"); | |
387 | 393 | // Shift the remaining if the target parameter is multityped and there's no AutoType to track type |
388 | 394 | boolean shift_remaining = !hasAnyParameterAutoTypeAnnotation(method, auto_target_param) && Utils.isParameterMultiTyped(auto_target_param); |
389 | 395 | if (shift_remaining) { |
442 | 448 | writer.print(offset == null ? "0" : offset); |
443 | 449 | } else |
444 | 450 | writer.print("0"); |
445 | } else if ( param.getAnnotation(GLpointer.class) != null ) { | |
446 | writer.print(".getPointer()"); | |
451 | } else { | |
452 | GLpointer pointer_annotation = param.getAnnotation(GLpointer.class); | |
453 | if ( pointer_annotation != null ) { | |
454 | if ( pointer_annotation.canBeNull() ) | |
455 | writer.print(" == null ? 0 : " + param.getSimpleName()); | |
456 | writer.print(".getPointer()"); | |
457 | } | |
447 | 458 | } |
448 | 459 | } |
449 | 460 | } |
489 | 500 | cachedReference != null && |
490 | 501 | (mode != Mode.BUFFEROBJECT || param.getAnnotation(BufferObject.class) == null) && |
491 | 502 | param.getAnnotation(Result.class) == null) { |
492 | writer.print("\t\t" + Utils.CHECKS_CLASS_NAME + ".getReferences(caps)."); | |
503 | writer.print("\t\tif ( LWJGLUtil.CHECKS ) " + Utils.CHECKS_CLASS_NAME + ".getReferences(caps)."); | |
493 | 504 | if(cachedReference.name().length() > 0) { |
494 | 505 | writer.print(cachedReference.name()); |
495 | 506 | } else { |
35 | 35 | * Various utility methods to the generator. |
36 | 36 | * |
37 | 37 | * @author elias_naur <elias_naur@users.sourceforge.net> |
38 | * @version $Revision: 3299 $ | |
39 | * $Id: Utils.java 3299 2010-03-31 15:46:16Z spasi $ | |
38 | * @version $Revision: 3339 $ | |
39 | * $Id: Utils.java 3339 2010-05-07 17:03:36Z spasi $ | |
40 | 40 | */ |
41 | 41 | |
42 | 42 | import java.io.PrintWriter; |
165 | 165 | return null; |
166 | 166 | } |
167 | 167 | |
168 | // DISABLED: We always generate indirect methods. (affects OpenAL only at the time of this change) | |
168 | 169 | public static boolean isMethodIndirect(boolean generate_error_checks, boolean context_specific, MethodDeclaration method) { |
170 | /* | |
169 | 171 | for (ParameterDeclaration param : method.getParameters()) { |
170 | 172 | if (isAddressableType(param.getType()) || getParameterAutoAnnotation(param) != null || |
171 | 173 | param.getAnnotation(Constant.class) != null) |
175 | 177 | method.getAnnotation(CachedResult.class) != null || |
176 | 178 | (generate_error_checks && method.getAnnotation(NoErrorCheck.class) == null) || |
177 | 179 | context_specific; |
180 | */ | |
181 | return true; | |
178 | 182 | } |
179 | 183 | |
180 | 184 | public static String getNativeQualifiedName(String qualified_name) { |
132 | 132 | typedef uint64_t GLuint64; |
133 | 133 | typedef struct __GLsync *GLsync; |
134 | 134 | |
135 | /* AMD_debug_output callback function pointer. */ | |
136 | typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id, GLenum category, GLenum severity, GLsizei length, const GLchar* message, GLvoid* userParam); | |
137 | ||
135 | 138 | /* helper stuff */ |
136 | 139 | |
137 | 140 | /* initializes everything, call this right after the rc is created. the function returns true if successful */ |
85 | 85 | int length; |
86 | 86 | int i=1; |
87 | 87 | |
88 | if(alcString == NULL) { | |
88 | if (alcString == NULL) { | |
89 | 89 | return NULL; |
90 | 90 | } |
91 | 91 | |
93 | 93 | // These are encoded using \0 between elements and a finishing \0\0 |
94 | 94 | switch(token) { |
95 | 95 | case 0x1005: // ALC_DEVICE_SPECIFIER |
96 | case 0x310: // ALC_CAPTURE_DEVICE_SPECIFIER | |
96 | case 0x310: // ALC_CAPTURE_DEVICE_SPECIFIER | |
97 | // If deviceaddress is not 0, OpenAL returns a single device terminated by a | |
98 | // single \0 character, if token is ALC_DEVICE_SPECIFIER or | |
99 | // ALC_CAPTURE_DEVICE_SPECIFIER. | |
100 | if (deviceaddress != 0) { | |
101 | length = strlen(alcString); | |
102 | break; | |
103 | } | |
97 | 104 | case 0x1013: // ALC_ALL_DEVICES_SPECIFIER |
98 | 105 | while (alcString[i - 1] != '\0' || alcString[i] != '\0') { |
99 | 106 | i++; |
100 | 107 | } |
101 | 108 | length = i + 1; |
102 | 109 | break; |
103 | default: | |
110 | default: // e.g. ALC_DEFAULT_ALL_DEVICES_SPECIFIER | |
104 | 111 | length = strlen(alcString); |
105 | 112 | } |
106 | 113 | return NewStringNativeWithLength(env, alcString, length); |
0 | /* | |
1 | * Copyright (c) 2002-2008 LWJGL Project | |
2 | * All rights reserved. | |
3 | * | |
4 | * Redistribution and use in source and binary forms, with or without | |
5 | * modification, are permitted provided that the following conditions are | |
6 | * met: | |
7 | * | |
8 | * * Redistributions of source code must retain the above copyright | |
9 | * notice, this list of conditions and the following disclaimer. | |
10 | * | |
11 | * * Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | |
14 | * | |
15 | * * Neither the name of 'LWJGL' nor the names of | |
16 | * its contributors may be used to endorse or promote products derived | |
17 | * from this software without specific prior written permission. | |
18 | * | |
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | |
23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
24 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
25 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
26 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | |
27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | |
31 | ||
32 | /** | |
33 | * JNI implementation of the AMD_debug_output function callback. | |
34 | * | |
35 | * @author Spasi | |
36 | */ | |
37 | ||
38 | #include <jni.h> | |
39 | #include "common_tools.h" | |
40 | #include "extgl.h" | |
41 | #include "org_lwjgl_opengl_AMDDebugOutputCallback.h" | |
42 | ||
43 | static void APIENTRY debugOutputCallback(GLuint id, GLenum category, GLenum severity, GLsizei length, const GLchar* message, GLvoid* userParam) { | |
44 | jclass callback_class; | |
45 | jmethodID callback_method; | |
46 | JNIEnv *env = getThreadEnv(); | |
47 | if (env != NULL && !(*env)->ExceptionOccurred(env)) { | |
48 | callback_class = (*env)->FindClass(env, "org/lwjgl/opengl/AMDDebugOutputUtil"); | |
49 | if ( callback_class != NULL ) { | |
50 | callback_method = (*env)->GetStaticMethodID(env, callback_class, "messageCallback", "(IIILjava/lang/String;Ljava/nio/ByteBuffer;)V"); | |
51 | if ( callback_method != NULL ) { | |
52 | (*env)->CallStaticVoidMethod(env, callback_class, callback_method, | |
53 | (jint)id, | |
54 | (jint)category, | |
55 | (jint)severity, | |
56 | NewStringNativeWithLength(env, message, length), | |
57 | NULL | |
58 | ); | |
59 | } | |
60 | } | |
61 | } | |
62 | } | |
63 | ||
64 | JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_AMDDebugOutputCallback_getFunctionPointer(JNIEnv *env, jclass clazz) { | |
65 | return (jlong)(intptr_t)&debugOutputCallback; | |
66 | } |
30 | 30 | */ |
31 | 31 | |
32 | 32 | /** |
33 | * $Id: context.c 3116 2008-08-19 16:46:03Z spasi $ | |
33 | * $Id: context.c 3357 2010-06-02 23:35:38Z spasi $ | |
34 | 34 | * |
35 | 35 | * Include file to access public window features |
36 | 36 | * |
37 | 37 | * @author elias_naur <elias_naur@users.sourceforge.net> |
38 | * @version $Revision: 3116 $ | |
38 | * @version $Revision: 3357 $ | |
39 | 39 | */ |
40 | 40 | |
41 | 41 | #include <jni.h> |
118 | 118 | int depth = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "depth", "I")); |
119 | 119 | int stencil = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stencil", "I")); |
120 | 120 | int samples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "samples", "I")); |
121 | int colorSamples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "colorSamples", "I")); | |
121 | 122 | int num_aux_buffers = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "num_aux_buffers", "I")); |
122 | 123 | int accum_bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_bpp", "I")); |
123 | 124 | int accum_alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_alpha", "I")); |
160 | 161 | // Assume the caller has checked support for multisample |
161 | 162 | if (samples > 0) { |
162 | 163 | putAttrib(&attrib_list, GLX_SAMPLE_BUFFERS_ARB); putAttrib(&attrib_list, 1); |
163 | putAttrib(&attrib_list, GLX_SAMPLES_ARB); putAttrib(&attrib_list, samples); | |
164 | putAttrib(&attrib_list, GLX_SAMPLES_ARB); putAttrib(&attrib_list, samples); // GLX_COVERAGE_SAMPLES_NV if colorSamples > 0 | |
165 | if ( colorSamples > 0 ) { | |
166 | putAttrib(&attrib_list, GLX_COLOR_SAMPLES_NV); putAttrib(&attrib_list, colorSamples); | |
167 | } | |
164 | 168 | } |
165 | 169 | if (sRGB) { |
166 | 170 | putAttrib(&attrib_list, GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB); putAttrib(&attrib_list, True); |
198 | 202 | int depth = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "depth", "I")); |
199 | 203 | int stencil = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stencil", "I")); |
200 | 204 | int samples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "samples", "I")); |
205 | int colorSamples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "colorSamples", "I")); | |
201 | 206 | int num_aux_buffers = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "num_aux_buffers", "I")); |
202 | 207 | int accum_bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_bpp", "I")); |
203 | 208 | int accum_alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_alpha", "I")); |
227 | 232 | // Assume the caller has checked support for multisample |
228 | 233 | if (samples > 0) { |
229 | 234 | putAttrib(&attrib_list, GLX_SAMPLE_BUFFERS_ARB); putAttrib(&attrib_list, 1); |
230 | putAttrib(&attrib_list, GLX_SAMPLES_ARB); putAttrib(&attrib_list, samples); | |
235 | putAttrib(&attrib_list, GLX_SAMPLES_ARB); putAttrib(&attrib_list, samples); // GLX_COVERAGE_SAMPLES_NV if colorSamples > 0 | |
236 | if ( colorSamples > 0 ) | |
237 | putAttrib(&attrib_list, GLX_COLOR_SAMPLES_NV); putAttrib(&attrib_list, colorSamples); | |
231 | 238 | } |
232 | 239 | if (sRGB) |
233 | 240 | putAttrib(&attrib_list, GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB); |
288 | 295 | throwException(env, "Samples > 0 specified but there's no support for GLX_ARB_multisample"); |
289 | 296 | return false; |
290 | 297 | } |
298 | int colorSamples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "colorSamples", "I")); | |
299 | if (colorSamples > 0 && !extension_flags.GLX_NV_multisample_coverage) { | |
300 | throwException(env, "Color samples > 0 specified but there's no support for GLX_NV_multisample_coverage"); | |
301 | return false; | |
302 | } | |
291 | 303 | bool floating_point = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point", "Z")); |
292 | 304 | if (floating_point && !(extension_flags.GLX13 && extension_flags.GLX_ARB_fbconfig_float)) { // We need GLX13 to support floating point |
293 | 305 | throwException(env, "Floating point specified but there's no support for GLX_ARB_fbconfig_float"); |
159 | 159 | extension_flags->GLX_EXT_fbconfig_packed_float = GLXQueryExtension(disp, screen, "GLX_EXT_fbconfig_packed_float"); |
160 | 160 | extension_flags->GLX_ARB_framebuffer_sRGB = GLXQueryExtension(disp, screen, "GLX_ARB_framebuffer_sRGB") || GLXQueryExtension(disp, screen, "GLX_EXT_framebuffer_sRGB"); |
161 | 161 | extension_flags->GLX_ARB_create_context = GLXQueryExtension(disp, screen, "GLX_ARB_create_context"); |
162 | extension_flags->GLX_NV_multisample_coverage = GLXQueryExtension(disp, screen, "GLX_NV_multisample_coverage"); | |
162 | 163 | } |
163 | 164 | |
164 | 165 | bool extgl_Open(JNIEnv *env) { |
270 | 270 | #define GLX_CONTEXT_DEBUG_BIT_ARB 0x0001 |
271 | 271 | #define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002 |
272 | 272 | |
273 | /* GLX_NV_multisample_coverage */ | |
274 | #define GLX_COVERAGE_SAMPLES_NV 100001 | |
275 | #define GLX_COLOR_SAMPLES_NV 0x20B3 | |
276 | ||
277 | ||
273 | 278 | typedef XID GLXContextID; |
274 | 279 | typedef XID GLXPixmap; |
275 | 280 | typedef XID GLXDrawable; |
345 | 350 | bool GLX_EXT_fbconfig_packed_float; |
346 | 351 | bool GLX_ARB_framebuffer_sRGB; |
347 | 352 | bool GLX_ARB_create_context; |
353 | bool GLX_NV_multisample_coverage; | |
348 | 354 | } GLXExtensions; |
349 | 355 | |
350 | 356 | /* Add _ to global symbols to avoid symbol clash with the OpenGL library */ |
0 | /* | |
0 | /* | |
1 | 1 | * Copyright (c) 2002-2008 LWJGL Project |
2 | 2 | * All rights reserved. |
3 | * | |
3 | * | |
4 | 4 | * Redistribution and use in source and binary forms, with or without |
5 | * modification, are permitted provided that the following conditions are | |
5 | * modification, are permitted provided that the following conditions are | |
6 | 6 | * met: |
7 | * | |
8 | * * Redistributions of source code must retain the above copyright | |
7 | * | |
8 | * * Redistributions of source code must retain the above copyright | |
9 | 9 | * notice, this list of conditions and the following disclaimer. |
10 | 10 | * |
11 | 11 | * * Redistributions in binary form must reproduce the above copyright |
12 | 12 | * notice, this list of conditions and the following disclaimer in the |
13 | 13 | * documentation and/or other materials provided with the distribution. |
14 | 14 | * |
15 | * * Neither the name of 'LWJGL' nor the names of | |
16 | * its contributors may be used to endorse or promote products derived | |
15 | * * Neither the name of 'LWJGL' nor the names of | |
16 | * its contributors may be used to endorse or promote products derived | |
17 | 17 | * from this software without specific prior written permission. |
18 | * | |
18 | * | |
19 | 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
20 | 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
21 | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | |
23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
24 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
25 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | |
23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
24 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
25 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
26 | 26 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
28 | 28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
29 | 29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
30 | 30 | */ |
31 | 31 | |
32 | 32 | /** |
33 | * $Id: org_lwjgl_opengl_LinuxPeerInfo.c 2985 2008-04-07 18:42:36Z matzon $ | |
33 | * $Id: org_lwjgl_opengl_LinuxPeerInfo.c 3358 2010-06-03 15:49:26Z spasi $ | |
34 | 34 | * |
35 | 35 | * @author elias_naur <elias_naur@users.sourceforge.net> |
36 | * @version $Revision: 2985 $ | |
36 | * @version $Revision: 3358 $ | |
37 | 37 | */ |
38 | 38 | |
39 | 39 | #include <jni.h> |
0 | /* | |
0 | /* | |
1 | 1 | * Copyright (c) 2002-2008 LWJGL Project |
2 | 2 | * All rights reserved. |
3 | * | |
3 | * | |
4 | 4 | * Redistribution and use in source and binary forms, with or without |
5 | * modification, are permitted provided that the following conditions are | |
5 | * modification, are permitted provided that the following conditions are | |
6 | 6 | * met: |
7 | * | |
8 | * * Redistributions of source code must retain the above copyright | |
7 | * | |
8 | * * Redistributions of source code must retain the above copyright | |
9 | 9 | * notice, this list of conditions and the following disclaimer. |
10 | 10 | * |
11 | 11 | * * Redistributions in binary form must reproduce the above copyright |
12 | 12 | * notice, this list of conditions and the following disclaimer in the |
13 | 13 | * documentation and/or other materials provided with the distribution. |
14 | 14 | * |
15 | * * Neither the name of 'LWJGL' nor the names of | |
16 | * its contributors may be used to endorse or promote products derived | |
15 | * * Neither the name of 'LWJGL' nor the names of | |
16 | * its contributors may be used to endorse or promote products derived | |
17 | 17 | * from this software without specific prior written permission. |
18 | * | |
18 | * | |
19 | 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
20 | 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
21 | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | |
23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
24 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
25 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | |
23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
24 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
25 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
26 | 26 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
28 | 28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
29 | 29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
30 | 30 | */ |
31 | 31 | |
32 | 32 | /** |
33 | * $Id: org_lwjgl_opengl_Pbuffer.c 2985 2008-04-07 18:42:36Z matzon $ | |
33 | * $Id: org_lwjgl_opengl_Pbuffer.c 3358 2010-06-03 15:49:26Z spasi $ | |
34 | 34 | * |
35 | 35 | * Linux Pbuffer. |
36 | 36 | * |
37 | 37 | * @author elias_naur <elias_naur@users.sourceforge.net> |
38 | * @version $Revision: 2985 $ | |
38 | * @version $Revision: 3358 $ | |
39 | 39 | */ |
40 | 40 | |
41 | 41 | #include <stdlib.h> |
30 | 30 | */ |
31 | 31 | |
32 | 32 | /** |
33 | * $Id: context.c 3139 2008-10-28 09:53:16Z elias_naur $ | |
33 | * $Id: context.c 3377 2010-07-12 12:04:56Z matzon $ | |
34 | 34 | * |
35 | 35 | * @author elias_naue <elias_naur@users.sourceforge.net> |
36 | * @version $Revision: 3139 $ | |
36 | * @version $Revision: 3377 $ | |
37 | 37 | */ |
38 | 38 | |
39 | 39 | #include <malloc.h> |
186 | 186 | int depth = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "depth", "I")); |
187 | 187 | int stencil = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stencil", "I")); |
188 | 188 | int samples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "samples", "I")); |
189 | int colorSamples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "colorSamples", "I")); | |
189 | 190 | int num_aux_buffers = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "num_aux_buffers", "I")); |
190 | 191 | int accum_bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_bpp", "I")); |
191 | 192 | int accum_alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_alpha", "I")); |
219 | 220 | if (pbuffer) { |
220 | 221 | putAttrib(&attrib_list, WGL_DRAW_TO_PBUFFER_ARB); putAttrib(&attrib_list, TRUE); |
221 | 222 | } |
222 | if (!getBooleanProperty(env, "org.lwjgl.opengl.Display.allowSoftwareOpenGL")) | |
223 | if (!getBooleanProperty(env, "org.lwjgl.opengl.Display.allowSoftwareOpenGL")) { | |
223 | 224 | putAttrib(&attrib_list, WGL_ACCELERATION_ARB); putAttrib(&attrib_list, WGL_FULL_ACCELERATION_ARB); |
225 | } | |
224 | 226 | putAttrib(&attrib_list, WGL_PIXEL_TYPE_ARB); putAttrib(&attrib_list, pixel_type); |
225 | 227 | putAttrib(&attrib_list, WGL_DOUBLE_BUFFER_ARB); putAttrib(&attrib_list, double_buffer ? TRUE : FALSE); |
226 | 228 | putAttrib(&attrib_list, WGL_SUPPORT_OPENGL_ARB); putAttrib(&attrib_list, TRUE); |
233 | 235 | // Assume caller checked extension availability |
234 | 236 | if (samples > 0) { |
235 | 237 | putAttrib(&attrib_list, WGL_SAMPLE_BUFFERS_ARB); putAttrib(&attrib_list, 1); |
236 | putAttrib(&attrib_list, WGL_SAMPLES_ARB); putAttrib(&attrib_list, samples); | |
238 | putAttrib(&attrib_list, WGL_SAMPLES_ARB); putAttrib(&attrib_list, samples); // WGL_COVERAGE_SAMPLES_NV if colorSamples > 0 | |
239 | if ( colorSamples > 0 ) { | |
240 | putAttrib(&attrib_list, WGL_COLOR_SAMPLES_NV); putAttrib(&attrib_list, colorSamples); | |
241 | } | |
237 | 242 | } |
238 | 243 | putAttrib(&attrib_list, WGL_ACCUM_BITS_ARB); putAttrib(&attrib_list, accum_bpp); |
239 | 244 | putAttrib(&attrib_list, WGL_ACCUM_ALPHA_BITS_ARB); putAttrib(&attrib_list, accum_alpha); |
384 | 389 | return findPixelFormatFromBPP(env, hdc, pixel_format, bpp, double_buffer); |
385 | 390 | } |
386 | 391 | |
387 | static bool validateAndGetExtensions(JNIEnv *env, WGLExtensions *extensions, HDC dummy_hdc, HGLRC dummy_hglrc, int samples, bool floating_point, bool floating_point_packed, bool sRGB, jobject pixelFormatCaps) { | |
392 | static bool validateAndGetExtensions(JNIEnv *env, WGLExtensions *extensions, HDC dummy_hdc, HGLRC dummy_hglrc, int samples, int colorSamples, bool floating_point, bool floating_point_packed, bool sRGB, jobject pixelFormatCaps) { | |
388 | 393 | if (!wglMakeCurrent(dummy_hdc, dummy_hglrc)) { |
389 | 394 | throwException(env, "Could not bind context to dummy window"); |
390 | 395 | return false; |
397 | 402 | } |
398 | 403 | if (samples > 0 && !extensions->WGL_ARB_multisample) { |
399 | 404 | throwException(env, "No support for WGL_ARB_multisample"); |
405 | return false; | |
406 | } | |
407 | if (colorSamples > 0 && !extensions->WGL_NV_multisample_coverage) { | |
408 | throwException(env, "No support for WGL_NV_multisample_coverage"); | |
400 | 409 | return false; |
401 | 410 | } |
402 | 411 | /* |
434 | 443 | jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format); |
435 | 444 | |
436 | 445 | int samples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "samples", "I")); |
446 | int colorSamples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "colorSamples", "I")); | |
437 | 447 | bool floating_point = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point", "Z")); |
438 | 448 | bool floating_point_packed = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point_packed", "Z")); |
439 | 449 | bool sRGB = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "sRGB", "Z")); |
460 | 470 | // Save the current HDC and HGLRC to avoid disruption |
461 | 471 | saved_current_hdc = wglGetCurrentDC(); |
462 | 472 | saved_current_hglrc = wglGetCurrentContext(); |
463 | if (validateAndGetExtensions(env, &extensions, dummy_hdc, dummy_hglrc, samples, floating_point, floating_point_packed, sRGB, pixelFormatCaps)) { | |
473 | if (validateAndGetExtensions(env, &extensions, dummy_hdc, dummy_hglrc, samples, colorSamples, floating_point, floating_point_packed, sRGB, pixelFormatCaps)) { | |
464 | 474 | pixel_format_id = findPixelFormatARB(env, hdc, &extensions, pixel_format, pixelFormatCaps, use_hdc_bpp, window, pbuffer, double_buffer); |
465 | 475 | } |
466 | 476 | wglMakeCurrent(saved_current_hdc, saved_current_hglrc); |
151 | 151 | extensions->WGL_ARB_framebuffer_sRGB = WGLQueryExtension(extensions, "WGL_ARB_framebuffer_sRGB") || WGLQueryExtension(extensions, "WGL_EXT_framebuffer_sRGB"); |
152 | 152 | extensions->WGL_EXT_pixel_format_packed_float = WGLQueryExtension(extensions, "WGL_EXT_pixel_format_packed_float"); |
153 | 153 | extensions->WGL_ARB_create_context = WGLQueryExtension(extensions, "WGL_ARB_create_context"); |
154 | extensions->WGL_NV_multisample_coverage = WGLQueryExtension(extensions, "WGL_NV_multisample_coverage"); | |
154 | 155 | } |
155 | 156 | |
156 | 157 | static void extgl_InitWGLEXTExtensionsString(WGLExtensions *extensions) { |
199 | 199 | |
200 | 200 | typedef HGLRC (APIENTRY * wglCreateContextAttribsARBPROC) (HDC hDC, HGLRC hShareContext, const int *attribList); |
201 | 201 | |
202 | /*---------------------------------------------------------------------*/ | |
203 | /*------------ WGL_NV_multisample_coverage ----------------------------*/ | |
204 | /*---------------------------------------------------------------------*/ | |
205 | ||
206 | #define WGL_COVERAGE_SAMPLES_NV 0x2042 | |
207 | #define WGL_COLOR_SAMPLES_NV 0x20B9 | |
208 | ||
209 | /*---------------------------------------------------------------------*/ | |
210 | ||
202 | 211 | typedef struct { |
203 | 212 | bool WGL_ARB_buffer_region; |
204 | 213 | bool WGL_ARB_extensions_string; |
216 | 225 | bool WGL_ARB_framebuffer_sRGB; |
217 | 226 | bool WGL_EXT_pixel_format_packed_float; |
218 | 227 | bool WGL_ARB_create_context; |
228 | bool WGL_NV_multisample_coverage; | |
219 | 229 | |
220 | 230 | wglGetExtensionsStringEXTPROC wglGetExtensionsStringEXT; |
221 | 231 |
0 | /* | |
0 | /* | |
1 | 1 | * Copyright (c) 2002-2008 LWJGL Project |
2 | 2 | * All rights reserved. |
3 | * | |
3 | * | |
4 | 4 | * Redistribution and use in source and binary forms, with or without |
5 | * modification, are permitted provided that the following conditions are | |
5 | * modification, are permitted provided that the following conditions are | |
6 | 6 | * met: |
7 | * | |
8 | * * Redistributions of source code must retain the above copyright | |
7 | * | |
8 | * * Redistributions of source code must retain the above copyright | |
9 | 9 | * notice, this list of conditions and the following disclaimer. |
10 | 10 | * |
11 | 11 | * * Redistributions in binary form must reproduce the above copyright |
12 | 12 | * notice, this list of conditions and the following disclaimer in the |
13 | 13 | * documentation and/or other materials provided with the distribution. |
14 | 14 | * |
15 | * * Neither the name of 'LWJGL' nor the names of | |
16 | * its contributors may be used to endorse or promote products derived | |
15 | * * Neither the name of 'LWJGL' nor the names of | |
16 | * its contributors may be used to endorse or promote products derived | |
17 | 17 | * from this software without specific prior written permission. |
18 | * | |
18 | * | |
19 | 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
20 | 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
21 | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | |
23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
24 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
25 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | |
23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
24 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
25 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
26 | 26 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
28 | 28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
29 | 29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
30 | 30 | */ |
31 | 31 | |
32 | 32 | /** |
33 | * $Id: org_lwjgl_opengl_Pbuffer.c 3149 2008-11-22 14:54:15Z elias_naur $ | |
33 | * $Id: org_lwjgl_opengl_Pbuffer.c 3358 2010-06-03 15:49:26Z spasi $ | |
34 | 34 | * |
35 | 35 | * Windows Pbuffer. |
36 | 36 | * |
37 | 37 | * @author elias_naur <elias_naur@users.sourceforge.net> |
38 | * @version $Revision: 3149 $ | |
38 | * @version $Revision: 3358 $ | |
39 | 39 | */ |
40 | 40 | |
41 | 41 | #include <stdlib.h> |
60 | 60 | HDC saved_hdc; |
61 | 61 | HGLRC saved_context; |
62 | 62 | int pixel_format_id; |
63 | ||
63 | ||
64 | 64 | dummy_hwnd = createDummyWindow(origin_x, origin_y); |
65 | 65 | if (dummy_hwnd == NULL) { |
66 | 66 | throwException(env, "Could not create dummy window"); |
135 | 135 | const int *pBufferAttribs_ptr; |
136 | 136 | WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); |
137 | 137 | int pixel_format_id; |
138 | ||
138 | ||
139 | 139 | if ( pBufferAttribs != NULL ) { |
140 | 140 | pBufferAttribs_ptr = (const int *)(*env)->GetDirectBufferAddress(env, pBufferAttribs); |
141 | 141 | } else { |
30 | 30 | */ |
31 | 31 | |
32 | 32 | /** |
33 | * $Id: org_lwjgl_opengl_WindowsPeerInfo.c 3148 2008-11-22 14:51:36Z elias_naur $ | |
33 | * $Id: org_lwjgl_opengl_WindowsPeerInfo.c 3358 2010-06-03 15:49:26Z spasi $ | |
34 | 34 | * |
35 | 35 | * @author elias_naur <elias_naur@users.sourceforge.net> |
36 | * @version $Revision: 3148 $ | |
36 | * @version $Revision: 3358 $ | |
37 | 37 | */ |
38 | 38 | |
39 | 39 | #include <jni.h> |
41 | 41 | #include "context.h" |
42 | 42 | #include "common_tools.h" |
43 | 43 | |
44 | JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_WindowsPeerInfo_createHandle | |
45 | (JNIEnv *env, jclass clazz) { | |
44 | JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_WindowsPeerInfo_createHandle(JNIEnv *env, jclass clazz) { | |
46 | 45 | return newJavaManagedByteBuffer(env, sizeof(WindowsPeerInfo)); |
47 | 46 | } |
48 | 47 |
43 | 43 | * AL.h version 1.0 |
44 | 44 | * |
45 | 45 | * @author Brian Matzon <brian@matzon.dk> |
46 | * @version $Revision: 3288 $ | |
47 | * $Id: AL10.java 3288 2010-03-16 17:58:48Z spasi $ | |
46 | * @version $Revision: 3380 $ | |
47 | * $Id: AL10.java 3380 2010-07-14 13:12:24Z matzon $ | |
48 | 48 | */ |
49 | 49 | public interface AL10 { |
50 | 50 | /** Bad value */ |
249 | 249 | int AL_FREQUENCY = 0x2001; |
250 | 250 | |
251 | 251 | /** |
252 | * Sound buffers: frequency, in units of Hertz [Hz]. | |
253 | * This is the number of samples per second. Half of the | |
254 | * sample frequency marks the maximum significant | |
255 | * frequency component. | |
252 | * Sound buffers: The number of bits per sample for the | |
253 | * data contained in the buffer. | |
256 | 254 | */ |
257 | 255 | int AL_BITS = 0x2002; |
258 | 256 | |
259 | 257 | /** |
260 | * Sound buffers: frequency, in units of Hertz [Hz]. | |
261 | * This is the number of samples per second. Half of the | |
262 | * sample frequency marks the maximum significant | |
263 | * frequency component. | |
258 | * Sound buffers: The number of channels for the data | |
259 | * contained in the buffer. | |
264 | 260 | */ |
265 | 261 | int AL_CHANNELS = 0x2003; |
266 | 262 | |
267 | 263 | /** |
268 | * Sound buffers: frequency, in units of Hertz [Hz]. | |
269 | * This is the number of samples per second. Half of the | |
270 | * sample frequency marks the maximum significant | |
271 | * frequency component. | |
264 | * Sound buffers: Size in bytes of the buffer data. | |
272 | 265 | */ |
273 | 266 | int AL_SIZE = 0x2004; |
274 | 267 | |
275 | 268 | /** |
276 | * Sound buffers: frequency, in units of Hertz [Hz]. | |
277 | * This is the number of samples per second. Half of the | |
278 | * sample frequency marks the maximum significant | |
279 | * frequency component. | |
280 | */ | |
269 | * @deprecated This token is a relict of the early OpenAL days and is | |
270 | * no longer supported. Neither the OpenAL spec nor OpenAL Soft define | |
271 | * it. | |
272 | */ | |
273 | @Deprecated | |
281 | 274 | int AL_DATA = 0x2005; |
282 | 275 | |
283 | 276 | /** |
0 | /* | |
1 | * Copyright (c) 2002-2010 LWJGL Project | |
2 | * All rights reserved. | |
3 | * | |
4 | * Redistribution and use in source and binary forms, with or without | |
5 | * modification, are permitted provided that the following conditions are | |
6 | * met: | |
7 | * | |
8 | * * Redistributions of source code must retain the above copyright | |
9 | * notice, this list of conditions and the following disclaimer. | |
10 | * | |
11 | * * Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | |
14 | * | |
15 | * * Neither the name of 'LWJGL' nor the names of | |
16 | * its contributors may be used to endorse or promote products derived | |
17 | * from this software without specific prior written permission. | |
18 | * | |
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | |
23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
24 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
25 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
26 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | |
27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | |
31 | package org.lwjgl.openal; | |
32 | ||
33 | import java.nio.FloatBuffer; | |
34 | import java.nio.IntBuffer; | |
35 | ||
36 | import org.lwjgl.util.generator.ALenum; | |
37 | import org.lwjgl.util.generator.ALsizei; | |
38 | import org.lwjgl.util.generator.ALuint; | |
39 | import org.lwjgl.util.generator.ALvoid; | |
40 | import org.lwjgl.util.generator.Alternate; | |
41 | import org.lwjgl.util.generator.AutoSize; | |
42 | import org.lwjgl.util.generator.Check; | |
43 | import org.lwjgl.util.generator.Const; | |
44 | import org.lwjgl.util.generator.Constant; | |
45 | import org.lwjgl.util.generator.Indirect; | |
46 | import org.lwjgl.util.generator.OutParameter; | |
47 | import org.lwjgl.util.generator.Result; | |
48 | import org.lwjgl.util.generator.StripPostfix; | |
49 | ||
50 | /** | |
51 | * Implementation of the OpenAL extension ALC_EXT_EFX (version 1.0). Contains necessary fields, | |
52 | * methods and a range of supplementary fields containing minimum, maximum and default values of | |
53 | * the former fields. | |
54 | * <p> | |
55 | * On top of regular functions defined in the ALC_EXT_EFX, there are also several convenience | |
56 | * functions. Namely alGen... and alDelete... which do not take a Java buffer parameter and | |
57 | * automatically create or delete a single object, without the overhead of using a buffer. | |
58 | * <p> | |
59 | * For comments and specification of functions and fields, refer to the "Effects Extension Guide" | |
60 | * which is part of the OpenAL SDK and can be downloaded from: | |
61 | * http://connect.creativelabs.com/openal/Downloads/Forms/AllItems.aspx | |
62 | * | |
63 | * @author Ciardhubh <ciardhubh[at]ciardhubh.de> | |
64 | * @version $Revision$ | |
65 | * $Id$ | |
66 | */ | |
67 | public interface EFX10 { | |
68 | ||
69 | // ALC properties | |
70 | String ALC_EXT_EFX_NAME = "ALC_EXT_EFX"; | |
71 | int ALC_EFX_MAJOR_VERSION = 0x20001; | |
72 | int ALC_EFX_MINOR_VERSION = 0x20002; | |
73 | int ALC_MAX_AUXILIARY_SENDS = 0x20003; | |
74 | ||
75 | // Listener properties | |
76 | int AL_METERS_PER_UNIT = 0x20004; | |
77 | ||
78 | // Source properties | |
79 | int AL_DIRECT_FILTER = 0x20005; | |
80 | int AL_AUXILIARY_SEND_FILTER = 0x20006; | |
81 | int AL_AIR_ABSORPTION_FACTOR = 0x20007; | |
82 | int AL_ROOM_ROLLOFF_FACTOR = 0x20008; | |
83 | int AL_CONE_OUTER_GAINHF = 0x20009; | |
84 | int AL_DIRECT_FILTER_GAINHF_AUTO = 0x2000A; | |
85 | int AL_AUXILIARY_SEND_FILTER_GAIN_AUTO = 0x2000B; | |
86 | int AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO = 0x2000C; | |
87 | ||
88 | // Auxiliary effect slot properties | |
89 | int AL_EFFECTSLOT_EFFECT = 0x0001; | |
90 | int AL_EFFECTSLOT_GAIN = 0x0002; | |
91 | int AL_EFFECTSLOT_AUXILIARY_SEND_AUTO = 0x0003; | |
92 | // NULL auxiliary slot ID to disable a source send | |
93 | int AL_EFFECTSLOT_NULL = 0x0000; | |
94 | ||
95 | // Effect parameters | |
96 | // Reverb | |
97 | int AL_REVERB_DENSITY = 0x0001; | |
98 | int AL_REVERB_DIFFUSION = 0x0002; | |
99 | int AL_REVERB_GAIN = 0x0003; | |
100 | int AL_REVERB_GAINHF = 0x0004; | |
101 | int AL_REVERB_DECAY_TIME = 0x0005; | |
102 | int AL_REVERB_DECAY_HFRATIO = 0x0006; | |
103 | int AL_REVERB_REFLECTIONS_GAIN = 0x0007; | |
104 | int AL_REVERB_REFLECTIONS_DELAY = 0x0008; | |
105 | int AL_REVERB_LATE_REVERB_GAIN = 0x0009; | |
106 | int AL_REVERB_LATE_REVERB_DELAY = 0x000A; | |
107 | int AL_REVERB_AIR_ABSORPTION_GAINHF = 0x000B; | |
108 | int AL_REVERB_ROOM_ROLLOFF_FACTOR = 0x000C; | |
109 | int AL_REVERB_DECAY_HFLIMIT = 0x000D; | |
110 | // EAX Reverb | |
111 | int AL_EAXREVERB_DENSITY = 0x0001; | |
112 | int AL_EAXREVERB_DIFFUSION = 0x0002; | |
113 | int AL_EAXREVERB_GAIN = 0x0003; | |
114 | int AL_EAXREVERB_GAINHF = 0x0004; | |
115 | int AL_EAXREVERB_GAINLF = 0x0005; | |
116 | int AL_EAXREVERB_DECAY_TIME = 0x0006; | |
117 | int AL_EAXREVERB_DECAY_HFRATIO = 0x0007; | |
118 | int AL_EAXREVERB_DECAY_LFRATIO = 0x0008; | |
119 | int AL_EAXREVERB_REFLECTIONS_GAIN = 0x0009; | |
120 | int AL_EAXREVERB_REFLECTIONS_DELAY = 0x000A; | |
121 | int AL_EAXREVERB_REFLECTIONS_PAN = 0x000B; | |
122 | int AL_EAXREVERB_LATE_REVERB_GAIN = 0x000C; | |
123 | int AL_EAXREVERB_LATE_REVERB_DELAY = 0x000D; | |
124 | int AL_EAXREVERB_LATE_REVERB_PAN = 0x000E; | |
125 | int AL_EAXREVERB_ECHO_TIME = 0x000F; | |
126 | int AL_EAXREVERB_ECHO_DEPTH = 0x0010; | |
127 | int AL_EAXREVERB_MODULATION_TIME = 0x0011; | |
128 | int AL_EAXREVERB_MODULATION_DEPTH = 0x0012; | |
129 | int AL_EAXREVERB_AIR_ABSORPTION_GAINHF = 0x0013; | |
130 | int AL_EAXREVERB_HFREFERENCE = 0x0014; | |
131 | int AL_EAXREVERB_LFREFERENCE = 0x0015; | |
132 | int AL_EAXREVERB_ROOM_ROLLOFF_FACTOR = 0x0016; | |
133 | int AL_EAXREVERB_DECAY_HFLIMIT = 0x0017; | |
134 | // Chorus | |
135 | int AL_CHORUS_WAVEFORM = 0x0001; | |
136 | int AL_CHORUS_PHASE = 0x0002; | |
137 | int AL_CHORUS_RATE = 0x0003; | |
138 | int AL_CHORUS_DEPTH = 0x0004; | |
139 | int AL_CHORUS_FEEDBACK = 0x0005; | |
140 | int AL_CHORUS_DELAY = 0x0006; | |
141 | // Distortion | |
142 | int AL_DISTORTION_EDGE = 0x0001; | |
143 | int AL_DISTORTION_GAIN = 0x0002; | |
144 | int AL_DISTORTION_LOWPASS_CUTOFF = 0x0003; | |
145 | int AL_DISTORTION_EQCENTER = 0x0004; | |
146 | int AL_DISTORTION_EQBANDWIDTH = 0x0005; | |
147 | // Echo | |
148 | int AL_ECHO_DELAY = 0x0001; | |
149 | int AL_ECHO_LRDELAY = 0x0002; | |
150 | int AL_ECHO_DAMPING = 0x0003; | |
151 | int AL_ECHO_FEEDBACK = 0x0004; | |
152 | int AL_ECHO_SPREAD = 0x0005; | |
153 | // Flanger | |
154 | int AL_FLANGER_WAVEFORM = 0x0001; | |
155 | int AL_FLANGER_PHASE = 0x0002; | |
156 | int AL_FLANGER_RATE = 0x0003; | |
157 | int AL_FLANGER_DEPTH = 0x0004; | |
158 | int AL_FLANGER_FEEDBACK = 0x0005; | |
159 | int AL_FLANGER_DELAY = 0x0006; | |
160 | // Frequency shifter | |
161 | int AL_FREQUENCY_SHIFTER_FREQUENCY = 0x0001; | |
162 | int AL_FREQUENCY_SHIFTER_LEFT_DIRECTION = 0x0002; | |
163 | int AL_FREQUENCY_SHIFTER_RIGHT_DIRECTION = 0x0003; | |
164 | // Vocal morpher | |
165 | int AL_VOCAL_MORPHER_PHONEMEA = 0x0001; | |
166 | int AL_VOCAL_MORPHER_PHONEMEA_COARSE_TUNING = 0x0002; | |
167 | int AL_VOCAL_MORPHER_PHONEMEB = 0x0003; | |
168 | int AL_VOCAL_MORPHER_PHONEMEB_COARSE_TUNING = 0x0004; | |
169 | int AL_VOCAL_MORPHER_WAVEFORM = 0x0005; | |
170 | int AL_VOCAL_MORPHER_RATE = 0x0006; | |
171 | // Pitch shifter | |
172 | int AL_PITCH_SHIFTER_COARSE_TUNE = 0x0001; | |
173 | int AL_PITCH_SHIFTER_FINE_TUNE = 0x0002; | |
174 | // Ring modulator | |
175 | int AL_RING_MODULATOR_FREQUENCY = 0x0001; | |
176 | int AL_RING_MODULATOR_HIGHPASS_CUTOFF = 0x0002; | |
177 | int AL_RING_MODULATOR_WAVEFORM = 0x0003; | |
178 | // Autowah | |
179 | int AL_AUTOWAH_ATTACK_TIME = 0x0001; | |
180 | int AL_AUTOWAH_RELEASE_TIME = 0x0002; | |
181 | int AL_AUTOWAH_RESONANCE = 0x0003; | |
182 | int AL_AUTOWAH_PEAK_GAIN = 0x0004; | |
183 | // Compressor | |
184 | int AL_COMPRESSOR_ONOFF = 0x0001; | |
185 | // Equalizer | |
186 | int AL_EQUALIZER_LOW_GAIN = 0x0001; | |
187 | int AL_EQUALIZER_LOW_CUTOFF = 0x0002; | |
188 | int AL_EQUALIZER_MID1_GAIN = 0x0003; | |
189 | int AL_EQUALIZER_MID1_CENTER = 0x0004; | |
190 | int AL_EQUALIZER_MID1_WIDTH = 0x0005; | |
191 | int AL_EQUALIZER_MID2_GAIN = 0x0006; | |
192 | int AL_EQUALIZER_MID2_CENTER = 0x0007; | |
193 | int AL_EQUALIZER_MID2_WIDTH = 0x0008; | |
194 | int AL_EQUALIZER_HIGH_GAIN = 0x0009; | |
195 | int AL_EQUALIZER_HIGH_CUTOFF = 0x000A; | |
196 | // Effect type | |
197 | int AL_EFFECT_FIRST_PARAMETER = 0x0000; | |
198 | int AL_EFFECT_LAST_PARAMETER = 0x8000; | |
199 | int AL_EFFECT_TYPE = 0x8001; | |
200 | // Effect types, used with AL_EFFECT_TYPE | |
201 | int AL_EFFECT_NULL = 0x0000; | |
202 | int AL_EFFECT_REVERB = 0x0001; | |
203 | int AL_EFFECT_CHORUS = 0x0002; | |
204 | int AL_EFFECT_DISTORTION = 0x0003; | |
205 | int AL_EFFECT_ECHO = 0x0004; | |
206 | int AL_EFFECT_FLANGER = 0x0005; | |
207 | int AL_EFFECT_FREQUENCY_SHIFTER = 0x0006; | |
208 | int AL_EFFECT_VOCAL_MORPHER = 0x0007; | |
209 | int AL_EFFECT_PITCH_SHIFTER = 0x0008; | |
210 | int AL_EFFECT_RING_MODULATOR = 0x0009; | |
211 | int AL_EFFECT_AUTOWAH = 0x000A; | |
212 | int AL_EFFECT_COMPRESSOR = 0x000B; | |
213 | int AL_EFFECT_EQUALIZER = 0x000C; | |
214 | int AL_EFFECT_EAXREVERB = 0x8000; | |
215 | ||
216 | // Filter properties | |
217 | // Lowpass | |
218 | int AL_LOWPASS_GAIN = 0x0001; | |
219 | int AL_LOWPASS_GAINHF = 0x0002; | |
220 | // Highpass | |
221 | int AL_HIGHPASS_GAIN = 0x0001; | |
222 | int AL_HIGHPASS_GAINLF = 0x0002; | |
223 | // Bandpass | |
224 | int AL_BANDPASS_GAIN = 0x0001; | |
225 | int AL_BANDPASS_GAINLF = 0x0002; | |
226 | int AL_BANDPASS_GAINHF = 0x0003; | |
227 | // Filter type | |
228 | int AL_FILTER_FIRST_PARAMETER = 0x0000; | |
229 | int AL_FILTER_LAST_PARAMETER = 0x8000; | |
230 | int AL_FILTER_TYPE = 0x8001; | |
231 | // Filter types, used with the AL_FILTER_TYPE property | |
232 | int AL_FILTER_NULL = 0x0000; | |
233 | int AL_FILTER_LOWPASS = 0x0001; | |
234 | int AL_FILTER_HIGHPASS = 0x0002; | |
235 | int AL_FILTER_BANDPASS = 0x0003; | |
236 | ||
237 | // Auxiliary effect slot object functions | |
238 | @ALvoid | |
239 | void alGenAuxiliaryEffectSlots(@AutoSize("auxiliaryeffectslots") @ALsizei int n, @OutParameter @ALuint IntBuffer auxiliaryeffectslots); | |
240 | ||
241 | @Alternate(value = "alGenAuxiliaryEffectSlots", nativeAlt = true) | |
242 | @ALvoid | |
243 | void alGenAuxiliaryEffectSlots2(@Constant("1") @ALsizei int n, @Result @ALuint int auxiliaryeffectslot); | |
244 | ||
245 | @ALvoid | |
246 | void alDeleteAuxiliaryEffectSlots(@AutoSize("auxiliaryeffectslots") @ALsizei int n, @OutParameter @ALuint IntBuffer auxiliaryeffectslots); | |
247 | ||
248 | @Alternate(value = "alDeleteAuxiliaryEffectSlots", nativeAlt = true) | |
249 | @ALvoid | |
250 | void alDeleteAuxiliaryEffectSlots2(@Constant("1") @ALsizei int n, @Indirect @ALuint int auxiliaryeffectslot); | |
251 | ||
252 | boolean alIsAuxiliaryEffectSlot(@ALuint int auxiliaryeffectslot); | |
253 | ||
254 | @ALvoid | |
255 | void alAuxiliaryEffectSloti(@ALuint int auxiliaryeffectslot, @ALenum int param, int value); | |
256 | ||
257 | @StripPostfix("values") | |
258 | @ALvoid | |
259 | void alAuxiliaryEffectSlotiv(@ALuint int auxiliaryeffectslot, @ALenum int param, @Check("1") @Const IntBuffer values); | |
260 | ||
261 | @ALvoid | |
262 | void alAuxiliaryEffectSlotf(@ALuint int auxiliaryeffectslot, @ALenum int param, float value); | |
263 | ||
264 | @StripPostfix("values") | |
265 | @ALvoid | |
266 | void alAuxiliaryEffectSlotfv(@ALuint int auxiliaryeffectslot, @ALenum int param, @Check("1") @Const FloatBuffer values); | |
267 | ||
268 | @ALvoid | |
269 | void alGetAuxiliaryEffectSloti(@ALuint int auxiliaryeffectslot, @ALenum int param, @Result int value); | |
270 | ||
271 | @StripPostfix("intdata") | |
272 | @ALvoid | |
273 | void alGetAuxiliaryEffectSlotiv(@ALuint int auxiliaryeffectslot, @ALenum int param, @OutParameter @Check("1") IntBuffer intdata); | |
274 | ||
275 | @ALvoid | |
276 | void alGetAuxiliaryEffectSlotf(@ALuint int auxiliaryeffectslot, @ALenum int param, @Result float value); | |
277 | ||
278 | @StripPostfix("floatdata") | |
279 | @ALvoid | |
280 | void alGetAuxiliaryEffectSlotfv(@ALuint int auxiliaryeffectslot, @ALenum int param, @OutParameter @Check("1") FloatBuffer floatdata); | |
281 | ||
282 | // Effect object functions | |
283 | @ALvoid | |
284 | void alGenEffects(@AutoSize("effects") @ALsizei int n, @OutParameter @ALuint IntBuffer effects); | |
285 | ||
286 | @Alternate(value = "alGenEffects", nativeAlt = true) | |
287 | @ALvoid | |
288 | void alGenEffects2(@Constant("1") @ALsizei int n, @Result @ALuint int effect); | |
289 | ||
290 | @ALvoid | |
291 | void alDeleteEffects(@AutoSize("effects") @ALsizei int n, @OutParameter @ALuint IntBuffer effects); | |
292 | ||
293 | @Alternate(value = "alDeleteEffects", nativeAlt = true) | |
294 | @ALvoid | |
295 | void alDeleteEffects2(@Constant("1") @ALsizei int n, @Indirect @ALuint int effect); | |
296 | ||
297 | boolean alIsEffect(@ALuint int effect); | |
298 | ||
299 | @ALvoid | |
300 | void alEffecti(@ALuint int effect, @ALenum int param, int value); | |
301 | ||
302 | @StripPostfix("values") | |
303 | @ALvoid | |
304 | void alEffectiv(@ALuint int effect, @ALenum int param, @Check("1") @Const IntBuffer values); | |
305 | ||
306 | @ALvoid | |
307 | void alEffectf(@ALuint int effect, @ALenum int param, float value); | |
308 | ||
309 | @StripPostfix("values") | |
310 | @ALvoid | |
311 | void alEffectfv(@ALuint int effect, @ALenum int param, @Check("1") @Const FloatBuffer values); | |
312 | ||
313 | @ALvoid | |
314 | void alGetEffecti(@ALuint int effect, @ALenum int param, @Result int value); | |
315 | ||
316 | @StripPostfix("intdata") | |
317 | @ALvoid | |
318 | void alGetEffectiv(@ALuint int effect, @ALenum int param, @OutParameter @Check("1") IntBuffer intdata); | |
319 | ||
320 | @ALvoid | |
321 | void alGetEffectf(@ALuint int effect, @ALenum int param, @Result float value); | |
322 | ||
323 | @StripPostfix("floatdata") | |
324 | @ALvoid | |
325 | void alGetEffectfv(@ALuint int effect, @ALenum int param, @OutParameter @Check("1") FloatBuffer floatdata); | |
326 | ||
327 | // Filter object functions | |
328 | @ALvoid | |
329 | void alGenFilters(@AutoSize("filters") @ALsizei int n, @OutParameter @ALuint IntBuffer filters); | |
330 | ||
331 | @Alternate(value = "alGenFilters", nativeAlt = true) | |
332 | @ALvoid | |
333 | void alGenFilters2(@Constant("1") @ALsizei int n, @Result @ALuint int filter); | |
334 | ||
335 | @ALvoid | |
336 | void alDeleteFilters(@AutoSize("filters") @ALsizei int n, @OutParameter @ALuint IntBuffer filters); | |
337 | ||
338 | @Alternate(value = "alDeleteFilters", nativeAlt = true) | |
339 | @ALvoid | |
340 | void alDeleteFilters2(@Constant("1") @ALsizei int n, @Indirect @ALuint int filter); | |
341 | ||
342 | boolean alIsFilter(@ALuint int filter); | |
343 | ||
344 | @ALvoid | |
345 | void alFilteri(@ALuint int filter, @ALenum int param, int value); | |
346 | ||
347 | @StripPostfix("values") | |
348 | @ALvoid | |
349 | void alFilteriv(@ALuint int filter, @ALenum int param, @Check("1") @Const IntBuffer values); | |
350 | ||
351 | @ALvoid | |
352 | void alFilterf(@ALuint int filter, @ALenum int param, float value); | |
353 | ||
354 | @StripPostfix("values") | |
355 | @ALvoid | |
356 | void alFilterfv(@ALuint int filter, @ALenum int param, @Check("1") @Const FloatBuffer values); | |
357 | ||
358 | @ALvoid | |
359 | void alGetFilteri(@ALuint int filter, @ALenum int param, @Result int value); | |
360 | ||
361 | @StripPostfix("intdata") | |
362 | @ALvoid | |
363 | void alGetFilteriv(@ALuint int filter, @ALenum int param, @OutParameter @Check("1") IntBuffer intdata); | |
364 | ||
365 | @ALvoid | |
366 | void alGetFilterf(@ALuint int filter, @ALenum int param, @Result float value); | |
367 | ||
368 | @StripPostfix("floatdata") | |
369 | @ALvoid | |
370 | void alGetFilterfv(@ALuint int filter, @ALenum int param, @OutParameter @Check("1") FloatBuffer floatdata); | |
371 | ||
372 | // Source property value ranges and defaults | |
373 | float AL_MIN_AIR_ABSORPTION_FACTOR = 0.0f; | |
374 | float AL_MAX_AIR_ABSORPTION_FACTOR = 10.0f; | |
375 | float AL_DEFAULT_AIR_ABSORPTION_FACTOR = 0.0f; | |
376 | float AL_MIN_ROOM_ROLLOFF_FACTOR = 0.0f; | |
377 | float AL_MAX_ROOM_ROLLOFF_FACTOR = 10.0f; | |
378 | float AL_DEFAULT_ROOM_ROLLOFF_FACTOR = 0.0f; | |
379 | float AL_MIN_CONE_OUTER_GAINHF = 0.0f; | |
380 | float AL_MAX_CONE_OUTER_GAINHF = 1.0f; | |
381 | float AL_DEFAULT_CONE_OUTER_GAINHF = 1.0f; | |
382 | int AL_MIN_DIRECT_FILTER_GAINHF_AUTO = AL10.AL_FALSE; | |
383 | int AL_MAX_DIRECT_FILTER_GAINHF_AUTO = AL10.AL_TRUE; | |
384 | int AL_DEFAULT_DIRECT_FILTER_GAINHF_AUTO = AL10.AL_TRUE; | |
385 | int AL_MIN_AUXILIARY_SEND_FILTER_GAIN_AUTO = AL10.AL_FALSE; | |
386 | int AL_MAX_AUXILIARY_SEND_FILTER_GAIN_AUTO = AL10.AL_TRUE; | |
387 | int AL_DEFAULT_AUXILIARY_SEND_FILTER_GAIN_AUTO = AL10.AL_TRUE; | |
388 | int AL_MIN_AUXILIARY_SEND_FILTER_GAINHF_AUTO = AL10.AL_FALSE; | |
389 | int AL_MAX_AUXILIARY_SEND_FILTER_GAINHF_AUTO = AL10.AL_TRUE; | |
390 | int AL_DEFAULT_AUXILIARY_SEND_FILTER_GAINHF_AUTO = AL10.AL_TRUE; | |
391 | ||
392 | // Listener property value ranges and defaults | |
393 | float AL_MIN_METERS_PER_UNIT = Float.MIN_VALUE; | |
394 | float AL_MAX_METERS_PER_UNIT = Float.MAX_VALUE; | |
395 | float AL_DEFAULT_METERS_PER_UNIT = 1.0f; | |
396 | ||
397 | // Effect parameter ranges and defaults | |
398 | // Reverb | |
399 | float AL_REVERB_MIN_DENSITY = 0.0f; | |
400 | float AL_REVERB_MAX_DENSITY = 1.0f; | |
401 | float AL_REVERB_DEFAULT_DENSITY = 1.0f; | |
402 | float AL_REVERB_MIN_DIFFUSION = 0.0f; | |
403 | float AL_REVERB_MAX_DIFFUSION = 1.0f; | |
404 | float AL_REVERB_DEFAULT_DIFFUSION = 1.0f; | |
405 | float AL_REVERB_MIN_GAIN = 0.0f; | |
406 | float AL_REVERB_MAX_GAIN = 1.0f; | |
407 | float AL_REVERB_DEFAULT_GAIN = 0.32f; | |
408 | float AL_REVERB_MIN_GAINHF = 0.0f; | |
409 | float AL_REVERB_MAX_GAINHF = 1.0f; | |
410 | float AL_REVERB_DEFAULT_GAINHF = 0.89f; | |
411 | float AL_REVERB_MIN_DECAY_TIME = 0.1f; | |
412 | float AL_REVERB_MAX_DECAY_TIME = 20.0f; | |
413 | float AL_REVERB_DEFAULT_DECAY_TIME = 1.49f; | |
414 | float AL_REVERB_MIN_DECAY_HFRATIO = 0.1f; | |
415 | float AL_REVERB_MAX_DECAY_HFRATIO = 2.0f; | |
416 | float AL_REVERB_DEFAULT_DECAY_HFRATIO = 0.83f; | |
417 | float AL_REVERB_MIN_REFLECTIONS_GAIN = 0.0f; | |
418 | float AL_REVERB_MAX_REFLECTIONS_GAIN = 3.16f; | |
419 | float AL_REVERB_DEFAULT_REFLECTIONS_GAIN = 0.05f; | |
420 | float AL_REVERB_MIN_REFLECTIONS_DELAY = 0.0f; | |
421 | float AL_REVERB_MAX_REFLECTIONS_DELAY = 0.3f; | |
422 | float AL_REVERB_DEFAULT_REFLECTIONS_DELAY = 0.007f; | |
423 | float AL_REVERB_MIN_LATE_REVERB_GAIN = 0.0f; | |
424 | float AL_REVERB_MAX_LATE_REVERB_GAIN = 10.0f; | |
425 | float AL_REVERB_DEFAULT_LATE_REVERB_GAIN = 1.26f; | |
426 | float AL_REVERB_MIN_LATE_REVERB_DELAY = 0.0f; | |
427 | float AL_REVERB_MAX_LATE_REVERB_DELAY = 0.1f; | |
428 | float AL_REVERB_DEFAULT_LATE_REVERB_DELAY = 0.011f; | |
429 | float AL_REVERB_MIN_AIR_ABSORPTION_GAINHF = 0.892f; | |
430 | float AL_REVERB_MAX_AIR_ABSORPTION_GAINHF = 1.0f; | |
431 | float AL_REVERB_DEFAULT_AIR_ABSORPTION_GAINHF = 0.994f; | |
432 | float AL_REVERB_MIN_ROOM_ROLLOFF_FACTOR = 0.0f; | |
433 | float AL_REVERB_MAX_ROOM_ROLLOFF_FACTOR = 10.0f; | |
434 | float AL_REVERB_DEFAULT_ROOM_ROLLOFF_FACTOR = 0.0f; | |
435 | int AL_REVERB_MIN_DECAY_HFLIMIT = AL10.AL_FALSE; | |
436 | int AL_REVERB_MAX_DECAY_HFLIMIT = AL10.AL_TRUE; | |
437 | int AL_REVERB_DEFAULT_DECAY_HFLIMIT = AL10.AL_TRUE; | |
438 | // EAX reverb | |
439 | float AL_EAXREVERB_MIN_DENSITY = 0.0f; | |
440 | float AL_EAXREVERB_MAX_DENSITY = 1.0f; | |
441 | float AL_EAXREVERB_DEFAULT_DENSITY = 1.0f; | |
442 | float AL_EAXREVERB_MIN_DIFFUSION = 0.0f; | |
443 | float AL_EAXREVERB_MAX_DIFFUSION = 1.0f; | |
444 | float AL_EAXREVERB_DEFAULT_DIFFUSION = 1.0f; | |
445 | float AL_EAXREVERB_MIN_GAIN = 0.0f; | |
446 | float AL_EAXREVERB_MAX_GAIN = 1.0f; | |
447 | float AL_EAXREVERB_DEFAULT_GAIN = 0.32f; | |
448 | float AL_EAXREVERB_MIN_GAINHF = 0.0f; | |
449 | float AL_EAXREVERB_MAX_GAINHF = 1.0f; | |
450 | float AL_EAXREVERB_DEFAULT_GAINHF = 0.89f; | |
451 | float AL_EAXREVERB_MIN_GAINLF = 0.0f; | |
452 | float AL_EAXREVERB_MAX_GAINLF = 1.0f; | |
453 | float AL_EAXREVERB_DEFAULT_GAINLF = 1.0f; | |
454 | float AL_EAXREVERB_MIN_DECAY_TIME = 0.1f; | |
455 | float AL_EAXREVERB_MAX_DECAY_TIME = 20.0f; | |
456 | float AL_EAXREVERB_DEFAULT_DECAY_TIME = 1.49f; | |
457 | float AL_EAXREVERB_MIN_DECAY_HFRATIO = 0.1f; | |
458 | float AL_EAXREVERB_MAX_DECAY_HFRATIO = 2.0f; | |
459 | float AL_EAXREVERB_DEFAULT_DECAY_HFRATIO = 0.83f; | |
460 | float AL_EAXREVERB_MIN_DECAY_LFRATIO = 0.1f; | |
461 | float AL_EAXREVERB_MAX_DECAY_LFRATIO = 2.0f; | |
462 | float AL_EAXREVERB_DEFAULT_DECAY_LFRATIO = 1.0f; | |
463 | float AL_EAXREVERB_MIN_REFLECTIONS_GAIN = 0.0f; | |
464 | float AL_EAXREVERB_MAX_REFLECTIONS_GAIN = 3.16f; | |
465 | float AL_EAXREVERB_DEFAULT_REFLECTIONS_GAIN = 0.05f; | |
466 | float AL_EAXREVERB_MIN_REFLECTIONS_DELAY = 0.0f; | |
467 | float AL_EAXREVERB_MAX_REFLECTIONS_DELAY = 0.3f; | |
468 | float AL_EAXREVERB_DEFAULT_REFLECTIONS_DELAY = 0.007f; | |
469 | float AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ = 0.0f; | |
470 | float AL_EAXREVERB_MIN_LATE_REVERB_GAIN = 0.0f; | |
471 | float AL_EAXREVERB_MAX_LATE_REVERB_GAIN = 10.0f; | |
472 | float AL_EAXREVERB_DEFAULT_LATE_REVERB_GAIN = 1.26f; | |
473 | float AL_EAXREVERB_MIN_LATE_REVERB_DELAY = 0.0f; | |
474 | float AL_EAXREVERB_MAX_LATE_REVERB_DELAY = 0.1f; | |
475 | float AL_EAXREVERB_DEFAULT_LATE_REVERB_DELAY = 0.011f; | |
476 | float AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ = 0.0f; | |
477 | float AL_EAXREVERB_MIN_ECHO_TIME = 0.075f; | |
478 | float AL_EAXREVERB_MAX_ECHO_TIME = 0.25f; | |
479 | float AL_EAXREVERB_DEFAULT_ECHO_TIME = 0.25f; | |
480 | float AL_EAXREVERB_MIN_ECHO_DEPTH = 0.0f; | |
481 | float AL_EAXREVERB_MAX_ECHO_DEPTH = 1.0f; | |
482 | float AL_EAXREVERB_DEFAULT_ECHO_DEPTH = 0.0f; | |
483 | float AL_EAXREVERB_MIN_MODULATION_TIME = 0.04f; | |
484 | float AL_EAXREVERB_MAX_MODULATION_TIME = 4.0f; | |
485 | float AL_EAXREVERB_DEFAULT_MODULATION_TIME = 0.25f; | |
486 | float AL_EAXREVERB_MIN_MODULATION_DEPTH = 0.0f; | |
487 | float AL_EAXREVERB_MAX_MODULATION_DEPTH = 1.0f; | |
488 | float AL_EAXREVERB_DEFAULT_MODULATION_DEPTH = 0.0f; | |
489 | float AL_EAXREVERB_MIN_AIR_ABSORPTION_GAINHF = 0.892f; | |
490 | float AL_EAXREVERB_MAX_AIR_ABSORPTION_GAINHF = 1.0f; | |
491 | float AL_EAXREVERB_DEFAULT_AIR_ABSORPTION_GAINHF = 0.994f; | |
492 | float AL_EAXREVERB_MIN_HFREFERENCE = 1000.0f; | |
493 | float AL_EAXREVERB_MAX_HFREFERENCE = 20000.0f; | |
494 | float AL_EAXREVERB_DEFAULT_HFREFERENCE = 5000.0f; | |
495 | float AL_EAXREVERB_MIN_LFREFERENCE = 20.0f; | |
496 | float AL_EAXREVERB_MAX_LFREFERENCE = 1000.0f; | |
497 | float AL_EAXREVERB_DEFAULT_LFREFERENCE = 250.0f; | |
498 | float AL_EAXREVERB_MIN_ROOM_ROLLOFF_FACTOR = 0.0f; | |
499 | float AL_EAXREVERB_MAX_ROOM_ROLLOFF_FACTOR = 10.0f; | |
500 | float AL_EAXREVERB_DEFAULT_ROOM_ROLLOFF_FACTOR = 0.0f; | |
501 | int AL_EAXREVERB_MIN_DECAY_HFLIMIT = AL10.AL_FALSE; | |
502 | int AL_EAXREVERB_MAX_DECAY_HFLIMIT = AL10.AL_TRUE; | |
503 | int AL_EAXREVERB_DEFAULT_DECAY_HFLIMIT = AL10.AL_TRUE; | |
504 | // Chorus | |
505 | int AL_CHORUS_WAVEFORM_SINUSOID = 0; | |
506 | int AL_CHORUS_WAVEFORM_TRIANGLE = 1; | |
507 | int AL_CHORUS_MIN_WAVEFORM = 0; | |
508 | int AL_CHORUS_MAX_WAVEFORM = 1; | |
509 | int AL_CHORUS_DEFAULT_WAVEFORM = 1; | |
510 | int AL_CHORUS_MIN_PHASE = -180; | |
511 | int AL_CHORUS_MAX_PHASE = 180; | |
512 | int AL_CHORUS_DEFAULT_PHASE = 90; | |
513 | float AL_CHORUS_MIN_RATE = 0.0f; | |
514 | float AL_CHORUS_MAX_RATE = 10.0f; | |
515 | float AL_CHORUS_DEFAULT_RATE = 1.1f; | |
516 | float AL_CHORUS_MIN_DEPTH = 0.0f; | |
517 | float AL_CHORUS_MAX_DEPTH = 1.0f; | |
518 | float AL_CHORUS_DEFAULT_DEPTH = 0.1f; | |
519 | float AL_CHORUS_MIN_FEEDBACK = -1.0f; | |
520 | float AL_CHORUS_MAX_FEEDBACK = 1.0f; | |
521 | float AL_CHORUS_DEFAULT_FEEDBACK = 0.25f; | |
522 | float AL_CHORUS_MIN_DELAY = 0.0f; | |
523 | float AL_CHORUS_MAX_DELAY = 0.016f; | |
524 | float AL_CHORUS_DEFAULT_DELAY = 0.016f; | |
525 | // Distortion | |
526 | float AL_DISTORTION_MIN_EDGE = 0.0f; | |
527 | float AL_DISTORTION_MAX_EDGE = 1.0f; | |
528 | float AL_DISTORTION_DEFAULT_EDGE = 0.2f; | |
529 | float AL_DISTORTION_MIN_GAIN = 0.01f; | |
530 | float AL_DISTORTION_MAX_GAIN = 1.0f; | |
531 | float AL_DISTORTION_DEFAULT_GAIN = 0.05f; | |
532 | float AL_DISTORTION_MIN_LOWPASS_CUTOFF = 80.0f; | |
533 | float AL_DISTORTION_MAX_LOWPASS_CUTOFF = 24000.0f; | |
534 | float AL_DISTORTION_DEFAULT_LOWPASS_CUTOFF = 8000.0f; | |
535 | float AL_DISTORTION_MIN_EQCENTER = 80.0f; | |
536 | float AL_DISTORTION_MAX_EQCENTER = 24000.0f; | |
537 | float AL_DISTORTION_DEFAULT_EQCENTER = 3600.0f; | |
538 | float AL_DISTORTION_MIN_EQBANDWIDTH = 80.0f; | |
539 | float AL_DISTORTION_MAX_EQBANDWIDTH = 24000.0f; | |
540 | float AL_DISTORTION_DEFAULT_EQBANDWIDTH = 3600.0f; | |
541 | // Echo | |
542 | float AL_ECHO_MIN_DELAY = 0.0f; | |
543 | float AL_ECHO_MAX_DELAY = 0.207f; | |
544 | float AL_ECHO_DEFAULT_DELAY = 0.1f; | |
545 | float AL_ECHO_MIN_LRDELAY = 0.0f; | |
546 | float AL_ECHO_MAX_LRDELAY = 0.404f; | |
547 | float AL_ECHO_DEFAULT_LRDELAY = 0.1f; | |
548 | float AL_ECHO_MIN_DAMPING = 0.0f; | |
549 | float AL_ECHO_MAX_DAMPING = 0.99f; | |
550 | float AL_ECHO_DEFAULT_DAMPING = 0.5f; | |
551 | float AL_ECHO_MIN_FEEDBACK = 0.0f; | |
552 | float AL_ECHO_MAX_FEEDBACK = 1.0f; | |
553 | float AL_ECHO_DEFAULT_FEEDBACK = 0.5f; | |
554 | float AL_ECHO_MIN_SPREAD = -1.0f; | |
555 | float AL_ECHO_MAX_SPREAD = 1.0f; | |
556 | float AL_ECHO_DEFAULT_SPREAD = -1.0f; | |
557 | // Flanger | |
558 | int AL_FLANGER_WAVEFORM_SINUSOID = 0; | |
559 | int AL_FLANGER_WAVEFORM_TRIANGLE = 1; | |
560 | int AL_FLANGER_MIN_WAVEFORM = 0; | |
561 | int AL_FLANGER_MAX_WAVEFORM = 1; | |
562 | int AL_FLANGER_DEFAULT_WAVEFORM = 1; | |
563 | int AL_FLANGER_MIN_PHASE = -180; | |
564 | int AL_FLANGER_MAX_PHASE = 180; | |
565 | int AL_FLANGER_DEFAULT_PHASE = 0; | |
566 | float AL_FLANGER_MIN_RATE = 0.0f; | |
567 | float AL_FLANGER_MAX_RATE = 10.0f; | |
568 | float AL_FLANGER_DEFAULT_RATE = 0.27f; | |
569 | float AL_FLANGER_MIN_DEPTH = 0.0f; | |
570 | float AL_FLANGER_MAX_DEPTH = 1.0f; | |
571 | float AL_FLANGER_DEFAULT_DEPTH = 1.0f; | |
572 | float AL_FLANGER_MIN_FEEDBACK = -1.0f; | |
573 | float AL_FLANGER_MAX_FEEDBACK = 1.0f; | |
574 | float AL_FLANGER_DEFAULT_FEEDBACK = -0.5f; | |
575 | float AL_FLANGER_MIN_DELAY = 0.0f; | |
576 | float AL_FLANGER_MAX_DELAY = 0.004f; | |
577 | float AL_FLANGER_DEFAULT_DELAY = 0.002f; | |
578 | // Frequency shifter | |
579 | float AL_FREQUENCY_SHIFTER_MIN_FREQUENCY = 0.0f; | |
580 | float AL_FREQUENCY_SHIFTER_MAX_FREQUENCY = 24000.0f; | |
581 | float AL_FREQUENCY_SHIFTER_DEFAULT_FREQUENCY = 0.0f; | |
582 | int AL_FREQUENCY_SHIFTER_MIN_LEFT_DIRECTION = 0; | |
583 | int AL_FREQUENCY_SHIFTER_MAX_LEFT_DIRECTION = 2; | |
584 | int AL_FREQUENCY_SHIFTER_DEFAULT_LEFT_DIRECTION = 0; | |
585 | int AL_FREQUENCY_SHIFTER_DIRECTION_DOWN = 0; | |
586 | int AL_FREQUENCY_SHIFTER_DIRECTION_UP = 1; | |
587 | int AL_FREQUENCY_SHIFTER_DIRECTION_OFF = 2; | |
588 | int AL_FREQUENCY_SHIFTER_MIN_RIGHT_DIRECTION = 0; | |
589 | int AL_FREQUENCY_SHIFTER_MAX_RIGHT_DIRECTION = 2; | |
590 | int AL_FREQUENCY_SHIFTER_DEFAULT_RIGHT_DIRECTION = 0; | |
591 | // Vocal morpher | |
592 | int AL_VOCAL_MORPHER_MIN_PHONEMEA = 0; | |
593 | int AL_VOCAL_MORPHER_MAX_PHONEMEA = 29; | |
594 | int AL_VOCAL_MORPHER_DEFAULT_PHONEMEA = 0; | |
595 | int AL_VOCAL_MORPHER_MIN_PHONEMEA_COARSE_TUNING = -24; | |
596 | int AL_VOCAL_MORPHER_MAX_PHONEMEA_COARSE_TUNING = 24; | |
597 | int AL_VOCAL_MORPHER_DEFAULT_PHONEMEA_COARSE_TUNING = 0; | |
598 | int AL_VOCAL_MORPHER_MIN_PHONEMEB = 0; | |
599 | int AL_VOCAL_MORPHER_MAX_PHONEMEB = 29; | |
600 | int AL_VOCAL_MORPHER_DEFAULT_PHONEMEB = 10; | |
601 | int AL_VOCAL_MORPHER_MIN_PHONEMEB_COARSE_TUNING = -24; | |
602 | int AL_VOCAL_MORPHER_MAX_PHONEMEB_COARSE_TUNING = 24; | |
603 | int AL_VOCAL_MORPHER_DEFAULT_PHONEMEB_COARSE_TUNING = 0; | |
604 | int AL_VOCAL_MORPHER_PHONEME_A = 0; | |
605 | int AL_VOCAL_MORPHER_PHONEME_E = 1; | |
606 | int AL_VOCAL_MORPHER_PHONEME_I = 2; | |
607 | int AL_VOCAL_MORPHER_PHONEME_O = 3; | |
608 | int AL_VOCAL_MORPHER_PHONEME_U = 4; | |
609 | int AL_VOCAL_MORPHER_PHONEME_AA = 5; | |
610 | int AL_VOCAL_MORPHER_PHONEME_AE = 6; | |
611 | int AL_VOCAL_MORPHER_PHONEME_AH = 7; | |
612 | int AL_VOCAL_MORPHER_PHONEME_AO = 8; | |
613 | int AL_VOCAL_MORPHER_PHONEME_EH = 9; | |
614 | int AL_VOCAL_MORPHER_PHONEME_ER = 10; | |
615 | int AL_VOCAL_MORPHER_PHONEME_IH = 11; | |
616 | int AL_VOCAL_MORPHER_PHONEME_IY = 12; | |
617 | int AL_VOCAL_MORPHER_PHONEME_UH = 13; | |
618 | int AL_VOCAL_MORPHER_PHONEME_UW = 14; | |
619 | int AL_VOCAL_MORPHER_PHONEME_B = 15; | |
620 | int AL_VOCAL_MORPHER_PHONEME_D = 16; | |
621 | int AL_VOCAL_MORPHER_PHONEME_F = 17; | |
622 | int AL_VOCAL_MORPHER_PHONEME_G = 18; | |
623 | int AL_VOCAL_MORPHER_PHONEME_J = 19; | |
624 | int AL_VOCAL_MORPHER_PHONEME_K = 20; | |
625 | int AL_VOCAL_MORPHER_PHONEME_L = 21; | |
626 | int AL_VOCAL_MORPHER_PHONEME_M = 22; | |
627 | int AL_VOCAL_MORPHER_PHONEME_N = 23; | |
628 | int AL_VOCAL_MORPHER_PHONEME_P = 24; | |
629 | int AL_VOCAL_MORPHER_PHONEME_R = 25; | |
630 | int AL_VOCAL_MORPHER_PHONEME_S = 26; | |
631 | int AL_VOCAL_MORPHER_PHONEME_T = 27; | |
632 | int AL_VOCAL_MORPHER_PHONEME_V = 28; | |
633 | int AL_VOCAL_MORPHER_PHONEME_Z = 29; | |
634 | int AL_VOCAL_MORPHER_WAVEFORM_SINUSOID = 0; | |
635 | int AL_VOCAL_MORPHER_WAVEFORM_TRIANGLE = 1; | |
636 | int AL_VOCAL_MORPHER_WAVEFORM_SAWTOOTH = 2; | |
637 | int AL_VOCAL_MORPHER_MIN_WAVEFORM = 0; | |
638 | int AL_VOCAL_MORPHER_MAX_WAVEFORM = 2; | |
639 | int AL_VOCAL_MORPHER_DEFAULT_WAVEFORM = 0; | |
640 | float AL_VOCAL_MORPHER_MIN_RATE = 0.0f; | |
641 | float AL_VOCAL_MORPHER_MAX_RATE = 10.0f; | |
642 | float AL_VOCAL_MORPHER_DEFAULT_RATE = 1.41f; | |
643 | // Pitch shifter | |
644 | int AL_PITCH_SHIFTER_MIN_COARSE_TUNE = -12; | |
645 | int AL_PITCH_SHIFTER_MAX_COARSE_TUNE = 12; | |
646 | int AL_PITCH_SHIFTER_DEFAULT_COARSE_TUNE = 12; | |
647 | int AL_PITCH_SHIFTER_MIN_FINE_TUNE = -50; | |
648 | int AL_PITCH_SHIFTER_MAX_FINE_TUNE = 50; | |
649 | int AL_PITCH_SHIFTER_DEFAULT_FINE_TUNE = 0; | |
650 | // Ring modulator | |
651 | float AL_RING_MODULATOR_MIN_FREQUENCY = 0.0f; | |
652 | float AL_RING_MODULATOR_MAX_FREQUENCY = 8000.0f; | |
653 | float AL_RING_MODULATOR_DEFAULT_FREQUENCY = 440.0f; | |
654 | float AL_RING_MODULATOR_MIN_HIGHPASS_CUTOFF = 0.0f; | |
655 | float AL_RING_MODULATOR_MAX_HIGHPASS_CUTOFF = 24000.0f; | |
656 | float AL_RING_MODULATOR_DEFAULT_HIGHPASS_CUTOFF = 800.0f; | |
657 | int AL_RING_MODULATOR_SINUSOID = 0; | |
658 | int AL_RING_MODULATOR_SAWTOOTH = 1; | |
659 | int AL_RING_MODULATOR_SQUARE = 2; | |
660 | int AL_RING_MODULATOR_MIN_WAVEFORM = 0; | |
661 | int AL_RING_MODULATOR_MAX_WAVEFORM = 2; | |
662 | int AL_RING_MODULATOR_DEFAULT_WAVEFORM = 0; | |
663 | // Autowah | |
664 | float AL_AUTOWAH_MIN_ATTACK_TIME = 0.0001f; | |
665 | float AL_AUTOWAH_MAX_ATTACK_TIME = 1.0f; | |
666 | float AL_AUTOWAH_DEFAULT_ATTACK_TIME = 0.06f; | |
667 | float AL_AUTOWAH_MIN_RELEASE_TIME = 0.0001f; | |
668 | float AL_AUTOWAH_MAX_RELEASE_TIME = 1.0f; | |
669 | float AL_AUTOWAH_DEFAULT_RELEASE_TIME = 0.06f; | |
670 | float AL_AUTOWAH_MIN_RESONANCE = 2.0f; | |
671 | float AL_AUTOWAH_MAX_RESONANCE = 1000.0f; | |
672 | float AL_AUTOWAH_DEFAULT_RESONANCE = 1000.0f; | |
673 | float AL_AUTOWAH_MIN_PEAK_GAIN = 0.00003f; | |
674 | float AL_AUTOWAH_MAX_PEAK_GAIN = 31621.0f; | |
675 | float AL_AUTOWAH_DEFAULT_PEAK_GAIN = 11.22f; | |
676 | // Compressor | |
677 | int AL_COMPRESSOR_MIN_ONOFF = 0; | |
678 | int AL_COMPRESSOR_MAX_ONOFF = 1; | |
679 | int AL_COMPRESSOR_DEFAULT_ONOFF = 1; | |
680 | // Equalizer | |
681 | float AL_EQUALIZER_MIN_LOW_GAIN = 0.126f; | |
682 | float AL_EQUALIZER_MAX_LOW_GAIN = 7.943f; | |
683 | float AL_EQUALIZER_DEFAULT_LOW_GAIN = 1.0f; | |
684 | float AL_EQUALIZER_MIN_LOW_CUTOFF = 50.0f; | |
685 | float AL_EQUALIZER_MAX_LOW_CUTOFF = 800.0f; | |
686 | float AL_EQUALIZER_DEFAULT_LOW_CUTOFF = 200.0f; | |
687 | float AL_EQUALIZER_MIN_MID1_GAIN = 0.126f; | |
688 | float AL_EQUALIZER_MAX_MID1_GAIN = 7.943f; | |
689 | float AL_EQUALIZER_DEFAULT_MID1_GAIN = 1.0f; | |
690 | float AL_EQUALIZER_MIN_MID1_CENTER = 200.0f; | |
691 | float AL_EQUALIZER_MAX_MID1_CENTER = 3000.0f; | |
692 | float AL_EQUALIZER_DEFAULT_MID1_CENTER = 500.0f; | |
693 | float AL_EQUALIZER_MIN_MID1_WIDTH = 0.01f; | |
694 | float AL_EQUALIZER_MAX_MID1_WIDTH = 1.0f; | |
695 | float AL_EQUALIZER_DEFAULT_MID1_WIDTH = 1.0f; | |
696 | float AL_EQUALIZER_MIN_MID2_GAIN = 0.126f; | |
697 | float AL_EQUALIZER_MAX_MID2_GAIN = 7.943f; | |
698 | float AL_EQUALIZER_DEFAULT_MID2_GAIN = 1.0f; | |
699 | float AL_EQUALIZER_MIN_MID2_CENTER = 1000.0f; | |
700 | float AL_EQUALIZER_MAX_MID2_CENTER = 8000.0f; | |
701 | float AL_EQUALIZER_DEFAULT_MID2_CENTER = 3000.0f; | |
702 | float AL_EQUALIZER_MIN_MID2_WIDTH = 0.01f; | |
703 | float AL_EQUALIZER_MAX_MID2_WIDTH = 1.0f; | |
704 | float AL_EQUALIZER_DEFAULT_MID2_WIDTH = 1.0f; | |
705 | float AL_EQUALIZER_MIN_HIGH_GAIN = 0.126f; | |
706 | float AL_EQUALIZER_MAX_HIGH_GAIN = 7.943f; | |
707 | float AL_EQUALIZER_DEFAULT_HIGH_GAIN = 1.0f; | |
708 | float AL_EQUALIZER_MIN_HIGH_CUTOFF = 4000.0f; | |
709 | float AL_EQUALIZER_MAX_HIGH_CUTOFF = 16000.0f; | |
710 | float AL_EQUALIZER_DEFAULT_HIGH_CUTOFF = 6000.0f; | |
711 | ||
712 | // Filter parameter ranges and defaults | |
713 | // Lowpass | |
714 | float LOWPASS_MIN_GAIN = 0.0f; | |
715 | float LOWPASS_MAX_GAIN = 1.0f; | |
716 | float LOWPASS_DEFAULT_GAIN = 1.0f; | |
717 | float LOWPASS_MIN_GAINHF = 0.0f; | |
718 | float LOWPASS_MAX_GAINHF = 1.0f; | |
719 | float LOWPASS_DEFAULT_GAINHF = 1.0f; | |
720 | // Highpass | |
721 | float HIGHPASS_MIN_GAIN = 0.0f; | |
722 | float HIGHPASS_MAX_GAIN = 1.0f; | |
723 | float HIGHPASS_DEFAULT_GAIN = 1.0f; | |
724 | float HIGHPASS_MIN_GAINLF = 0.0f; | |
725 | float HIGHPASS_MAX_GAINLF = 1.0f; | |
726 | float HIGHPASS_DEFAULT_GAINLF = 1.0f; | |
727 | // Bandpass | |
728 | float BANDPASS_MIN_GAIN = 0.0f; | |
729 | float BANDPASS_MAX_GAIN = 1.0f; | |
730 | float BANDPASS_DEFAULT_GAIN = 1.0f; | |
731 | float BANDPASS_MIN_GAINHF = 0.0f; | |
732 | float BANDPASS_MAX_GAINHF = 1.0f; | |
733 | float BANDPASS_DEFAULT_GAINHF = 1.0f; | |
734 | float BANDPASS_MIN_GAINLF = 0.0f; | |
735 | float BANDPASS_MAX_GAINLF = 1.0f; | |
736 | float BANDPASS_DEFAULT_GAINLF = 1.0f; | |
737 | } |
0 | /* | |
1 | * Copyright (c) 2002-2008 LWJGL Project | |
2 | * All rights reserved. | |
3 | * | |
4 | * Redistribution and use in source and binary forms, with or without | |
5 | * modification, are permitted provided that the following conditions are | |
6 | * met: | |
7 | * | |
8 | * * Redistributions of source code must retain the above copyright | |
9 | * notice, this list of conditions and the following disclaimer. | |
10 | * | |
11 | * * Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | |
14 | * | |
15 | * * Neither the name of 'LWJGL' nor the names of | |
16 | * its contributors may be used to endorse or promote products derived | |
17 | * from this software without specific prior written permission. | |
18 | * | |
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | |
23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
24 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
25 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
26 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | |
27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | |
31 | package org.lwjgl.opengl; | |
32 | ||
33 | import org.lwjgl.util.generator.*; | |
34 | ||
35 | import java.nio.ByteBuffer; | |
36 | import java.nio.IntBuffer; | |
37 | ||
38 | @Alias(value = "AMDX_debug_output", postfix = "X") | |
39 | public interface AMD_debug_output { | |
40 | ||
41 | /** Tokens accepted by GetIntegerv: */ | |
42 | int GL_MAX_DEBUG_MESSAGE_LENGTH_AMD = 0x9143, | |
43 | GL_MAX_DEBUG_LOGGED_MESSAGES_AMD = 0x9144, | |
44 | GL_DEBUG_LOGGED_MESSAGES_AMD = 0x9145; | |
45 | ||
46 | /** | |
47 | * Tokens accepted by DebugMessageEnableAMD, GetDebugMessageLogAMD, | |
48 | * DebugMessageInsertAMD, and DEBUGPROCAMD callback function | |
49 | * for <severity>: | |
50 | */ | |
51 | int GL_DEBUG_SEVERITY_HIGH_AMD = 0x9146, | |
52 | GL_DEBUG_SEVERITY_MEDIUM_AMD = 0x9147, | |
53 | GL_DEBUG_SEVERITY_LOW_AMD = 0x9148; | |
54 | ||
55 | /** | |
56 | * Tokens accepted by DebugMessageEnableAMD, GetDebugMessageLogAMD, | |
57 | * and DEBUGPROCAMD callback function for <category>: | |
58 | */ | |
59 | int GL_DEBUG_CATEGORY_API_ERROR_AMD = 0x9149, | |
60 | GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD = 0x914A, | |
61 | GL_DEBUG_CATEGORY_DEPRECATION_AMD = 0x914B, | |
62 | GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD = 0x914C, | |
63 | GL_DEBUG_CATEGORY_PERFORMANCE_AMD = 0x914D, | |
64 | GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD = 0x914E, | |
65 | GL_DEBUG_CATEGORY_APPLICATION_AMD = 0x914F, | |
66 | GL_DEBUG_CATEGORY_OTHER_AMD = 0x9150; | |
67 | ||
68 | void glDebugMessageEnableAMD(@GLenum int category, @GLenum int severity, @AutoSize(value = "ids", canBeNull = true) @GLsizei int count, @Check(canBeNull = true) @Const @GLuint IntBuffer ids, boolean enabled); | |
69 | ||
70 | void glDebugMessageInsertAMD(@GLenum int category, @GLenum int severity, @GLuint int id, @AutoSize("buf") @GLsizei int length, @Const @GLchar ByteBuffer buf); | |
71 | ||
72 | @Alternate("glDebugMessageInsertAMD") | |
73 | void glDebugMessageInsertAMD(@GLenum int category, @GLenum int severity, @GLuint int id, @Constant("buf.length()") @GLsizei int length, CharSequence buf); | |
74 | ||
75 | /** | |
76 | * The {@code AMDDebugOutputCallback.Handler} implementation passed to this method will be used for | |
77 | * AMD_debug_output messages. If callback is null, any previously registered handler for the current | |
78 | * thread will be unregistered and stop receiving messages. | |
79 | * <p/> | |
80 | * The userParam buffer will be passed to the GL, but the current implementation will ignore it and | |
81 | * never return it to the handler. Instead, users are encouraged to use a custom callback handler | |
82 | * implentation to store context-specific data. | |
83 | * | |
84 | * @param callback the callback function to use | |
85 | * @param userParam the user-specified data | |
86 | */ | |
87 | void glDebugMessageCallbackAMD(@GLpointer(value = "GLDEBUGPROCAMD", canBeNull = true) AMDDebugOutputCallback callback, @Check(canBeNull = true) @GLvoid ByteBuffer userParam); | |
88 | ||
89 | @GLuint | |
90 | int glGetDebugMessageLogAMD(@GLuint int count, | |
91 | @AutoSize(value = "messageLog", canBeNull = true) @GLsizei int logSize, | |
92 | @Check(value = "count", canBeNull = true) @GLenum IntBuffer categories, | |
93 | @Check(value = "count", canBeNull = true) @GLuint IntBuffer severities, | |
94 | @Check(value = "count", canBeNull = true) @GLuint IntBuffer ids, | |
95 | @Check(value = "count", canBeNull = true) @GLsizei IntBuffer lengths, | |
96 | @Check(canBeNull = true) @OutParameter @GLchar ByteBuffer messageLog); | |
97 | ||
98 | }⏎ |
0 | /* | |
1 | * Copyright (c) 2002-2008 LWJGL Project | |
2 | * All rights reserved. | |
3 | * | |
4 | * Redistribution and use in source and binary forms, with or without | |
5 | * modification, are permitted provided that the following conditions are | |
6 | * met: | |
7 | * | |
8 | * * Redistributions of source code must retain the above copyright | |
9 | * notice, this list of conditions and the following disclaimer. | |
10 | * | |
11 | * * Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | |
14 | * | |
15 | * * Neither the name of 'LWJGL' nor the names of | |
16 | * its contributors may be used to endorse or promote products derived | |
17 | * from this software without specific prior written permission. | |
18 | * | |
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | |
23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
24 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
25 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
26 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | |
27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | |
31 | package org.lwjgl.opengl; | |
32 | ||
33 | import org.lwjgl.util.generator.*; | |
34 | ||
35 | import java.nio.IntBuffer; | |
36 | ||
37 | public interface AMD_name_gen_delete { | |
38 | ||
39 | /** Accepted as the <identifier> parameter of GenNamesAMD and DeleteNamesAMD: */ | |
40 | int GL_DATA_BUFFER_AMD = 0x9151, | |
41 | GL_PERFORMANCE_MONITOR_AMD = 0x9152, | |
42 | GL_QUERY_OBJECT_AMD = 0x9153, | |
43 | GL_VERTEX_ARRAY_OBJECT_AMD = 0x9154, | |
44 | GL_SAMPLER_OBJECT_AMD = 0x9155; | |
45 | ||
46 | void glGenNamesAMD(@GLenum int identifier, @AutoSize("names") @GLuint int num, @OutParameter @GLuint IntBuffer names); | |
47 | ||
48 | @Alternate("glGenNamesAMD") | |
49 | @GLreturn("names") | |
50 | void glGenNamesAMD2(@GLenum int identifier, @Constant("1") @GLsizei int num, @OutParameter @GLuint IntBuffer names); | |
51 | ||
52 | void glDeleteNamesAMD(@GLenum int identifier, @AutoSize("names") @GLsizei int num, @Const @GLuint IntBuffer names); | |
53 | ||
54 | @Alternate("glDeleteNamesAMD") | |
55 | void glDeleteNamesAMD(@GLenum int identifier, @Constant("1") @GLsizei int num, @Constant(value = "APIUtils.getBufferInt().put(0, name), 0", keepParam = true) int name); | |
56 | ||
57 | boolean glIsNameAMD(@GLenum int identifier, @GLuint int name); | |
58 | ||
59 | }⏎ |
0 | /* | |
1 | * Copyright (c) 2002-2008 LWJGL Project | |
2 | * All rights reserved. | |
3 | * | |
4 | * Redistribution and use in source and binary forms, with or without | |
5 | * modification, are permitted provided that the following conditions are | |
6 | * met: | |
7 | * | |
8 | * * Redistributions of source code must retain the above copyright | |
9 | * notice, this list of conditions and the following disclaimer. | |
10 | * | |
11 | * * Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | |
14 | * | |
15 | * * Neither the name of 'LWJGL' nor the names of | |
16 | * its contributors may be used to endorse or promote products derived | |
17 | * from this software without specific prior written permission. | |
18 | * | |
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | |
23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
24 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
25 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
26 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | |
27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | |
31 | package org.lwjgl.opengl; | |
32 | ||
33 | public interface AMD_transform_feedback3_lines_triangles { | |
34 | ||
35 | }⏎ |
30 | 30 | */ |
31 | 31 | package org.lwjgl.opengl; |
32 | 32 | |
33 | import org.lwjgl.util.generator.Alias; | |
34 | ||
35 | @Alias("EXT_texture_buffer_object_rgb32") | |
33 | 36 | public interface ARB_texture_buffer_object_rgb32 { |
34 | 37 | }⏎ |
30 | 30 | */ |
31 | 31 | package org.lwjgl.opengl; |
32 | 32 | |
33 | import org.lwjgl.util.generator.Alias; | |
33 | 34 | import org.lwjgl.util.generator.Extension; |
34 | 35 | |
35 | 36 | @Extension(postfix = "ARB", className = "ARBTextureCompressionBPTC") |
37 | @Alias("EXT_texture_compression_bptc") | |
36 | 38 | public interface ARB_texture_compression_bptc { |
37 | 39 | |
38 | 40 | /** |
70 | 70 | @StripPostfix("params") |
71 | 71 | void glGetObjectBufferivATI(@GLuint int buffer, @GLenum int pname, @OutParameter @Check IntBuffer params); |
72 | 72 | |
73 | @Alternate("glGetObjectBufferivATI") | |
74 | @GLreturn("params") | |
75 | @StripPostfix("params") | |
76 | void glGetObjectBufferivATI2(@GLuint int buffer, @GLenum int pname, @OutParameter IntBuffer params); | |
77 | ||
73 | 78 | void glFreeObjectBufferATI(@GLuint int buffer); |
74 | 79 | |
75 | 80 | void glArrayObjectATI(@GLenum int array, int size, @GLenum int type, @GLsizei int stride, @GLuint int buffer, @GLuint int offset); |
518 | 518 | value parameters |
519 | 519 | */ |
520 | 520 | |
521 | @Optional(reason = "AMD does not expose this (last driver checked: 10.3)") | |
521 | @Optional(reason = "AMD does not expose this (last driver checked: 10.5)") | |
522 | 522 | @Dependent("OpenGL30") |
523 | 523 | void glEnableClientStateiEXT(@GLenum int array, @GLuint int index); |
524 | 524 | |
525 | @Optional(reason = "AMD does not expose this (last driver checked: 10.3)") | |
525 | @Optional(reason = "AMD does not expose this (last driver checked: 10.5)") | |
526 | 526 | @Dependent("OpenGL30") |
527 | 527 | void glDisableClientStateiEXT(@GLenum int array, @GLuint int index); |
528 | 528 | |
564 | 564 | and before state value parameters |
565 | 565 | */ |
566 | 566 | |
567 | @Optional(reason = "AMD does not expose this (last driver checked: 10.3)") | |
567 | @Optional(reason = "AMD does not expose this (last driver checked: 10.5)") | |
568 | 568 | @Dependent("OpenGL30") |
569 | 569 | @StripPostfix("params") |
570 | 570 | void glGetFloati_vEXT(@GLenum int pname, @GLuint int index, @OutParameter @Check("16") FloatBuffer params); |
575 | 575 | @StripPostfix("params") |
576 | 576 | void glGetFloati_vEXT2(@GLenum int pname, @GLuint int index, @OutParameter FloatBuffer params); |
577 | 577 | |
578 | @Optional(reason = "AMD does not expose this (last driver checked: 10.3)") | |
578 | @Optional(reason = "AMD does not expose this (last driver checked: 10.5)") | |
579 | 579 | @Dependent("OpenGL30") |
580 | 580 | @StripPostfix("params") |
581 | 581 | void glGetDoublei_vEXT(@GLenum int pname, @GLuint int index, @OutParameter @Check("16") DoubleBuffer params); |
586 | 586 | @StripPostfix("params") |
587 | 587 | void glGetDoublei_vEXT2(@GLenum int pname, @GLuint int index, @OutParameter DoubleBuffer params); |
588 | 588 | |
589 | @Optional(reason = "AMD does not expose this (last driver checked: 10.3)") | |
589 | @Optional(reason = "AMD does not expose this (last driver checked: 10.5)") | |
590 | 590 | @Dependent("OpenGL30") |
591 | 591 | @StripPostfix(value = "params", hasPostfix = false) |
592 | 592 | void glGetPointeri_vEXT(@GLenum int pname, @GLuint int index, @Result @GLvoid ByteBuffer params); |
1342 | 1342 | OpenGL 3.1: New buffer data copy command |
1343 | 1343 | */ |
1344 | 1344 | |
1345 | @Optional(reason = "AMD does not expose this (last driver checked: 10.5)") | |
1345 | 1346 | @Dependent("OpenGL31,GL_ARB_copy_buffer") |
1346 | 1347 | void glNamedCopyBufferSubDataEXT(@GLuint int readBuffer, @GLuint int writeBuffer, @GLintptr long readoffset, @GLintptr long writeoffset, @GLsizeiptr long size); |
1347 | 1348 | |
1385 | 1386 | and change the final parameter from "const void *" to "intptr offset" |
1386 | 1387 | */ |
1387 | 1388 | |
1389 | @Optional(reason = "AMD does not expose this (last driver checked: 10.5)") | |
1388 | 1390 | @Dependent("OpenGL30") |
1389 | 1391 | @DeprecatedGL |
1390 | 1392 | void glVertexArrayVertexOffsetEXT(@GLuint int vaobj, @GLuint int buffer, int size, @GLenum int type, @GLsizei int stride, @GLintptr long offset); |
1391 | 1393 | |
1394 | @Optional(reason = "AMD does not expose this (last driver checked: 10.5)") | |
1392 | 1395 | @Dependent("OpenGL30") |
1393 | 1396 | @DeprecatedGL |
1394 | 1397 | void glVertexArrayColorOffsetEXT(@GLuint int vaobj, @GLuint int buffer, int size, @GLenum int type, @GLsizei int stride, @GLintptr long offset); |
1395 | 1398 | |
1399 | @Optional(reason = "AMD does not expose this (last driver checked: 10.5)") | |
1396 | 1400 | @Dependent("OpenGL30") |
1397 | 1401 | @DeprecatedGL |
1398 | 1402 | void glVertexArrayEdgeFlagOffsetEXT(@GLuint int vaobj, @GLuint int buffer, @GLsizei int stride, @GLintptr long offset); |
1399 | 1403 | |
1404 | @Optional(reason = "AMD does not expose this (last driver checked: 10.5)") | |
1400 | 1405 | @Dependent("OpenGL30") |
1401 | 1406 | void glVertexArrayIndexOffsetEXT(@GLuint int vaobj, @GLuint int buffer, @GLenum int type, @GLsizei int stride, @GLintptr long offset); |
1402 | 1407 | |
1408 | @Optional(reason = "AMD does not expose this (last driver checked: 10.5)") | |
1403 | 1409 | @Dependent("OpenGL30") |
1404 | 1410 | @DeprecatedGL |
1405 | 1411 | void glVertexArrayNormalOffsetEXT(@GLuint int vaobj, @GLuint int buffer, @GLenum int type, @GLsizei int stride, @GLintptr long offset); |
1406 | 1412 | |
1413 | @Optional(reason = "AMD does not expose this (last driver checked: 10.5)") | |
1407 | 1414 | @Dependent("OpenGL30") |
1408 | 1415 | @DeprecatedGL |
1409 | 1416 | void glVertexArrayTexCoordOffsetEXT(@GLuint int vaobj, @GLuint int buffer, int size, @GLenum int type, @GLsizei int stride, @GLintptr long offset); |
1410 | 1417 | |
1418 | @Optional(reason = "AMD does not expose this (last driver checked: 10.5)") | |
1411 | 1419 | @Dependent("OpenGL30") |
1412 | 1420 | @DeprecatedGL |
1413 | 1421 | void glVertexArrayMultiTexCoordOffsetEXT(@GLuint int vaobj, @GLuint int buffer, @GLenum int texunit, int size, @GLenum int type, @GLsizei int stride, @GLintptr long offset); |
1414 | 1422 | |
1423 | @Optional(reason = "AMD does not expose this (last driver checked: 10.5)") | |
1415 | 1424 | @Dependent("OpenGL30") |
1416 | 1425 | @DeprecatedGL |
1417 | 1426 | void glVertexArrayFogCoordOffsetEXT(@GLuint int vaobj, @GLuint int buffer, @GLenum int type, @GLsizei int stride, @GLintptr long offset); |
1418 | 1427 | |
1428 | @Optional(reason = "AMD does not expose this (last driver checked: 10.5)") | |
1419 | 1429 | @Dependent("OpenGL30") |
1420 | 1430 | @DeprecatedGL |
1421 | 1431 | void glVertexArraySecondaryColorOffsetEXT(@GLuint int vaobj, @GLuint int buffer, int size, @GLenum int type, @GLsizei int stride, @GLintptr long offset); |
1422 | 1432 | |
1433 | @Optional(reason = "AMD does not expose this (last driver checked: 10.5)") | |
1423 | 1434 | @Dependent("OpenGL30") |
1424 | 1435 | void glVertexArrayVertexAttribOffsetEXT(@GLuint int vaobj, @GLuint int buffer, @GLuint int index, int size, @GLenum int type, boolean normalized, @GLsizei int stride, @GLintptr long offset); |
1425 | 1436 | |
1437 | @Optional(reason = "AMD does not expose this (last driver checked: 10.5)") | |
1426 | 1438 | @Dependent("OpenGL30") |
1427 | 1439 | void glVertexArrayVertexAttribIOffsetEXT(@GLuint int vaobj, @GLuint int buffer, @GLuint int index, int size, @GLenum int type, @GLsizei int stride, @GLintptr long offset); |
1428 | 1440 | |
1432 | 1444 | "uint vaobj" parameter |
1433 | 1445 | */ |
1434 | 1446 | |
1447 | @Optional(reason = "AMD does not expose this (last driver checked: 10.5)") | |
1435 | 1448 | @Dependent("OpenGL30") |
1436 | 1449 | void glEnableVertexArrayEXT(@GLuint int vaobj, @GLenum int array); |
1437 | 1450 | |
1451 | @Optional(reason = "AMD does not expose this (last driver checked: 10.5)") | |
1438 | 1452 | @Dependent("OpenGL30") |
1439 | 1453 | void glDisableVertexArrayEXT(@GLuint int vaobj, @GLenum int array); |
1440 | 1454 | |
1444 | 1458 | and add an initial "uint vaobj" parameter |
1445 | 1459 | */ |
1446 | 1460 | |
1461 | @Optional(reason = "AMD does not expose this (last driver checked: 10.5)") | |
1447 | 1462 | @Dependent("OpenGL30") |
1448 | 1463 | void glEnableVertexArrayAttribEXT(@GLuint int vaobj, @GLuint int index); |
1449 | 1464 | |
1465 | @Optional(reason = "AMD does not expose this (last driver checked: 10.5)") | |
1450 | 1466 | @Dependent("OpenGL30") |
1451 | 1467 | void glDisableVertexArrayAttribEXT(@GLuint int vaobj, @GLuint int index); |
1452 | 1468 | |
1454 | 1470 | OpenGL 3.0: New queries for vertex array objects |
1455 | 1471 | */ |
1456 | 1472 | |
1473 | @Optional(reason = "AMD does not expose this (last driver checked: 10.5)") | |
1457 | 1474 | @Dependent("OpenGL30") |
1458 | 1475 | @StripPostfix("param") |
1459 | 1476 | void glGetVertexArrayIntegervEXT(@GLuint int vaobj, @GLenum int pname, @OutParameter @Check("16") IntBuffer param); |
1464 | 1481 | @StripPostfix("param") |
1465 | 1482 | void glGetVertexArrayIntegervEXT2(@GLuint int vaobj, @GLenum int pname, @OutParameter IntBuffer param); |
1466 | 1483 | |
1484 | @Optional(reason = "AMD does not expose this (last driver checked: 10.5)") | |
1467 | 1485 | @Dependent("OpenGL30") |
1468 | 1486 | @StripPostfix("param") |
1469 | 1487 | void glGetVertexArrayPointervEXT(@GLuint int vaobj, @GLenum int pname, @Result @GLvoid ByteBuffer param); |
1470 | 1488 | |
1489 | @Optional(reason = "AMD does not expose this (last driver checked: 10.5)") | |
1471 | 1490 | @Dependent("OpenGL30") |
1472 | 1491 | @StripPostfix(value = "param") |
1473 | 1492 | void glGetVertexArrayIntegeri_vEXT(@GLuint int vaobj, @GLuint int index, @GLenum int pname, @OutParameter @Check("16") IntBuffer param); |
1478 | 1497 | @StripPostfix(value = "param", postfix = "_v") |
1479 | 1498 | void glGetVertexArrayIntegeri_vEXT2(@GLuint int vaobj, @GLuint int index, @GLenum int pname, @OutParameter IntBuffer param); |
1480 | 1499 | |
1500 | @Optional(reason = "AMD does not expose this (last driver checked: 10.5)") | |
1481 | 1501 | @Dependent("OpenGL30") |
1482 | 1502 | @StripPostfix(value = "param") |
1483 | 1503 | void glGetVertexArrayPointeri_vEXT(@GLuint int vaobj, @GLuint int index, @GLenum int pname, @Result @GLvoid ByteBuffer param); |
1501 | 1521 | * |
1502 | 1522 | * @return A ByteBuffer representing the mapped buffer memory. |
1503 | 1523 | */ |
1524 | @Optional(reason = "AMD does not expose this (last driver checked: 10.5)") | |
1504 | 1525 | @Dependent("OpenGL30") |
1505 | 1526 | @CachedResult(isRange = true) |
1506 | 1527 | @GLvoid |
1507 | 1528 | @AutoResultSize("length") |
1508 | 1529 | ByteBuffer glMapNamedBufferRangeEXT(@GLuint int buffer, @GLintptr long offset, @GLsizeiptr long length, @GLbitfield int access); |
1509 | 1530 | |
1531 | @Optional(reason = "AMD does not expose this (last driver checked: 10.5)") | |
1510 | 1532 | @Dependent("OpenGL30") |
1511 | 1533 | void glFlushMappedNamedBufferRangeEXT(@GLuint int buffer, @GLintptr long offset, @GLsizeiptr long length); |
1512 | 1534 |
38 | 38 | * The core OpenGL1.1 API. |
39 | 39 | * |
40 | 40 | * @author cix_foo <cix_foo@users.sourceforge.net> |
41 | * @version $Revision: 3316 $ | |
42 | * $Id: GL11.java 3316 2010-04-09 23:57:40Z spasi $ | |
41 | * @version $Revision: 3338 $ | |
42 | * $Id: GL11.java 3338 2010-05-01 09:19:00Z spasi $ | |
43 | 43 | */ |
44 | 44 | @DeprecatedGL |
45 | 45 | public interface GL11 { |
1146 | 1146 | String glGetString(int name); |
1147 | 1147 | |
1148 | 1148 | @DeprecatedGL |
1149 | void glGetPolygonStipple(@OutParameter @BufferObject(BufferKind.PackPBO) @Check("1024") @GLubyte ByteBuffer mask); | |
1149 | void glGetPolygonStipple(@OutParameter @BufferObject(BufferKind.PackPBO) @Check("128") @GLubyte ByteBuffer mask); | |
1150 | 1150 | |
1151 | 1151 | @DeprecatedGL |
1152 | 1152 | boolean glIsList(@GLuint int list); |
1251 | 1251 | void glMatrixMode(@GLenum int mode); |
1252 | 1252 | |
1253 | 1253 | @DeprecatedGL |
1254 | void glPolygonStipple(@BufferObject(BufferKind.UnpackPBO) @Check("1024") @Const @GLubyte ByteBuffer mask); | |
1254 | void glPolygonStipple(@BufferObject(BufferKind.UnpackPBO) @Check("128") @Const @GLubyte ByteBuffer mask); | |
1255 | 1255 | |
1256 | 1256 | void glPolygonOffset(float factor, float units); |
1257 | 1257 |
73 | 73 | int GL_BUFFER_MAPPED = 0x88BC; |
74 | 74 | int GL_BUFFER_MAP_POINTER = 0x88BD; |
75 | 75 | |
76 | int FOG_COORD_SRC = GL14.GL_FOG_COORDINATE_SOURCE; | |
76 | int GL_FOG_COORD_SRC = GL14.GL_FOG_COORDINATE_SOURCE; | |
77 | 77 | int GL_FOG_COORD = GL14.GL_FOG_COORDINATE; |
78 | 78 | int GL_CURRENT_FOG_COORD = GL14.GL_CURRENT_FOG_COORDINATE; |
79 | 79 | int GL_FOG_COORD_ARRAY_TYPE = GL14.GL_FOG_COORDINATE_ARRAY_TYPE; |
41 | 41 | |
42 | 42 | void glGenFencesNV(@AutoSize("piFences") @GLsizei int n, @OutParameter @GLuint IntBuffer piFences); |
43 | 43 | |
44 | @Alternate("glGenFencesNV") | |
45 | @GLreturn("piFences") | |
46 | void glGenFencesNV2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer piFences); | |
47 | ||
44 | 48 | void glDeleteFencesNV(@AutoSize("piFences") @GLsizei int n, @Const @GLuint IntBuffer piFences); |
49 | ||
50 | @Alternate("glDeleteFencesNV") | |
51 | void glDeleteFencesNV(@Constant("1") @GLsizei int n, @Const @GLuint @Constant(value = "APIUtils.getBufferInt().put(0, fence), 0", keepParam = true) int fence); | |
45 | 52 | |
46 | 53 | void glSetFenceNV(@GLuint int fence, @GLenum int condition); |
47 | 54 |
0 | /* | |
1 | * Copyright (c) 2002-2008 LWJGL Project | |
2 | * All rights reserved. | |
3 | * | |
4 | * Redistribution and use in source and binary forms, with or without | |
5 | * modification, are permitted provided that the following conditions are | |
6 | * met: | |
7 | * | |
8 | * * Redistributions of source code must retain the above copyright | |
9 | * notice, this list of conditions and the following disclaimer. | |
10 | * | |
11 | * * Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | |
14 | * | |
15 | * * Neither the name of 'LWJGL' nor the names of | |
16 | * its contributors may be used to endorse or promote products derived | |
17 | * from this software without specific prior written permission. | |
18 | * | |
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | |
23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
24 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
25 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
26 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | |
27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | |
31 | package org.lwjgl.opengl; | |
32 | ||
33 | public interface NV_multisample_coverage { | |
34 | ||
35 | /** | |
36 | * Accepted by the <pname> parameter of GetBooleanv, GetDoublev, | |
37 | * GetIntegerv, and GetFloatv: | |
38 | */ | |
39 | int GL_COVERAGE_SAMPLES_NV = 0x80A9; | |
40 | int GL_COLOR_SAMPLES_NV = 0x8E20; | |
41 | ||
42 | }⏎ |