Codebase list lwjgl / afc97ed
Imported Upstream version 2.5+dfsg Gabriele Giacone 13 years ago
76 changed file(s) with 4261 addition(s) and 800 deletion(s). Raw diff Collapse all Expand all
123123 <fileset refid="lwjgl.fileset" />
124124 <manifest>
125125 <attribute name="Sealed" value="true"/>
126 <attribute name="Trusted-Library" value="true"/>
127126 </manifest>
128127 </jar>
129128
132131 <fileset refid="lwjgl_util_applet.fileset" />
133132 <manifest>
134133 <attribute name="Sealed" value="true"/>
135 <attribute name="Trusted-Library" value="true"/>
136134 </manifest>
137135 </jar>
138136
252250 <class name="org.lwjgl.openal.AL" />
253251 <class name="org.lwjgl.opengl.GLContext" />
254252 <class name="org.lwjgl.opengl.Pbuffer" />
253 <class name="org.lwjgl.opengl.AMDDebugOutputCallback" />
255254 </javah>
256255 </target>
257256
1111 <property name="lwjgl.docs" location="doc" />
1212 <property name="lwjgl.temp" location="temp" />
1313 <property name="lwjgl.res" location="res" />
14 <property name="lwjgl.version" value="2.4.2" />
14 <property name="lwjgl.version" value="2.5" />
1515
1616 <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"/>
1717 <!-- ================================================================== -->
1212 <javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" includes="org/lwjgl/util/generator/**.java" source="1.5" target="1.5" taskname="generator">
1313 <compilerarg value="-Xlint:all"/>
1414 </javac>
15 <!-- Compile helper classes used by the templates -->
1516 <javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" source="1.4" target="1.4" taskname="generator">
1617 <include name="org/lwjgl/opengl/GLSync.java"/>
18 <include name="org/lwjgl/opengl/AMDDebugOutputCallback.java"/>
1719 <include name="org/lwjgl/opengl/PointerWrapper.java"/>
1820 </javac>
1921 </target>
3638 <arg value="-d"/>
3739 <arg path="${lwjgl.src.native}/generated"/>
3840 <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"/>
4042 </apply>
4143 </target>
4244
5456 <arg path="${lwjgl.src.native}/generated"/>
5557 <arg value="-Atypemap=org.lwjgl.util.generator.ALTypeMap"/>
5658 <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"/>
5860 </apply>
5961 </target>
6062
66 </antcall>
77 </target>
88
9 <target name="webstart_demo-release" depends="jars">
9 <target name="webstart_demo-release">
1010 <input message="Please type the password for the keystore" addproperty="sign.pwd"/>
1111
1212 <antcall target="-webstart_demo">
2424
2525 <!-- unzip common files -->
2626 <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"/>
2729
2830 <!-- move files to unified structure -->
2931 <move todir="${lwjgl.temp}/jnlp/temp">
3537 <!-- move relevant files to root -->
3638 <move todir="${lwjgl.temp}/jnlp/" flatten="true">
3739 <fileset dir="${lwjgl.temp}/jnlp/temp">
38 <include name="**/**.jar"/>
40 <include name="**/jinput.jar"/>
41 <include name="**/lwjgl*.jar"/>
3942 </fileset>
4043 </move>
4144
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
4265 <!-- 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>
4789
4890 <!-- 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>
5096
5197 <!-- sign 'em -->
5298 <signjar jar="${lwjgl.temp}/jnlp/lwjgl.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
56102 <signjar jar="${lwjgl.temp}/jnlp/native_macosx.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
57103 <signjar jar="${lwjgl.temp}/jnlp/native_windows.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
58104 <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}"/>
59106 </target>
60107 </project>
+0
-85
platform_build/build-webstart.xml.bak less more
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>
4747 * </p>
4848 * @author cix_foo <cix_foo@users.sourceforge.net>
4949 * @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 $
5252 */
5353 public class BufferChecks {
5454 /** Static methods only! */
5959 * Helper methods to ensure a function pointer is not-null (0)
6060 */
6161 public static void checkFunctionAddress(long pointer) {
62 if (pointer == 0) {
62 if (LWJGLUtil.CHECKS && pointer == 0) {
6363 throw new IllegalStateException("Function is not supported");
6464 }
6565 }
6868 * Helper methods to ensure a ByteBuffer is null-terminated
6969 */
7070 public static void checkNullTerminated(ByteBuffer buf) {
71 if (buf.get(buf.limit() - 1) != 0) {
71 if ( LWJGLUtil.CHECKS && buf.get(buf.limit() - 1) != 0) {
7272 throw new IllegalArgumentException("Missing null termination");
7373 }
7474 }
7575
7676 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 }
8587 }
8688
8789 /** Helper methods to ensure an IntBuffer is null-terminated */
9294 }
9395
9496 public static void checkNotNull(Object o) {
95 if (o == null)
97 if ( LWJGLUtil.CHECKS && o == null)
9698 throw new IllegalArgumentException("Null argument");
9799 }
98100
100102 * Helper methods to ensure a buffer is direct (and, implicitly, non-null).
101103 */
102104 public static void checkDirect(ByteBuffer buf) {
103 if (!buf.isDirect()) {
105 if ( LWJGLUtil.CHECKS && !buf.isDirect()) {
104106 throw new IllegalArgumentException("ByteBuffer is not direct");
105107 }
106108 }
107109
108110 public static void checkDirect(ShortBuffer buf) {
109 if (!buf.isDirect()) {
111 if ( LWJGLUtil.CHECKS && !buf.isDirect()) {
110112 throw new IllegalArgumentException("ShortBuffer is not direct");
111113 }
112114 }
113115
114116 public static void checkDirect(IntBuffer buf) {
115 if (!buf.isDirect()) {
117 if ( LWJGLUtil.CHECKS && !buf.isDirect()) {
116118 throw new IllegalArgumentException("IntBuffer is not direct");
117119 }
118120 }
119121
120122 public static void checkDirect(LongBuffer buf) {
121 if (!buf.isDirect()) {
123 if ( LWJGLUtil.CHECKS && !buf.isDirect()) {
122124 throw new IllegalArgumentException("LongBuffer is not direct");
123125 }
124126 }
125127
126128 public static void checkDirect(FloatBuffer buf) {
127 if (!buf.isDirect()) {
129 if ( LWJGLUtil.CHECKS && !buf.isDirect()) {
128130 throw new IllegalArgumentException("FloatBuffer is not direct");
129131 }
130132 }
131133
132134 public static void checkDirect(DoubleBuffer buf) {
133 if (!buf.isDirect()) {
135 if ( LWJGLUtil.CHECKS && !buf.isDirect()) {
134136 throw new IllegalArgumentException("DoubleBuffer is not direct");
135137 }
136138 }
153155 * @throws IllegalArgumentException
154156 */
155157 public static void checkBufferSize(Buffer buf, int size) {
156 if (buf.remaining() < size) {
158 if ( LWJGLUtil.CHECKS && buf.remaining() < size) {
157159 throwBufferSizeException(buf, size);
158160 }
159161 }
160162
161163 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 }
164168 }
165169
166170 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 }
169175 }
170176
171177 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 }
174182 }
175183
176184 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 }
179189 }
180190
181191 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 }
184196 }
185197
186198 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 }
189203 }
190204 }
4848 * </p>
4949 *
5050 * @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 $
5353 */
5454 public class LWJGLUtil {
5555 public static final int PLATFORM_LINUX = 1;
265265
266266 /** Debug flag. */
267267 public static final boolean DEBUG = getPrivilegedBoolean("org.lwjgl.util.Debug");
268
268
269 public static final boolean CHECKS = !getPrivilegedBoolean("org.lwjgl.util.NoChecks");
270
269271 static {
270272 LWJGLIcon16x16.flip();
271273 LWJGLIcon32x32.flip();
4545 * System class (named Sys so as not to conflict with java.lang.System)
4646 * </p>
4747 * @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 $
5050 */
5151 public final class Sys {
5252 /** The native library name */
5353 private static final String JNI_LIBRARY_NAME = "lwjgl";
5454
5555 /** Current version of library */
56 private static final String VERSION = "2.4.2";
56 private static final String VERSION = "2.5";
5757
5858 /** The implementation instance to delegate platform specific behavior to */
5959 private final static SysImplementation implementation;
5858 * @author cix_foo <cix_foo@users.sourceforge.net>
5959 * @author elias_naur <elias_naur@users.sourceforge.net>
6060 * @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 $
6363 */
6464 public class Mouse {
6565 /** Internal use - event size in bytes */
466466 }
467467
468468 /**
469 * @return Current events delta x. Only valid when the mouse is grabbed.
469 * @return Current events delta x.
470470 */
471471 public static int getEventDX() {
472472 synchronized (OpenGLPackageAccess.global_lock) {
475475 }
476476
477477 /**
478 * @return Current events delta y. Only valid when the mouse is grabbed.
478 * @return Current events delta y.
479479 */
480480 public static int getEventDY() {
481481 synchronized (OpenGLPackageAccess.global_lock) {
484484 }
485485
486486 /**
487 * @return Current events absolute x. Only valid when the mouse is not grabbed.
487 * @return Current events absolute x.
488488 */
489489 public static int getEventX() {
490490 synchronized (OpenGLPackageAccess.global_lock) {
493493 }
494494
495495 /**
496 * @return Current events absolute y. Only valid when the mouse is not grabbed.
496 * @return Current events absolute y.
497497 */
498498 public static int getEventY() {
499499 synchronized (OpenGLPackageAccess.global_lock) {
549549 }
550550
551551 /**
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.
553553 */
554554 public static int getDX() {
555555 synchronized (OpenGLPackageAccess.global_lock) {
560560 }
561561
562562 /**
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.
564564 */
565565 public static int getDY() {
566566 synchronized (OpenGLPackageAccess.global_lock) {
4141 * </p>
4242 *
4343 * @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 $
4646 */
4747 public final class AL {
4848 /** ALCdevice instance. */
159159
160160 if(openDevice) {
161161 device = ALC10.alcOpenDevice(deviceArguments);
162 if (device == null)
162 if (device == null) {
163163 throw new LWJGLException("Could not open ALC device");
164 }
164165
165166 if (contextFrequency == -1) {
166167 context = ALC10.alcCreateContext(device, null);
176177 throw e;
177178 }
178179
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 }
180192 }
181193
182194 /**
204216 device = null;
205217 }
206218 resetNativeStubs(AL10.class);
219 resetNativeStubs(AL11.class);
207220 resetNativeStubs(ALC10.class);
208221 resetNativeStubs(ALC11.class);
222 resetNativeStubs(EFX10.class);
209223
210224 if (created)
211225 nDestroy();
5757 public static final int ALC_CAPTURE_DEVICE_SPECIFIER = 0x310;
5858 public static final int ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER = 0x311;
5959 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;
6063
6164 /**
6265 * 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 }
157157 final InfiniteCharSequence infiniteSeq = getInfiniteSeq();
158158 infiniteSeq.setString(string);
159159 encoder.encode(infiniteSeq.buffer, buffer, true);
160 infiniteSeq.clear();
160161 }
161162
162163 /**
4646 * <p/>
4747 *
4848 * @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 $
5151 */
52 public class AWTGLCanvas extends Canvas implements Drawable, ComponentListener, HierarchyListener {
52 public class AWTGLCanvas extends Canvas implements DrawableLWJGL, ComponentListener, HierarchyListener {
5353
5454 private static final long serialVersionUID = 1L;
5555
108108 return context;
109109 }
110110
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
111120 /** Constructor using the default PixelFormat. */
112121 public AWTGLCanvas() throws LWJGLException {
113122 this(new PixelFormat());
174183 */
175184 public void removeNotify() {
176185 synchronized ( SYNC_LOCK ) {
177 destroyContext();
186 destroy();
178187 super.removeNotify();
179188 }
180189 }
199208 if ( context == null )
200209 throw new IllegalStateException("Canvas not yet displayable");
201210 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();
202231 }
203232 }
204233
211240 }
212241 }
213242
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
226243 /** Destroy the OpenGL context. This happens when the component becomes undisplayable */
227 private void destroyContext() {
244 public final void destroy() {
228245 synchronized ( SYNC_LOCK ) {
229246 try {
230247 if ( context != null ) {
268285 peer_info.lockAndGetHandle();
269286 try {
270287 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);
272289 first_run = true;
273290 }
274291
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 }
3131 package org.lwjgl.opengl;
3232
3333 import java.nio.Buffer;
34 import java.nio.IntBuffer;
3534 import java.util.Arrays;
3635
3736 class BaseReferences {
4847 int indirectBuffer;
4948
5049 BaseReferences(ContextCapabilities caps) {
51 IntBuffer temp = caps.scratch_int_buffer;
52
5350 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
5854 max_vertex_attribs = 0;
5955 glVertexAttribPointer_buffer = new Buffer[max_vertex_attribs];
6056
6157 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
6963 max_texture_units = 1;
7064 glTexCoordPointer_buffer = new Buffer[max_texture_units];
7165 }
4545 * This class is thread-safe.
4646 *
4747 * @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 $
5050 */
5151 final class Context {
5252
6060 private final ByteBuffer handle;
6161 private final PeerInfo peer_info;
6262
63 private final IntBuffer attribList;
63 private final ContextAttribs contextAttribs;
6464 private final boolean forwardCompatible;
6565
6666 /** Whether the context has been destroyed */
9191
9292 PeerInfo getPeerInfo() {
9393 return peer_info;
94 }
95
96 ContextAttribs getContextAttribs() {
97 return contextAttribs;
9498 }
9599
96100 static Context getCurrentContext() {
108112 GLContext.loadOpenGLLibrary();
109113 try {
110114 this.peer_info = peer_info;
115 this.contextAttribs = attribs;
116
117 IntBuffer attribList;
111118 if ( attribs != null ) {
112119 attribList = attribs.getAttribList();
113120 forwardCompatible = attribs.isForwardCompatible();
3636 import java.nio.IntBuffer;
3737
3838 /**
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.
4041 * These attributes can be used to indicate at context creation which OpenGL interface will be used. This includes the
4142 * 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)
4344 * <p/>
4445 * 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.
4949 * <p/>
5050 * If the forwardCompatible
5151 * attribute is used, LWJGL will not load the deprecated functionality (as defined in the OpenGL 3.0 specification). This
7171 }
7272
7373 public ContextAttribs(final int majorVersion, final int minorVersion) {
74 if ( majorVersion < 0 ||
75 3 < majorVersion ||
74 if ( majorVersion < 0 || 4 < majorVersion ||
7675 minorVersion < 0 ||
77 (majorVersion == 3 && 2 < minorVersion) ||
76 (majorVersion == 4 && 0 < minorVersion) ||
77 (majorVersion == 3 && 3 < minorVersion) ||
7878 (majorVersion == 2 && 1 < minorVersion) ||
7979 (majorVersion == 1 && 5 < minorVersion) )
8080 throw new IllegalArgumentException("Invalid OpenGL version specified: " + majorVersion + '.' + minorVersion);
8787 this.debug = false;
8888 this.forwardCompatible = false;
8989
90 this.profileCore = 3 < majorVersion || (majorVersion == 3 && 2 <= minorVersion) ? true : false;
90 this.profileCore = false;
9191 this.profileCompatibility = false;
9292 }
9393
105105 /** Swap interval */
106106 private static int swap_interval;
107107
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
112108 /** 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;
116112
117113 private static boolean parent_resized;
118114
136132 } catch (LWJGLException e) {
137133 throw new RuntimeException(e);
138134 }
139 drawable = new Drawable() {
140 public Context getContext() {
135 drawable = new AbstractDrawable() {
136 public void destroy() {
141137 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();
143148 }
144149 }
145150 };
237242 * @throws LWJGLException if the display mode could not be set
238243 */
239244 public static void setDisplayMode(DisplayMode mode) throws LWJGLException {
240 synchronized (GlobalLock.lock) {
241 if (mode == null)
245 synchronized ( GlobalLock.lock ) {
246 if ( mode == null )
242247 throw new NullPointerException("mode must be non-null");
243248 boolean was_fullscreen = isFullscreen();
244249 current_mode = mode;
245 if (isCreated()) {
250 if ( isCreated() ) {
246251 destroyWindow();
247252 // If mode is not fullscreen capable, make sure we are in windowed mode
248253 try {
249 if (was_fullscreen && !isFullscreen())
254 if ( was_fullscreen && !isFullscreen() )
250255 display_impl.resetDisplayMode();
251 else if (isFullscreen())
256 else if ( isFullscreen() )
252257 switchDisplayMode();
253258 createWindow();
254259 makeCurrentAndSetSwapInterval();
255260 } catch (LWJGLException e) {
256 destroyContext();
257 destroyPeerInfo();
261 drawable.destroy();
258262 display_impl.resetDisplayMode();
259263 throw e;
260264 }
267271 }
268272
269273 private static int getWindowX() {
270 if (!isFullscreen() && parent == null) {
274 if ( !isFullscreen() && parent == null ) {
271275 // if no display location set, center window
272 if (x == -1) {
276 if ( x == -1 ) {
273277 return Math.max(0, (initial_mode.getWidth() - current_mode.getWidth()) / 2);
274278 } else {
275279 return x;
280284 }
281285
282286 private static int getWindowY() {
283 if (!isFullscreen() && parent == null) {
287 if ( !isFullscreen() && parent == null ) {
284288 // if no display location set, center window
285289 if ( y == -1 ) {
286290 return Math.max(0, (initial_mode.getHeight() - current_mode.getHeight()) / 2);
323327
324328 private static void releaseDrawable() {
325329 try {
330 Context context = drawable.context;
326331 if ( context != null && context.isCurrent() ) {
327332 Context.releaseCurrentContext();
328333 context.releaseDrawable();
418423 savedTimeLate = timeLate;
419424 }
420425
421 while ( gapTo > timeNow + savedTimeLate ) {
422 try {
426 try {
427 while ( gapTo > timeNow + savedTimeLate ) {
423428 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();
427433 }
428434
429435 synchronized ( GlobalLock.lock ) {
462468 */
463469 public static void setParent(Canvas parent) throws LWJGLException {
464470 synchronized ( GlobalLock.lock ) {
465 if (Display.parent != parent) {
471 if ( Display.parent != parent ) {
466472 Display.parent = parent;
467473 if ( !isCreated() )
468474 return;
469475 destroyWindow();
470476 try {
471 if (isFullscreen()) {
477 if ( isFullscreen() ) {
472478 switchDisplayMode();
473479 } else {
474480 display_impl.resetDisplayMode();
476482 createWindow();
477483 makeCurrentAndSetSwapInterval();
478484 } catch (LWJGLException e) {
479 destroyContext();
480 destroyPeerInfo();
485 drawable.destroy();
481486 display_impl.resetDisplayMode();
482487 throw e;
483488 }
518523
519524 private static void setDisplayModeAndFullscreenInternal(boolean fullscreen, DisplayMode mode) throws LWJGLException {
520525 synchronized ( GlobalLock.lock ) {
521 if (mode == null)
526 if ( mode == null )
522527 throw new NullPointerException("mode must be non-null");
523528 DisplayMode old_mode = current_mode;
524529 current_mode = mode;
525530 boolean was_fullscreen = isFullscreen();
526531 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() )
529534 return;
530535 destroyWindow();
531536 try {
532 if (isFullscreen()) {
537 if ( isFullscreen() ) {
533538 switchDisplayMode();
534539 } else {
535540 display_impl.resetDisplayMode();
537542 createWindow();
538543 makeCurrentAndSetSwapInterval();
539544 } catch (LWJGLException e) {
540 destroyContext();
541 destroyPeerInfo();
545 drawable.destroy();
542546 display_impl.resetDisplayMode();
543547 throw e;
544548 }
548552
549553 /** @return whether the Display is in fullscreen mode */
550554 public static boolean isFullscreen() {
551 synchronized (GlobalLock.lock) {
555 synchronized ( GlobalLock.lock ) {
552556 return fullscreen && current_mode.isFullscreenCapable();
553557 }
554558 }
650654 * Update the window. If the window is visible clears
651655 * the dirty flag and calls swapBuffers() and finally
652656 * polls the input devices.
653 *
654657 */
655658 public static void update() {
656659 update(true);
709712 * @throws LWJGLException If the context could not be released
710713 */
711714 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();
718721 }
719722
720723 /**
723726 * @throws LWJGLException If the context could not be made current
724727 */
725728 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();
731730 }
732731
733732 private static void removeShutdownHook() {
847846 throw new NullPointerException("pixel_format cannot be null");
848847 removeShutdownHook();
849848 registerShutdownHook();
850 if (isFullscreen())
849 if ( isFullscreen() )
851850 switchDisplayMode();
852851 try {
853 peer_info = display_impl.createPeerInfo(pixel_format);
852 drawable.peer_info = display_impl.createPeerInfo(pixel_format);
854853 try {
855854 createWindow();
856855 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);
858857 try {
859858 makeCurrentAndSetSwapInterval();
860859 initContext();
861860 } catch (LWJGLException e) {
862 destroyContext();
861 drawable.destroy();
863862 throw e;
864863 }
865864 } catch (LWJGLException e) {
867866 throw e;
868867 }
869868 } catch (LWJGLException e) {
870 destroyPeerInfo();
869 drawable.destroy();
871870 throw e;
872871 }
873872 } catch (LWJGLException e) {
878877 }
879878
880879 /**
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 */
888887 public static void setInitialBackground(float red, float green, float blue) {
889888 r = red;
890889 g = green;
956955 * regardless of whether the Display was the current rendering context.
957956 */
958957 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();
988959 }
989960
990961 /*
991962 * Reset display mode if fullscreen. This method is also called from the shutdown hook added
992963 * in the static constructor
993964 */
965
994966 private static void reset() {
995967 display_impl.resetDisplayMode();
996968 current_mode = initial_mode;
10491021 y = new_y;
10501022
10511023 // offset if already created
1052 if (isCreated() && !isFullscreen()) {
1024 if ( isCreated() && !isFullscreen() ) {
10531025 reshape();
10541026 }
10551027 }
3030 */
3131 package org.lwjgl.opengl;
3232
33 import org.lwjgl.LWJGLException;
34
3335 /**
3436 * The Drawable interface describes an OpenGL drawable with an associated
3537 * Context.
3840 */
3941
4042 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
4264 }
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 }
3434 import java.nio.IntBuffer;
3535
3636 import org.lwjgl.BufferUtils;
37 import org.lwjgl.LWJGLUtil;
3738
3839 /**
3940 * A class to check buffer boundaries in GL methods. Many GL
4546 * Thrown by the debug build library of the LWJGL if any OpenGL operation causes an error.
4647 *
4748 * @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 $
5051 */
5152 class GLChecks {
5253
5960 }
6061
6162 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);
6564 }
6665
6766 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);
7168 }
7269
7370 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);
7772 }
7873
7974 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);
9076 }
9177
9278 /** Helper method to ensure that array buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */
9379 static void ensureArrayVBOdisabled(ContextCapabilities caps) {
94 if(StateTracker.getReferencesStack(caps).getReferences().arrayBuffer != 0)
80 if( LWJGLUtil.CHECKS && StateTracker.getReferencesStack(caps).getReferences().arrayBuffer != 0 )
9581 throw new OpenGLException("Cannot use Buffers when Array Buffer Object is enabled");
9682 }
9783
9884 /** Helper method to ensure that array buffer objects are enabled. If they are disabled, we'll throw an OpenGLException */
9985 static void ensureArrayVBOenabled(ContextCapabilities caps) {
100 if(StateTracker.getReferencesStack(caps).getReferences().arrayBuffer == 0)
86 if( LWJGLUtil.CHECKS && StateTracker.getReferencesStack(caps).getReferences().arrayBuffer == 0 )
10187 throw new OpenGLException("Cannot use offsets when Array Buffer Object is disabled");
10288 }
10389
10490 /** Helper method to ensure that element array buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */
10591 static void ensureElementVBOdisabled(ContextCapabilities caps) {
106 if(StateTracker.getReferencesStack(caps).getReferences().elementArrayBuffer != 0)
92 if( LWJGLUtil.CHECKS && StateTracker.getReferencesStack(caps).getReferences().elementArrayBuffer != 0 )
10793 throw new OpenGLException("Cannot use Buffers when Element Array Buffer Object is enabled");
10894 }
10995
11096 /** Helper method to ensure that element array buffer objects are enabled. If they are disabled, we'll throw an OpenGLException */
11197 static void ensureElementVBOenabled(ContextCapabilities caps) {
112 if(StateTracker.getReferencesStack(caps).getReferences().elementArrayBuffer == 0)
98 if( LWJGLUtil.CHECKS && StateTracker.getReferencesStack(caps).getReferences().elementArrayBuffer == 0 )
11399 throw new OpenGLException("Cannot use offsets when Element Array Buffer Object is disabled");
114100 }
115101
116102 /** Helper method to ensure that array buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */
117103 static void ensureIndirectBOdisabled(ContextCapabilities caps) {
118 if ( StateTracker.getReferencesStack(caps).getReferences().indirectBuffer != 0 )
104 if ( LWJGLUtil.CHECKS && StateTracker.getReferencesStack(caps).getReferences().indirectBuffer != 0 )
119105 throw new OpenGLException("Cannot use Buffers when Draw Indirect Object is enabled");
120106 }
121107
122108 /** Helper method to ensure that array buffer objects are enabled. If they are disabled, we'll throw an OpenGLException */
123109 static void ensureIndirectBOenabled(ContextCapabilities caps) {
124 if ( StateTracker.getReferencesStack(caps).getReferences().indirectBuffer == 0 )
110 if ( LWJGLUtil.CHECKS && StateTracker.getReferencesStack(caps).getReferences().indirectBuffer == 0 )
125111 throw new OpenGLException("Cannot use offsets when Draw Indirect Object is disabled");
126112 }
127113
128114 /** Helper method to ensure that pixel pack buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */
129115 static void ensurePackPBOdisabled(ContextCapabilities caps) {
130 if ( StateTracker.getReferencesStack(caps).getReferences().pixelPackBuffer != 0 )
116 if ( LWJGLUtil.CHECKS && StateTracker.getReferencesStack(caps).getReferences().pixelPackBuffer != 0 )
131117 throw new OpenGLException("Cannot use Buffers when Pixel Pack Buffer Object is enabled");
132118 }
133119
134120 /** Helper method to ensure that pixel pack buffer objects are enabled. If they are disabled, we'll throw an OpenGLException */
135121 static void ensurePackPBOenabled(ContextCapabilities caps) {
136 if ( StateTracker.getReferencesStack(caps).getReferences().pixelPackBuffer == 0 )
122 if ( LWJGLUtil.CHECKS && StateTracker.getReferencesStack(caps).getReferences().pixelPackBuffer == 0 )
137123 throw new OpenGLException("Cannot use offsets when Pixel Pack Buffer Object is disabled");
138124 }
139125
140126 /** Helper method to ensure that pixel unpack buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */
141127 static void ensureUnpackPBOdisabled(ContextCapabilities caps) {
142 if ( StateTracker.getReferencesStack(caps).getReferences().pixelUnpackBuffer != 0 )
128 if ( LWJGLUtil.CHECKS && StateTracker.getReferencesStack(caps).getReferences().pixelUnpackBuffer != 0 )
143129 throw new OpenGLException("Cannot use Buffers when Pixel Unpack Buffer Object is enabled");
144130 }
145131
146132 /** Helper method to ensure that pixel unpack buffer objects are enabled. If they are disabled, we'll throw an OpenGLException */
147133 static void ensureUnpackPBOenabled(ContextCapabilities caps) {
148 if ( StateTracker.getReferencesStack(caps).getReferences().pixelUnpackBuffer == 0 )
134 if ( LWJGLUtil.CHECKS && StateTracker.getReferencesStack(caps).getReferences().pixelUnpackBuffer == 0 )
149135 throw new OpenGLException("Cannot use offsets when Pixel Unpack Buffer Object is disabled");
150136 }
151137
161147 * @return the size, in elements, of the image
162148 */
163149 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;
165151 }
166152
167153 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;
169155 }
170156
171157 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;
173159 }
174160
175161 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;
177163 }
178164
179165 /**
5353 * That way, multiple threads can have multiple contexts current and render to them concurrently.
5454 *
5555 * @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 $
5858 */
5959 public final class GLContext {
6060
168168 return 0;
169169 }
170170
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
171187 /** Helper method to get a pointer to a named function in the OpenGL library */
172188 static native long getFunctionAddress(String name);
173189
3838 */
3939
4040 import java.awt.Canvas;
41 import java.io.BufferedReader;
42 import java.io.IOException;
43 import java.io.InputStreamReader;
4144 import java.nio.ByteBuffer;
4245 import java.nio.FloatBuffer;
4346 import java.nio.IntBuffer;
4649 import org.lwjgl.LWJGLException;
4750 import org.lwjgl.LWJGLUtil;
4851 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;
4958
5059 final class LinuxDisplay implements DisplayImplementation {
5160 /* X11 constants */
406415 ByteBuffer handle = peer_info.lockAndGetHandle();
407416 try {
408417 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"));
410427 this.parent = parent;
411428 parent_window = parent != null ? getHandle(parent) : getRootWindow(getDisplay(), getDefaultScreen());
412429 current_window = nCreateWindow(getDisplay(), getDefaultScreen(), handle, mode, current_window_mode, x, y, undecorated, parent_window);
440457 private static native void mapRaised(long display, long window);
441458 private static native void reparentWindow(long display, long window, long parent, int x, int y);
442459
443 private boolean isAncestorXEmbedded(long window) throws LWJGLException {
460 private static boolean isAncestorXEmbedded(long window) throws LWJGLException {
444461 long xembed_atom = internAtom("_XEMBED_INFO", true);
445462 if (xembed_atom != None) {
446463 long w = window;
482499 ungrabKeyboard();
483500 nDestroyWindow(getDisplay(), getWindow());
484501 decDisplay();
502
503 if ( current_window_mode != WINDOWED )
504 Compiz.setLegacyFullscreenSupport(false);
485505 } finally {
486506 unlockAWT();
487507 }
523543 try {
524544 if( current_displaymode_extension == XRANDR && savedXrandrConfig.length > 0 )
525545 {
526 XRandR.setConfiguration( savedXrandrConfig );
546 AccessController.doPrivileged(new PrivilegedAction() {
547 public Object run() {
548 XRandR.setConfiguration( savedXrandrConfig );
549 return null;
550 }
551 });
527552 }
528553 else
529554 {
531556 }
532557 if (isXF86VidModeSupported())
533558 doSetGamma(saved_gamma);
559
560 Compiz.setLegacyFullscreenSupport(false);
534561 } catch (LWJGLException e) {
535562 LWJGLUtil.log("Caught exception while resetting mode: " + e);
536563 } finally {
605632 public DisplayMode init() throws LWJGLException {
606633 lockAWT();
607634 try {
635 Compiz.init();
636
608637 delete_atom = internAtom("WM_DELETE_WINDOW", false);
609638 current_displaymode_extension = getBestDisplayModeExtension();
610639 if (current_displaymode_extension == NONE)
614643 throw new LWJGLException("No modes available");
615644 switch (current_displaymode_extension) {
616645 case XRANDR:
617 savedXrandrConfig = XRandR.getConfiguration();
646 savedXrandrConfig = (Screen[])AccessController.doPrivileged(new PrivilegedAction() {
647 public Object run() {
648 return XRandR.getConfiguration();
649 }
650 });
618651 saved_mode = getCurrentXRandrMode();
619652 break;
620653 case XF86VIDMODE:
846879 setInputFocusUnsafe(current_window);
847880 }
848881 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 //}
855888 }
856889
857890 private void setFocused(boolean got_focus, int focus_detail) {
889922 try {
890923 if( current_displaymode_extension == XRANDR && savedXrandrConfig.length > 0 )
891924 {
892 XRandR.setConfiguration( savedXrandrConfig );
925 AccessController.doPrivileged(new PrivilegedAction() {
926 public Object run() {
927 XRandR.setConfiguration( savedXrandrConfig );
928 return null;
929 }
930 });
893931 }
894932 else
895933 {
12111249 public boolean isInsideWindow() {
12121250 return true;
12131251 }
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 }
7777 AccessController.doPrivileged(new PrivilegedExceptionAction() {
7878 public Object run() throws Exception {
7979 Application.getApplication().addApplicationListener(new ApplicationAdapter() {
80 public final void handleQuit(ApplicationEvent event) {
80 public void handleQuit(ApplicationEvent event) {
8181 doHandleQuit();
8282 }
8383 });
270270 *
271271 * - elias
272272 */
273 AbstractDrawable drawable = (AbstractDrawable)Display.getDrawable();
273274 if (Display.isFullscreen() && (frame != null && frame.getCanvas().syncCanvasPainted() || should_update)) {
274275 try {
275 MacOSXContextImplementation.resetView(Display.getDrawable().getContext().getPeerInfo(), Display.getDrawable().getContext());
276 MacOSXContextImplementation.resetView(drawable.peer_info, drawable.context);
276277 } catch (LWJGLException e) {
277278 LWJGLUtil.log("Failed to reset context: " + e);
278279 }
279280 }
280281 if (should_update) {
281 Display.getDrawable().getContext().update();
282 drawable.context.update();
282283 /* This is necessary to make sure the context won't "forget" about the view size */
283284 GL11.glGetInteger(GL11.GL_VIEWPORT, current_viewport);
284285 GL11.glViewport(current_viewport.get(0), current_viewport.get(1), current_viewport.get(2), current_viewport.get(3));
3434
3535 import org.lwjgl.BufferUtils;
3636 import org.lwjgl.LWJGLException;
37 import org.lwjgl.LWJGLUtil;
3837 import org.lwjgl.Sys;
3938
4039 /**
4544 * This class is thread-safe.
4645 *
4746 * @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 $
5049 */
51 public final class Pbuffer implements Drawable {
50 public final class Pbuffer extends AbstractDrawable {
5251 /**
5352 * Indicates that Pbuffers can be created.
5453 */
135134 public static final int DEPTH_BUFFER = RenderTexture.WGL_DEPTH_COMPONENT_NV;
136135
137136 /**
138 * Handle to the native GL rendering context
139 */
140 private final PeerInfo peer_info;
141
142 /**
143137 * Width
144138 */
145139 private final int width;
148142 * Height
149143 */
150144 private final int height;
151
152 private final Context context;
153
154 private boolean destroyed;
155145
156146 static {
157147 Sys.initialize();
226216 this.width = width;
227217 this.height = height;
228218 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
237224 this.context = new Context(peer_info, attribs, shared_context);
238225 }
239226
250237 renderTexture.pBufferAttribs);
251238 }
252239
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
262240 /**
263241 * Method to test for validity of the buffer. If this function returns true, the buffer contents is lost. The buffer can still
264242 * be used, but the results are undefined. The application is expected to release the buffer if needed, destroy it and recreate
272250 }
273251
274252 /**
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 /**
284253 * Gets the Pbuffer capabilities.
285254 *
286255 * @return a bitmask of Pbuffer capabilities.
287256 */
288257 public static int getCapabilities() {
289258 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 }
306259 }
307260
308261 // -----------------------------------------------------------------------------------------
4444 * pixel format selection path, which could trigger a crash.
4545 *
4646 * @author elias_naur@sourceforge.net
47 * @version $Revision: 3116 $
47 * @version $Revision: 3355 $
4848 */
4949
5050 public final class PixelFormat {
6565 * 0 means that anti-aliasing is disabled.
6666 */
6767 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;
6876 /** The number of auxiliary buffers */
6977 private int num_aux_buffers;
7078 /** The number of bits per pixel in the accumulation buffer */
7583 private boolean stereo;
7684 /** Whether this format specifies a floating point format */
7785 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 */
7990 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 */
8195 private boolean sRGB;
8296
8397 /**
131145 this.stencil = pf.stencil;
132146
133147 this.samples = pf.samples;
148 this.colorSamples = pf.colorSamples;
134149
135150 this.num_aux_buffers = pf.num_aux_buffers;
136151
244259 return pf;
245260 }
246261
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
247294 public int getAuxBuffers() {
248295 return num_aux_buffers;
249296 }
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 }
436436 * is maximized helps some gfx cards recover from fullscreen
437437 */
438438 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();
441442 } catch (LWJGLException e) {
442443 LWJGLUtil.log("Exception occurred while trying to make context current: " + e);
443444 }
972973 return "Rect: top = " + top + " bottom = " + bottom + " left = " + left + " right = " + right;
973974 }
974975 }
975 }
976 }
00 /*
1 * Copyright (c) 2002-2010 LWJGL Project
2 * All rights reserved.
3 *
1 * Copyright (c) 2002-2010 LWJGL Project All rights reserved.
42 * 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,
2519 * 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.
3025 */
3126
3227 package org.lwjgl.opengl;
3833 import java.util.HashMap;
3934 import java.util.List;
4035 import java.util.Map;
36 import java.util.regex.Matcher;
4137 import java.util.regex.Pattern;
42 import java.security.AccessController;
43 import java.security.PrivilegedAction;
38
39 import org.lwjgl.LWJGLUtil;
4440
4541 /**
4642 * Utility for working with the xrandr commmand-line utility. Assumes
4844 *
4945 * @author ryanm
5046 */
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 {
5957 screens = new HashMap/* <String, Screen[]> */();
6058
6159 // ProcessBuilder pb = new ProcessBuilder( "xrandr", "-q" );
6260 // pb.redirectErrorStream();
63 try {
61 try
62 {
6463 // Process p= pb.start();
65 Process p = Runtime.getRuntime().exec(new String[] { "xrandr", "-q"});
64 Process p = Runtime.getRuntime().exec( new String[] { "xrandr", "-q" } );
6665
6766 List/* <Screen> */currentList = new ArrayList/* <Screen> */();
6867 List/* <Screen> */possibles = new ArrayList/* <Screen> */();
6968 String name = null;
7069
71 BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
70 BufferedReader br = new BufferedReader( new InputStreamReader( p.getInputStream() ) );
7271 String line;
73 while ((line = br.readLine()) != null) {
72 while( ( line = br.readLine() ) != null )
73 {
7474 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 {
7879 // 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() ] ) );
8183 possibles.clear();
8284 }
83 name = sa[0];
85 name = sa[ 0 ];
8486
8587 // 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 {
8892 // found a new mode line
89 possibles.add(new Screen(name, sa[0]));
93 parseScreen( possibles, name, sa[ 0 ] );
9094 }
9195 }
9296
93 screens.put(name, possibles.toArray(new Screen[possibles.size()]));
97 screens.put( name, possibles.toArray( new Screen[ possibles.size() ] ) );
9498
9599 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 ];
98106 }
99107 }
100108 }
103111 * @return The current screen configuration, or an empty array if
104112 * xrandr is not supported
105113 */
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();
113117
114118 return (Screen[]) current.clone();
115119 }
117121 /**
118122 * @param screens
119123 * 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" );
124132 }
125133
126134 List/* <String> */cmd = new ArrayList/* <String> */();
127 cmd.add("xrandr");
135 cmd.add( "xrandr" );
128136
129137 // 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 {
131140 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 {
134145 found = true;
135146 break;
136147 }
137148 }
138149
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" );
143155 }
144156 }
145157
146158 // 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 {
152166 // ProcessBuilder pb = new ProcessBuilder( cmd );
153167 // pb.redirectErrorStream();
154168 // 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() ] ) );
156171 // 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() ) );
158173 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 );
161177 }
162178 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 }
167184 }
168185
169186 /**
170187 * @return the name of connected screens, or an empty array if
171188 * xrandr is not supported
172189 */
173 public static String[] getScreenNames() {
190 public static String[] getScreenNames()
191 {
174192 populate();
175 return (String[]) screens.keySet().toArray(new String[screens.size()]);
193 return ( String[] ) screens.keySet().toArray( new String[ screens.size() ] );
176194 }
177195
178196 /**
180198 * @return the possible resolutions of the named screen, or
181199 * <code>null</code> if there is no such screen
182200 */
183 public static Screen[] getResolutions(String name) {
201 public static Screen[] getResolutions( String name )
202 {
184203 populate();
185204 // clone the array to prevent held copies being altered
186205 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 ) );
187251 }
188252
189253 /**
192256 *
193257 * @author ryanm
194258 */
195 public static class Screen implements Cloneable {
196
259 public static class Screen implements Cloneable
260 {
197261 /**
198262 * Name for this output
199263 */
200 public final String name;
264 public final String name;
201265
202266 /**
203267 * Width in pixels
204268 */
205 public final int width;
269 public final int width;
206270
207271 /**
208272 * Height in pixels
209273 */
210 public final int height;
274 public final int height;
211275
212276 /**
213277 * Position on the x-axis, in pixels
214278 */
215 public int xPos = 0;
279 public int xPos = 0;
216280
217281 /**
218282 * Position on the y-axis, in pixels
219283 */
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 {
230288 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 {
253308 return name + " " + width + "x" + height + " @ " + xPos + "x" + yPos;
254309 }
255310 }
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 }
3131 package org.lwjgl.test.openal;
3232
3333 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;
3439
3540 import org.lwjgl.BufferUtils;
3641 import org.lwjgl.LWJGLException;
3944 import org.lwjgl.openal.ALC10;
4045 import org.lwjgl.openal.ALC11;
4146 import org.lwjgl.openal.ALCdevice;
47 import org.lwjgl.openal.EFX10;
48 import org.lwjgl.openal.EFXUtil;
4249
4350 /**
4451 *
6976
7077 printALCInfo();
7178 printALInfo();
79 printEFXInfo();
7280
7381 checkForErrors();
7482
93101 device = ALC10.alcGetContextsDevice(ALC10.alcGetCurrentContext());
94102 checkForErrors();
95103
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));
97105
98106 System.out.println("Default capture device: " + ALC10.alcGetString(device, ALC11.ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER));
99107
129137 checkForErrors();
130138 }
131139
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
132204 private void printDevices(int which, String kind) {
133205 String[] devices = ALC10.alcGetString(null, which).split("\0");
134206 checkForErrors();
3232
3333 import org.lwjgl.LWJGLException;
3434 import org.lwjgl.input.Keyboard;
35 import org.lwjgl.input.Mouse;
3536 import org.lwjgl.opengl.Display;
3637 import org.lwjgl.opengl.DisplayMode;
3738 import org.lwjgl.opengl.GL11;
4344 * Tests switching between windowed and fullscreen
4445 *
4546 * @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 $
4849 */
4950 public class FullScreenWindowedTest {
5051 /** Intended deiplay mode */
221222 if (angleRotation > MAX_SPEED) {
222223 angleRotation = MAX_SPEED;
223224 }
225
226 while ( Mouse.next() );
224227 }
225228 /**
226229 * Cleans up the test
3030 */
3131
3232 /**
33 * $Id: VBOIndexTest.java 2983 2008-04-07 18:36:09Z matzon $
33 * $Id: VBOIndexTest.java 3344 2010-05-22 16:53:49Z spasi $
3434 *
3535 * Simple java test program.
3636 *
3737 * @author elias_naur <elias_naur@users.sourceforge.net>
38 * @version $Revision: 2983 $
38 * @version $Revision: 3344 $
3939 */
4040
4141 package org.lwjgl.test.opengl;
178178 mapped_indices_buffer);
179179 if ( new_mapped_buffer != mapped_indices_buffer )
180180 mapped_indices_int_buffer = new_mapped_buffer.order(ByteOrder.nativeOrder()).asIntBuffer();
181 mapped_indices_buffer = new_mapped_buffer;
181182
182183 mapped_float_buffer.rewind();
183184 vertices.rewind();
2828 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2929 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030 */
31 /*
32 * Created by LWJGL.
33 * User: spasi
34 * Date: 2009-04-04
35 * Time: 21:20:24 pm
36 */
37
3831 package org.lwjgl.test.opengl;
3932
4033 import org.lwjgl.LWJGLException;
4336 import java.util.StringTokenizer;
4437 import java.util.regex.Pattern;
4538
39 /**
40 * Tests the ARB_create_context extension through the use of the ContextAttribs class.
41 *
42 * @author Spasi
43 */
4644 public final class VersionTest {
4745
4846 private VersionTest() {
109107
110108 System.out.println("\n---------\n");
111109
110 System.out.println("Requested " + ca);
111
112112 final String version = GL11.glGetString(GL11.GL_VERSION);
113113
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) {}
120119
121120 final StringTokenizer version_tokenizer = new StringTokenizer(version, ". ");
122121
123122 int majorVersion = Integer.parseInt(version_tokenizer.nextToken());
124123 int minorVersion = Integer.parseInt(version_tokenizer.nextToken());
125124
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"));
152209 }
153210 }
154211
173230
174231 private static void argsError(final String msg) {
175232 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");
177234 System.out.println("majorVersion\t- Major OpenGL version.");
178235 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+).");
179238 System.out.println("layer\t- Layer plane (optional).");
180239 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+).");
182241
183242 cleanup();
184243 System.exit(-1);
192251 System.exit(-1);
193252 }
194253
195 }
254 }
149149 addWindowListener(new WindowAdapter() {
150150
151151 public void windowClosing(WindowEvent e) {
152 demoCanvas.destroy();
152 demoCanvas.destroyCanvas();
153153 dispose();
154154 System.exit(0);
155155 }
268268 }
269269 }
270270
271 public void destroy() {
271 public void destroyCanvas() {
272272 setActiveDemo(null);
273273 renderThread = null;
274274 }
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 }
5050 * Utitlity class for loading wavefiles.
5151 *
5252 * @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 $
5555 */
5656 public class WaveData {
5757 /** actual wave data */
107107 * @return WaveData containing data, or null if a failure occured
108108 */
109109 public static WaveData create(String path) {
110 return create(WaveData.class.getClassLoader().getResource(path));
110 return create(Thread.currentThread().getContextClassLoader().getResource(path));
111111 }
112112
113113 /**
3838 import java.awt.Graphics;
3939 import java.awt.Image;
4040 import java.awt.MediaTracker;
41 import java.awt.image.ImageObserver;
4142 import java.io.DataInputStream;
4243 import java.io.DataOutputStream;
4344 import java.io.File;
4647 import java.io.FilePermission;
4748 import java.io.IOException;
4849 import java.io.InputStream;
50 import java.io.ObjectInputStream;
51 import java.io.ObjectOutputStream;
4952 import java.io.OutputStream;
5053 import java.io.PrintWriter;
5154 import java.io.StringWriter;
6770 import java.security.SecureClassLoader;
6871 import java.security.cert.Certificate;
6972 import java.util.Enumeration;
73 import java.util.HashMap;
7074 import java.util.StringTokenizer;
7175 import java.util.Vector;
7276 import java.util.jar.JarEntry;
105109 * <ul>
106110 * <li>al_version - [int or float] Version of deployment. If this is specified, the jars will be cached and
107111 * 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>
111113 * <li>al_debug - [boolean] Whether to enable debug mode. <i>Default: false</i>.</li>
112114 * <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>
113123 * </ul>
114124 * </p>
115125 * @author kappaOne
165175 protected int totalSizeExtract;
166176
167177 /** logo to be shown while loading */
168 protected Image logo;
178 protected Image logo, logoBuffer;
169179
170180 /** progressbar to render while loading */
171 protected Image progressbar;
181 protected Image progressbar, progressbarBuffer;
172182
173183 /** offscreen image used */
174184 protected Image offscreen;
175185
186 /** set to true while painting is done */
187 protected boolean painting;
188
176189 /** background color of applet */
177190 protected Color bgColor = Color.white;
178
179 /** Color to write errors in */
180 protected Color errorColor = Color.red;
181191
182192 /** color to write foreground in */
183193 protected Color fgColor = Color.black;
208218
209219 /** whether to prepend host to cache path */
210220 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;
211230
212231 /** String to display as a subtask */
213232 protected String subtaskMessage = "";
251270 return;
252271 }
253272 }
254
273
274 // whether to use cache system
275 cacheEnabled = getBooleanParameter("al_cache", true);
276
255277 // whether to run in debug mode
256278 debugMode = getBooleanParameter("al_debug", false);
257279
259281 prependHost = getBooleanParameter("al_prepend_host", true);
260282
261283 // get colors of applet
262 bgColor = getColor("al_bgcolor", Color.white);
284 bgColor = getColor("boxbgcolor", Color.white);
263285 setBackground(bgColor);
264
265 fgColor = getColor("al_fgcolor", Color.black);
266 errorColor = getColor("al_errorcolor", Color.red);
286 fgColor = getColor("boxfgcolor", Color.black);
267287
268288 // load logos
269289 logo = getImage(getParameter("al_logo"));
338358 if (lwjglApplet != null) {
339359 lwjglApplet.stop();
340360 }
341 super.stop();
342361 }
343362
344363 /*
352371 progressbar = null;
353372 logo = null;
354373
355 super.destroy();
374 logoBuffer = null;
375 progressbarBuffer = null;
356376 }
357377
358378 /**
389409 // create offscreen if missing
390410 if (offscreen == null) {
391411 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);
392424 }
393425
394426 // draw everything onto an image before drawing to avoid flicker
395427 Graphics og = offscreen.getGraphics();
396428 FontMetrics fm = og.getFontMetrics();
397429
398 // set background color
430 // clear background color
399431 og.setColor(bgColor);
400 og.fillRect(0, 0, getWidth(), getHeight());
432 og.fillRect(0, 0, offscreen.getWidth(null), offscreen.getHeight(null));
401433
402434 // get logo position so its in the middle of applet
403435 int x = 0, y = 0;
404436
405437 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;
408440 }
409441
410442 og.setColor(fgColor);
420452
421453 for(int i=0; i<errorMessage.length; i++) {
422454 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;
425457
426 og.setColor(errorColor);
427458 og.drawString(errorMessage[i], messageX, messageY + i*fm.getHeight());
428459 }
429460 }
430461 } else {
431462 og.setColor(fgColor);
432
463
464 painting = true;
465
433466 // draw logo
434 og.drawImage(logo, x, y, null);
467 og.drawImage(logoBuffer, x, y, this);
435468
436469 // 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;
439472 og.drawString(message, messageX, messageY);
440473
441474 // draw subtaskmessage, if any
442475 if(subtaskMessage.length() > 0) {
443 messageX = (getWidth() - fm.stringWidth(subtaskMessage)) / 2;
476 messageX = (offscreen.getWidth(null) - fm.stringWidth(subtaskMessage)) / 2;
444477 og.drawString(subtaskMessage, messageX, messageY+20);
445478 }
446479
447480 // 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;
451486 }
452487
453488 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 }
458528
459529 /**
460530 * @return string describing the state of the loader
466536 case STATE_DETERMINING_PACKAGES:
467537 return "Determining packages to load";
468538 case STATE_CHECKING_CACHE:
469 return "Checking cache for existing files";
539 return "Calculating download size";
470540 case STATE_DOWNLOADING:
471541 return "Downloading packages";
472542 case STATE_EXTRACTING_PACKAGES:
533603 String nativeJar = null;
534604
535605 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
537618 } 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
539631 } else if (osName.startsWith("Mac")) {
540632 nativeJar = getParameter("al_mac");
541633 } else if (osName.startsWith("Solaris") || osName.startsWith("SunOS")) {
597689 if (!dir.exists()) {
598690 dir.mkdirs();
599691 }
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;
604697
605698 // version of applet
606699 String version = getParameter("al_version");
612705 latestVersion = Float.parseFloat(version);
613706
614707 // if version file exists
615 if (dir.exists()) {
708 if (versionFile.exists()) {
616709 // compare to new version
617 if (latestVersion <= readVersionFile(dir)) {
618 cacheAvailable = true;
710 if (latestVersion <= readVersionFile(versionFile)) {
711 versionAvailable = true;
619712 percentage = 90;
620713
621714 if(debugMode) {
627720 }
628721
629722 // 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
631727 // downloads jars from the server
632 downloadJars(path); // 10-55%
728 downloadJars(path); // 15-55%
633729
634730 // Extract Pack and LZMA files
635731 extractJars(path); // 55-65%
637733 // Extracts Native Files
638734 extractNatives(path); // 65-85%
639735
640 // add version information once jars downloaded successfully
736 // save version information once jars downloaded successfully
641737 if (version != null) {
642738 percentage = 90;
643739 writeVersionFile(dir, latestVersion);
644740 }
741
742 // save file names with last modified info once downloaded successfully
743 writeCacheFile(new File(dir, "cache"), filesLastModified);
645744 }
646745
647746 // add the downloaded jars and natives to classpath
685784 protected void writeVersionFile(File file, float version) throws Exception {
686785 DataOutputStream dos = new DataOutputStream(new FileOutputStream(file));
687786 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);
688814 dos.close();
689815 }
690816
764890 * Due to the way applets on plugin1 work, one jvm must
765891 * be used for all applets. We need to use multiple
766892 * 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
768894 * natives from a previous classloader allowing a new
769895 * classloader to use those natives in the same jvm.
770896 *
829955 state = STATE_START_REAL_APPLET;
830956 lwjglApplet.start();
831957 }
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
844976 URLConnection urlconnection;
845977
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 }
848984
849985 // calculate total size of jars to download
850986 for (int i = 0; i < urlList.length; i++) {
853989 if (urlconnection instanceof HttpURLConnection) {
854990 ((HttpURLConnection) urlconnection).setRequestMethod("HEAD");
855991 }
992
856993 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;
8611035
8621036 // download each jar
8631037 byte buffer[] = new byte[65536];
8641038 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;
8651042
8661043 int unsuccessfulAttempts = 0;
8671044 int maxUnsuccessfulAttempts = 3;
9081085 // round to two decimal places
9091086 downloadSpeed = ((int)(downloadSpeed*100))/100f;
9101087 // set current speed message
911 downloadSpeedMessage = " @ " + downloadSpeed + " KB/sec";
1088 downloadSpeedMessage = " - " + downloadSpeed + " KB/sec";
9121089 // reset downloaded amount
9131090 downloadedAmount = 0;
9141091 // reset start time
10661243 float increment = (float) 10.0 / urlList.length;
10671244 // extract all lzma and pack.lzma files
10681245 for (int i = 0; i < urlList.length; i++) {
1246
1247 // if file has not changed, skip it
1248 if (fileSizes[i] == -2) continue;
1249
10691250 percentage = 55 + (int) (increment * (i+1));
10701251 String filename = getFileName(urlList[i]);
10711252
11011282 */
11021283 protected void extractNatives(String path) throws Exception {
11031284
1285 // if no new native jar was downloaded, no extracting needed
1286 if (fileSizes[fileSizes.length-1] == -2) {
1287 return;
1288 }
1289
11041290 state = STATE_EXTRACTING_PACKAGES;
11051291
11061292 int initialPercentage = percentage;
12921478 * @param defaultColor Default color to use if no color to load
12931479 * @return Color to use
12941480 */
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 }
13011514 }
13021515
13031516 /**
13211534 */
13221535 protected void fatalErrorOccured(String error, Exception e) {
13231536 fatalError = true;
1324 fatalErrorDescription = "Fatal error occured (" + state + "): " + error;
1537 fatalErrorDescription = "This occurred while '" + getDescriptionForState() + "'";
13251538 System.out.println(fatalErrorDescription);
13261539 if(e != null) {
13271540 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 }
3636 * according to the remaining() of a Buffer parameter.
3737 *
3838 * @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 $
4141 */
4242
4343 import java.lang.annotation.Target;
4848 public @interface AutoSize {
4949 String value(); // The name of the Buffer parameter
5050 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.
5152 }
4545 * Generator visitor for the context capabilities generator tool
4646 *
4747 * @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 $
5050 */
5151 public class ContextCapabilitiesGenerator {
5252
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";
6060
6161 public static void generateClassPrologue(PrintWriter writer, boolean context_specific, boolean generate_error_checks) {
6262 writer.println("public class " + Utils.CONTEXT_CAPS_CLASS_NAME + " {");
6363 writer.println("\tstatic final boolean DEBUG = " + Boolean.toString(generate_error_checks) + ";");
6464 writer.println("\tfinal StateTracker tracker = new StateTracker();");
65 writer.println("\tfinal IntBuffer scratch_int_buffer = BufferUtils.createIntBuffer(16);");
6665 writer.println();
6766 if ( !context_specific ) {
6867 writer.println("\tprivate static boolean " + STUBS_LOADED_NAME + " = false;");
108107 writer.print("\t\t\t&& " + CACHED_EXTS_VAR_NAME + ".contains(\"");
109108 writer.print(translateFieldName(super_interface.getDeclaration().getSimpleName()) + "\")");
110109 }
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 }
111116 writer.println(";");
112117 }
113118
164169 public static void generateInitStubs(PrintWriter writer, InterfaceDeclaration d, boolean context_specific) {
165170 if ( d.getMethods().size() > 0 ) {
166171 if ( context_specific ) {
172 final Alias alias_annotation = d.getAnnotation(Alias.class);
173
167174 if ( d.getAnnotation(ForceInit.class) != null )
168175 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(\"");
170180 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 }
171185 writer.print(" && !" + getAddressesInitializerName(d.getSimpleName()) + "(");
172186 if ( d.getAnnotation(DeprecatedGL.class) != null )
173187 writer.print("forwardCompatible");
176190 writer.print(",");
177191 writer.print("supported_extensions");
178192 }
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("))");
181199 writer.print("\t\t\tremove(" + CACHED_EXTS_VAR_NAME + ", \"");
182200 writer.println(translateFieldName(d.getSimpleName()) + "\");");
201 if ( alias_annotation != null )
202 writer.println("\t\t}");
183203 } else {
184204 writer.print("\t\tGLContext." + Utils.STUB_INITIALIZER_NAME + "(" + Utils.getSimpleClassName(d));
185205 writer.println(".class, " + CACHED_EXTS_VAR_NAME + ", \"" + translateFieldName(d.getSimpleName()) + "\");");
209229 writer.print(",");
210230 writer.print("Set supported_extensions");
211231 }
232
233 Alias alias_annotation = d.getAnnotation(Alias.class);
234 boolean aliased = alias_annotation != null && alias_annotation.postfix().length() > 0;
212235
213236 writer.println(") {");
214237 writer.println("\t\treturn ");
266289 writer.print(", ");
267290 }
268291 writer.print("}, ");
292 } else if ( aliased ) {
293 writer.print("GLContext.getFunctionAddress(new String[] {\"" + method.getSimpleName() + "\",\"" + method.getSimpleName() + alias_annotation.postfix() + "\"})) != 0");
269294 } else
270295 writer.print("GLContext.getFunctionAddress(");
271 writer.print("\"" + method.getSimpleName() + "\")) != 0");
296 if ( !aliased )
297 writer.print("\"" + method.getSimpleName() + "\")) != 0");
272298 if ( deprecated || dependent != null )
273299 writer.print(')');
274300 if ( optional )
3131
3232 package org.lwjgl.util.generator;
3333
34 import com.sun.mirror.declaration.*;
35 import com.sun.mirror.type.*;
34 import java.io.PrintWriter;
35 import java.util.Collection;
3636
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;
3941
4042 public class FieldsGenerator {
43
4144 private static void validateField(FieldDeclaration field) {
45 // Check if field is "public static final"
4246 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) ) {
4551 throw new RuntimeException("Field " + field.getSimpleName() + " is not declared public static final");
52 }
53
54 // Check suported types (int, long, float, String)
4655 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
5269 Object field_value = field.getConstantValue();
53 if (field_value == null)
70 if ( field_value == null ) {
5471 throw new RuntimeException("Field " + field.getSimpleName() + " has no initial value");
72 }
5573 }
5674
57 private static void generateField(PrintWriter writer, FieldDeclaration field) {
75 private static void generateField(PrintWriter writer, FieldDeclaration field, FieldDeclaration prev_field) {
5876 validateField(field);
5977
6078 Object value = field.getConstantValue();
6179 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 }
6692
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
6897 // 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);
70106 }
71107
72108 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 }
75118 }
76119
77120 }
3939 @Target({ElementType.PARAMETER, ElementType.METHOD})
4040 public @interface GLpointer {
4141 String value(); // The native pointer type.
42 boolean canBeNull() default false; // Whether the pointer may be null.
4243 }
4949 * Generator visitor for the generator tool
5050 *
5151 * @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 $
5454 */
5555 public class GeneratorVisitor extends SimpleDeclarationVisitor {
5656 private final AnnotationProcessorEnvironment env;
179179 java_writer.println();
180180 java_writer.println("package " + d.getPackage().getQualifiedName() + ";");
181181 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.*;");
186183 java_writer.println("import java.nio.*;");
187184 java_writer.println();
188185 Utils.printDocComment(java_writer, d);
203200 java_writer.println();
204201 if (is_final) {
205202 // 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) {
208206 java_writer.println();
209 }
210 if (d.getMethods().size() > 0 && !context_specific)
211207 java_writer.println("\tstatic native void " + Utils.STUB_INITIALIZER_NAME + "() throws LWJGLException;");
208 }
212209 JavaMethodsGenerator.generateMethodsJava(env, type_map, java_writer, d, generate_error_checks, context_specific);
213210 java_writer.println("}");
214211 java_writer.close();
3636 * This class generates the methods in the generated java source files.
3737 *
3838 * @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 $
4141 */
4242
4343 import com.sun.mirror.apt.*;
260260 // DISABLED: indirect buffer support
261261 //printNondirectParameterCopies(writer, method, mode);
262262 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
266269 Utils.printGLReturnPost(writer, method, method.getAnnotation(GLreturn.class));
267270 }
268271 writer.println("\t}");
383386 String auto_parameter_name = auto_type_annotation.value();
384387 ParameterDeclaration auto_target_param = Utils.findParameter(method, auto_parameter_name);
385388 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()");
387393 // Shift the remaining if the target parameter is multityped and there's no AutoType to track type
388394 boolean shift_remaining = !hasAnyParameterAutoTypeAnnotation(method, auto_target_param) && Utils.isParameterMultiTyped(auto_target_param);
389395 if (shift_remaining) {
442448 writer.print(offset == null ? "0" : offset);
443449 } else
444450 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 }
447458 }
448459 }
449460 }
489500 cachedReference != null &&
490501 (mode != Mode.BUFFEROBJECT || param.getAnnotation(BufferObject.class) == null) &&
491502 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).");
493504 if(cachedReference.name().length() > 0) {
494505 writer.print(cachedReference.name());
495506 } else {
3535 * Various utility methods to the generator.
3636 *
3737 * @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 $
4040 */
4141
4242 import java.io.PrintWriter;
165165 return null;
166166 }
167167
168 // DISABLED: We always generate indirect methods. (affects OpenAL only at the time of this change)
168169 public static boolean isMethodIndirect(boolean generate_error_checks, boolean context_specific, MethodDeclaration method) {
170 /*
169171 for (ParameterDeclaration param : method.getParameters()) {
170172 if (isAddressableType(param.getType()) || getParameterAutoAnnotation(param) != null ||
171173 param.getAnnotation(Constant.class) != null)
175177 method.getAnnotation(CachedResult.class) != null ||
176178 (generate_error_checks && method.getAnnotation(NoErrorCheck.class) == null) ||
177179 context_specific;
180 */
181 return true;
178182 }
179183
180184 public static String getNativeQualifiedName(String qualified_name) {
132132 typedef uint64_t GLuint64;
133133 typedef struct __GLsync *GLsync;
134134
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
135138 /* helper stuff */
136139
137140 /* initializes everything, call this right after the rc is created. the function returns true if successful */
8585 int length;
8686 int i=1;
8787
88 if(alcString == NULL) {
88 if (alcString == NULL) {
8989 return NULL;
9090 }
9191
9393 // These are encoded using \0 between elements and a finishing \0\0
9494 switch(token) {
9595 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 }
97104 case 0x1013: // ALC_ALL_DEVICES_SPECIFIER
98105 while (alcString[i - 1] != '\0' || alcString[i] != '\0') {
99106 i++;
100107 }
101108 length = i + 1;
102109 break;
103 default:
110 default: // e.g. ALC_DEFAULT_ALL_DEVICES_SPECIFIER
104111 length = strlen(alcString);
105112 }
106113 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 }
3030 */
3131
3232 /**
33 * $Id: context.c 3116 2008-08-19 16:46:03Z spasi $
33 * $Id: context.c 3357 2010-06-02 23:35:38Z spasi $
3434 *
3535 * Include file to access public window features
3636 *
3737 * @author elias_naur <elias_naur@users.sourceforge.net>
38 * @version $Revision: 3116 $
38 * @version $Revision: 3357 $
3939 */
4040
4141 #include <jni.h>
118118 int depth = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "depth", "I"));
119119 int stencil = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stencil", "I"));
120120 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"));
121122 int num_aux_buffers = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "num_aux_buffers", "I"));
122123 int accum_bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_bpp", "I"));
123124 int accum_alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_alpha", "I"));
160161 // Assume the caller has checked support for multisample
161162 if (samples > 0) {
162163 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 }
164168 }
165169 if (sRGB) {
166170 putAttrib(&attrib_list, GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB); putAttrib(&attrib_list, True);
198202 int depth = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "depth", "I"));
199203 int stencil = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stencil", "I"));
200204 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"));
201206 int num_aux_buffers = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "num_aux_buffers", "I"));
202207 int accum_bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_bpp", "I"));
203208 int accum_alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_alpha", "I"));
227232 // Assume the caller has checked support for multisample
228233 if (samples > 0) {
229234 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);
231238 }
232239 if (sRGB)
233240 putAttrib(&attrib_list, GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB);
288295 throwException(env, "Samples > 0 specified but there's no support for GLX_ARB_multisample");
289296 return false;
290297 }
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 }
291303 bool floating_point = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point", "Z"));
292304 if (floating_point && !(extension_flags.GLX13 && extension_flags.GLX_ARB_fbconfig_float)) { // We need GLX13 to support floating point
293305 throwException(env, "Floating point specified but there's no support for GLX_ARB_fbconfig_float");
159159 extension_flags->GLX_EXT_fbconfig_packed_float = GLXQueryExtension(disp, screen, "GLX_EXT_fbconfig_packed_float");
160160 extension_flags->GLX_ARB_framebuffer_sRGB = GLXQueryExtension(disp, screen, "GLX_ARB_framebuffer_sRGB") || GLXQueryExtension(disp, screen, "GLX_EXT_framebuffer_sRGB");
161161 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");
162163 }
163164
164165 bool extgl_Open(JNIEnv *env) {
270270 #define GLX_CONTEXT_DEBUG_BIT_ARB 0x0001
271271 #define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002
272272
273 /* GLX_NV_multisample_coverage */
274 #define GLX_COVERAGE_SAMPLES_NV 100001
275 #define GLX_COLOR_SAMPLES_NV 0x20B3
276
277
273278 typedef XID GLXContextID;
274279 typedef XID GLXPixmap;
275280 typedef XID GLXDrawable;
345350 bool GLX_EXT_fbconfig_packed_float;
346351 bool GLX_ARB_framebuffer_sRGB;
347352 bool GLX_ARB_create_context;
353 bool GLX_NV_multisample_coverage;
348354 } GLXExtensions;
349355
350356 /* Add _ to global symbols to avoid symbol clash with the OpenGL library */
0 /*
0 /*
11 * Copyright (c) 2002-2008 LWJGL Project
22 * All rights reserved.
3 *
3 *
44 * 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
66 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
7 *
8 * * Redistributions of source code must retain the above copyright
99 * notice, this list of conditions and the following disclaimer.
1010 *
1111 * * Redistributions in binary form must reproduce the above copyright
1212 * notice, this list of conditions and the following disclaimer in the
1313 * documentation and/or other materials provided with the distribution.
1414 *
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
1717 * from this software without specific prior written permission.
18 *
18 *
1919 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2020 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2121 * 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
2626 * 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
2828 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2929 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030 */
3131
3232 /**
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 $
3434 *
3535 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2985 $
36 * @version $Revision: 3358 $
3737 */
3838
3939 #include <jni.h>
0 /*
0 /*
11 * Copyright (c) 2002-2008 LWJGL Project
22 * All rights reserved.
3 *
3 *
44 * 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
66 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
7 *
8 * * Redistributions of source code must retain the above copyright
99 * notice, this list of conditions and the following disclaimer.
1010 *
1111 * * Redistributions in binary form must reproduce the above copyright
1212 * notice, this list of conditions and the following disclaimer in the
1313 * documentation and/or other materials provided with the distribution.
1414 *
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
1717 * from this software without specific prior written permission.
18 *
18 *
1919 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2020 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2121 * 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
2626 * 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
2828 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2929 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030 */
3131
3232 /**
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 $
3434 *
3535 * Linux Pbuffer.
3636 *
3737 * @author elias_naur <elias_naur@users.sourceforge.net>
38 * @version $Revision: 2985 $
38 * @version $Revision: 3358 $
3939 */
4040
4141 #include <stdlib.h>
3030 */
3131
3232 /**
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 $
3434 *
3535 * @author elias_naue <elias_naur@users.sourceforge.net>
36 * @version $Revision: 3139 $
36 * @version $Revision: 3377 $
3737 */
3838
3939 #include <malloc.h>
186186 int depth = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "depth", "I"));
187187 int stencil = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stencil", "I"));
188188 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"));
189190 int num_aux_buffers = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "num_aux_buffers", "I"));
190191 int accum_bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_bpp", "I"));
191192 int accum_alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_alpha", "I"));
219220 if (pbuffer) {
220221 putAttrib(&attrib_list, WGL_DRAW_TO_PBUFFER_ARB); putAttrib(&attrib_list, TRUE);
221222 }
222 if (!getBooleanProperty(env, "org.lwjgl.opengl.Display.allowSoftwareOpenGL"))
223 if (!getBooleanProperty(env, "org.lwjgl.opengl.Display.allowSoftwareOpenGL")) {
223224 putAttrib(&attrib_list, WGL_ACCELERATION_ARB); putAttrib(&attrib_list, WGL_FULL_ACCELERATION_ARB);
225 }
224226 putAttrib(&attrib_list, WGL_PIXEL_TYPE_ARB); putAttrib(&attrib_list, pixel_type);
225227 putAttrib(&attrib_list, WGL_DOUBLE_BUFFER_ARB); putAttrib(&attrib_list, double_buffer ? TRUE : FALSE);
226228 putAttrib(&attrib_list, WGL_SUPPORT_OPENGL_ARB); putAttrib(&attrib_list, TRUE);
233235 // Assume caller checked extension availability
234236 if (samples > 0) {
235237 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 }
237242 }
238243 putAttrib(&attrib_list, WGL_ACCUM_BITS_ARB); putAttrib(&attrib_list, accum_bpp);
239244 putAttrib(&attrib_list, WGL_ACCUM_ALPHA_BITS_ARB); putAttrib(&attrib_list, accum_alpha);
384389 return findPixelFormatFromBPP(env, hdc, pixel_format, bpp, double_buffer);
385390 }
386391
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) {
388393 if (!wglMakeCurrent(dummy_hdc, dummy_hglrc)) {
389394 throwException(env, "Could not bind context to dummy window");
390395 return false;
397402 }
398403 if (samples > 0 && !extensions->WGL_ARB_multisample) {
399404 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");
400409 return false;
401410 }
402411 /*
434443 jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format);
435444
436445 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"));
437447 bool floating_point = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point", "Z"));
438448 bool floating_point_packed = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point_packed", "Z"));
439449 bool sRGB = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "sRGB", "Z"));
460470 // Save the current HDC and HGLRC to avoid disruption
461471 saved_current_hdc = wglGetCurrentDC();
462472 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)) {
464474 pixel_format_id = findPixelFormatARB(env, hdc, &extensions, pixel_format, pixelFormatCaps, use_hdc_bpp, window, pbuffer, double_buffer);
465475 }
466476 wglMakeCurrent(saved_current_hdc, saved_current_hglrc);
151151 extensions->WGL_ARB_framebuffer_sRGB = WGLQueryExtension(extensions, "WGL_ARB_framebuffer_sRGB") || WGLQueryExtension(extensions, "WGL_EXT_framebuffer_sRGB");
152152 extensions->WGL_EXT_pixel_format_packed_float = WGLQueryExtension(extensions, "WGL_EXT_pixel_format_packed_float");
153153 extensions->WGL_ARB_create_context = WGLQueryExtension(extensions, "WGL_ARB_create_context");
154 extensions->WGL_NV_multisample_coverage = WGLQueryExtension(extensions, "WGL_NV_multisample_coverage");
154155 }
155156
156157 static void extgl_InitWGLEXTExtensionsString(WGLExtensions *extensions) {
199199
200200 typedef HGLRC (APIENTRY * wglCreateContextAttribsARBPROC) (HDC hDC, HGLRC hShareContext, const int *attribList);
201201
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
202211 typedef struct {
203212 bool WGL_ARB_buffer_region;
204213 bool WGL_ARB_extensions_string;
216225 bool WGL_ARB_framebuffer_sRGB;
217226 bool WGL_EXT_pixel_format_packed_float;
218227 bool WGL_ARB_create_context;
228 bool WGL_NV_multisample_coverage;
219229
220230 wglGetExtensionsStringEXTPROC wglGetExtensionsStringEXT;
221231
0 /*
0 /*
11 * Copyright (c) 2002-2008 LWJGL Project
22 * All rights reserved.
3 *
3 *
44 * 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
66 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
7 *
8 * * Redistributions of source code must retain the above copyright
99 * notice, this list of conditions and the following disclaimer.
1010 *
1111 * * Redistributions in binary form must reproduce the above copyright
1212 * notice, this list of conditions and the following disclaimer in the
1313 * documentation and/or other materials provided with the distribution.
1414 *
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
1717 * from this software without specific prior written permission.
18 *
18 *
1919 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2020 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2121 * 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
2626 * 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
2828 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2929 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030 */
3131
3232 /**
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 $
3434 *
3535 * Windows Pbuffer.
3636 *
3737 * @author elias_naur <elias_naur@users.sourceforge.net>
38 * @version $Revision: 3149 $
38 * @version $Revision: 3358 $
3939 */
4040
4141 #include <stdlib.h>
6060 HDC saved_hdc;
6161 HGLRC saved_context;
6262 int pixel_format_id;
63
63
6464 dummy_hwnd = createDummyWindow(origin_x, origin_y);
6565 if (dummy_hwnd == NULL) {
6666 throwException(env, "Could not create dummy window");
135135 const int *pBufferAttribs_ptr;
136136 WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
137137 int pixel_format_id;
138
138
139139 if ( pBufferAttribs != NULL ) {
140140 pBufferAttribs_ptr = (const int *)(*env)->GetDirectBufferAddress(env, pBufferAttribs);
141141 } else {
3030 */
3131
3232 /**
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 $
3434 *
3535 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 3148 $
36 * @version $Revision: 3358 $
3737 */
3838
3939 #include <jni.h>
4141 #include "context.h"
4242 #include "common_tools.h"
4343
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) {
4645 return newJavaManagedByteBuffer(env, sizeof(WindowsPeerInfo));
4746 }
4847
4343 * AL.h version 1.0
4444 *
4545 * @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 $
4848 */
4949 public interface AL10 {
5050 /** Bad value */
249249 int AL_FREQUENCY = 0x2001;
250250
251251 /**
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.
256254 */
257255 int AL_BITS = 0x2002;
258256
259257 /**
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.
264260 */
265261 int AL_CHANNELS = 0x2003;
266262
267263 /**
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.
272265 */
273266 int AL_SIZE = 0x2004;
274267
275268 /**
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
281274 int AL_DATA = 0x2005;
282275
283276 /**
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 &lt;severity&gt;:
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 &lt;category&gt;:
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 &lt;identifier&gt; 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 }
3030 */
3131 package org.lwjgl.opengl;
3232
33 import org.lwjgl.util.generator.Alias;
34
35 @Alias("EXT_texture_buffer_object_rgb32")
3336 public interface ARB_texture_buffer_object_rgb32 {
3437 }
3030 */
3131 package org.lwjgl.opengl;
3232
33 import org.lwjgl.util.generator.Alias;
3334 import org.lwjgl.util.generator.Extension;
3435
3536 @Extension(postfix = "ARB", className = "ARBTextureCompressionBPTC")
37 @Alias("EXT_texture_compression_bptc")
3638 public interface ARB_texture_compression_bptc {
3739
3840 /**
7070 @StripPostfix("params")
7171 void glGetObjectBufferivATI(@GLuint int buffer, @GLenum int pname, @OutParameter @Check IntBuffer params);
7272
73 @Alternate("glGetObjectBufferivATI")
74 @GLreturn("params")
75 @StripPostfix("params")
76 void glGetObjectBufferivATI2(@GLuint int buffer, @GLenum int pname, @OutParameter IntBuffer params);
77
7378 void glFreeObjectBufferATI(@GLuint int buffer);
7479
7580 void glArrayObjectATI(@GLenum int array, int size, @GLenum int type, @GLsizei int stride, @GLuint int buffer, @GLuint int offset);
518518 value parameters
519519 */
520520
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)")
522522 @Dependent("OpenGL30")
523523 void glEnableClientStateiEXT(@GLenum int array, @GLuint int index);
524524
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)")
526526 @Dependent("OpenGL30")
527527 void glDisableClientStateiEXT(@GLenum int array, @GLuint int index);
528528
564564 and before state value parameters
565565 */
566566
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)")
568568 @Dependent("OpenGL30")
569569 @StripPostfix("params")
570570 void glGetFloati_vEXT(@GLenum int pname, @GLuint int index, @OutParameter @Check("16") FloatBuffer params);
575575 @StripPostfix("params")
576576 void glGetFloati_vEXT2(@GLenum int pname, @GLuint int index, @OutParameter FloatBuffer params);
577577
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)")
579579 @Dependent("OpenGL30")
580580 @StripPostfix("params")
581581 void glGetDoublei_vEXT(@GLenum int pname, @GLuint int index, @OutParameter @Check("16") DoubleBuffer params);
586586 @StripPostfix("params")
587587 void glGetDoublei_vEXT2(@GLenum int pname, @GLuint int index, @OutParameter DoubleBuffer params);
588588
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)")
590590 @Dependent("OpenGL30")
591591 @StripPostfix(value = "params", hasPostfix = false)
592592 void glGetPointeri_vEXT(@GLenum int pname, @GLuint int index, @Result @GLvoid ByteBuffer params);
13421342 OpenGL 3.1: New buffer data copy command
13431343 */
13441344
1345 @Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
13451346 @Dependent("OpenGL31,GL_ARB_copy_buffer")
13461347 void glNamedCopyBufferSubDataEXT(@GLuint int readBuffer, @GLuint int writeBuffer, @GLintptr long readoffset, @GLintptr long writeoffset, @GLsizeiptr long size);
13471348
13851386 and change the final parameter from "const void *" to "intptr offset"
13861387 */
13871388
1389 @Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
13881390 @Dependent("OpenGL30")
13891391 @DeprecatedGL
13901392 void glVertexArrayVertexOffsetEXT(@GLuint int vaobj, @GLuint int buffer, int size, @GLenum int type, @GLsizei int stride, @GLintptr long offset);
13911393
1394 @Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
13921395 @Dependent("OpenGL30")
13931396 @DeprecatedGL
13941397 void glVertexArrayColorOffsetEXT(@GLuint int vaobj, @GLuint int buffer, int size, @GLenum int type, @GLsizei int stride, @GLintptr long offset);
13951398
1399 @Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
13961400 @Dependent("OpenGL30")
13971401 @DeprecatedGL
13981402 void glVertexArrayEdgeFlagOffsetEXT(@GLuint int vaobj, @GLuint int buffer, @GLsizei int stride, @GLintptr long offset);
13991403
1404 @Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
14001405 @Dependent("OpenGL30")
14011406 void glVertexArrayIndexOffsetEXT(@GLuint int vaobj, @GLuint int buffer, @GLenum int type, @GLsizei int stride, @GLintptr long offset);
14021407
1408 @Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
14031409 @Dependent("OpenGL30")
14041410 @DeprecatedGL
14051411 void glVertexArrayNormalOffsetEXT(@GLuint int vaobj, @GLuint int buffer, @GLenum int type, @GLsizei int stride, @GLintptr long offset);
14061412
1413 @Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
14071414 @Dependent("OpenGL30")
14081415 @DeprecatedGL
14091416 void glVertexArrayTexCoordOffsetEXT(@GLuint int vaobj, @GLuint int buffer, int size, @GLenum int type, @GLsizei int stride, @GLintptr long offset);
14101417
1418 @Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
14111419 @Dependent("OpenGL30")
14121420 @DeprecatedGL
14131421 void glVertexArrayMultiTexCoordOffsetEXT(@GLuint int vaobj, @GLuint int buffer, @GLenum int texunit, int size, @GLenum int type, @GLsizei int stride, @GLintptr long offset);
14141422
1423 @Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
14151424 @Dependent("OpenGL30")
14161425 @DeprecatedGL
14171426 void glVertexArrayFogCoordOffsetEXT(@GLuint int vaobj, @GLuint int buffer, @GLenum int type, @GLsizei int stride, @GLintptr long offset);
14181427
1428 @Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
14191429 @Dependent("OpenGL30")
14201430 @DeprecatedGL
14211431 void glVertexArraySecondaryColorOffsetEXT(@GLuint int vaobj, @GLuint int buffer, int size, @GLenum int type, @GLsizei int stride, @GLintptr long offset);
14221432
1433 @Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
14231434 @Dependent("OpenGL30")
14241435 void glVertexArrayVertexAttribOffsetEXT(@GLuint int vaobj, @GLuint int buffer, @GLuint int index, int size, @GLenum int type, boolean normalized, @GLsizei int stride, @GLintptr long offset);
14251436
1437 @Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
14261438 @Dependent("OpenGL30")
14271439 void glVertexArrayVertexAttribIOffsetEXT(@GLuint int vaobj, @GLuint int buffer, @GLuint int index, int size, @GLenum int type, @GLsizei int stride, @GLintptr long offset);
14281440
14321444 "uint vaobj" parameter
14331445 */
14341446
1447 @Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
14351448 @Dependent("OpenGL30")
14361449 void glEnableVertexArrayEXT(@GLuint int vaobj, @GLenum int array);
14371450
1451 @Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
14381452 @Dependent("OpenGL30")
14391453 void glDisableVertexArrayEXT(@GLuint int vaobj, @GLenum int array);
14401454
14441458 and add an initial "uint vaobj" parameter
14451459 */
14461460
1461 @Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
14471462 @Dependent("OpenGL30")
14481463 void glEnableVertexArrayAttribEXT(@GLuint int vaobj, @GLuint int index);
14491464
1465 @Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
14501466 @Dependent("OpenGL30")
14511467 void glDisableVertexArrayAttribEXT(@GLuint int vaobj, @GLuint int index);
14521468
14541470 OpenGL 3.0: New queries for vertex array objects
14551471 */
14561472
1473 @Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
14571474 @Dependent("OpenGL30")
14581475 @StripPostfix("param")
14591476 void glGetVertexArrayIntegervEXT(@GLuint int vaobj, @GLenum int pname, @OutParameter @Check("16") IntBuffer param);
14641481 @StripPostfix("param")
14651482 void glGetVertexArrayIntegervEXT2(@GLuint int vaobj, @GLenum int pname, @OutParameter IntBuffer param);
14661483
1484 @Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
14671485 @Dependent("OpenGL30")
14681486 @StripPostfix("param")
14691487 void glGetVertexArrayPointervEXT(@GLuint int vaobj, @GLenum int pname, @Result @GLvoid ByteBuffer param);
14701488
1489 @Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
14711490 @Dependent("OpenGL30")
14721491 @StripPostfix(value = "param")
14731492 void glGetVertexArrayIntegeri_vEXT(@GLuint int vaobj, @GLuint int index, @GLenum int pname, @OutParameter @Check("16") IntBuffer param);
14781497 @StripPostfix(value = "param", postfix = "_v")
14791498 void glGetVertexArrayIntegeri_vEXT2(@GLuint int vaobj, @GLuint int index, @GLenum int pname, @OutParameter IntBuffer param);
14801499
1500 @Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
14811501 @Dependent("OpenGL30")
14821502 @StripPostfix(value = "param")
14831503 void glGetVertexArrayPointeri_vEXT(@GLuint int vaobj, @GLuint int index, @GLenum int pname, @Result @GLvoid ByteBuffer param);
15011521 *
15021522 * @return A ByteBuffer representing the mapped buffer memory.
15031523 */
1524 @Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
15041525 @Dependent("OpenGL30")
15051526 @CachedResult(isRange = true)
15061527 @GLvoid
15071528 @AutoResultSize("length")
15081529 ByteBuffer glMapNamedBufferRangeEXT(@GLuint int buffer, @GLintptr long offset, @GLsizeiptr long length, @GLbitfield int access);
15091530
1531 @Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
15101532 @Dependent("OpenGL30")
15111533 void glFlushMappedNamedBufferRangeEXT(@GLuint int buffer, @GLintptr long offset, @GLsizeiptr long length);
15121534
3838 * The core OpenGL1.1 API.
3939 *
4040 * @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 $
4343 */
4444 @DeprecatedGL
4545 public interface GL11 {
11461146 String glGetString(int name);
11471147
11481148 @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);
11501150
11511151 @DeprecatedGL
11521152 boolean glIsList(@GLuint int list);
12511251 void glMatrixMode(@GLenum int mode);
12521252
12531253 @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);
12551255
12561256 void glPolygonOffset(float factor, float units);
12571257
7373 int GL_BUFFER_MAPPED = 0x88BC;
7474 int GL_BUFFER_MAP_POINTER = 0x88BD;
7575
76 int FOG_COORD_SRC = GL14.GL_FOG_COORDINATE_SOURCE;
76 int GL_FOG_COORD_SRC = GL14.GL_FOG_COORDINATE_SOURCE;
7777 int GL_FOG_COORD = GL14.GL_FOG_COORDINATE;
7878 int GL_CURRENT_FOG_COORD = GL14.GL_CURRENT_FOG_COORDINATE;
7979 int GL_FOG_COORD_ARRAY_TYPE = GL14.GL_FOG_COORDINATE_ARRAY_TYPE;
4141
4242 void glGenFencesNV(@AutoSize("piFences") @GLsizei int n, @OutParameter @GLuint IntBuffer piFences);
4343
44 @Alternate("glGenFencesNV")
45 @GLreturn("piFences")
46 void glGenFencesNV2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer piFences);
47
4448 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);
4552
4653 void glSetFenceNV(@GLuint int fence, @GLenum int condition);
4754
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 &lt;pname&gt; 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 }