Codebase list lwjgl / 6d47d60
Merge branch 'upstream' Michael Gilbert 13 years ago
527 changed file(s) with 31672 addition(s) and 7801 deletion(s). Raw diff Collapse all Expand all
55 <import file="platform_build/build-generator.xml"/>
66 <import file="platform_build/build-applet.xml"/>
77 <import file="platform_build/build-webstart.xml"/>
8 <import file="platform_build/build-maven.xml"/>
89
910 <!-- ================================================================== -->
1011 <!-- Everything below this line is targets. -->
1516 <!-- Initialize build -->
1617 <!-- ================================================================== -->
1718 <target name="-initialize">
18 <mkdir dir="${lwjgl.bin}" taskname="initialiazing bin folder" />
19 <mkdir dir="${lwjgl.bin}/lwjgl" taskname="initialiazing bin folder" />
20 <mkdir dir="${lwjgl.lib}" taskname="initialiazing lib folder" />
21 <mkdir dir="${lwjgl.dist}" taskname="initialiazing dist folder" />
22 <mkdir dir="${lwjgl.docs}/javadoc" taskname="initialiazing docs folder" />
23 <mkdir dir="${lwjgl.res}" taskname="initialiazing res folder" />
24 <mkdir dir="${lwjgl.temp}" taskname="initialiazing temp folder" />
25 <mkdir dir="${lwjgl.temp}/jar" taskname="initialiazing temp/jar folder" />
26 <mkdir dir="${lwjgl.temp}/doc" taskname="initialiazing temp/doc folder" />
27 <mkdir dir="${lwjgl.temp}/res" taskname="initialiazing temp/res folder" />
28 <mkdir dir="${lwjgl.temp}/native" taskname="initialiazing temp/native folder" />
29 <mkdir dir="${lwjgl.temp}/native/windows" taskname="initialiazing temp/windows folder" />
30 <mkdir dir="${lwjgl.temp}/native/linux" taskname="initialiazing temp/linux folder" />
31 <mkdir dir="${lwjgl.temp}/native/macosx" taskname="initialiazing temp/macosx folder" />
32 <mkdir dir="${lwjgl.temp}/native/solaris" taskname="initialiazing temp/solaris folder" />
33 </target>
34
19 <mkdir dir="${lwjgl.bin}" taskname="initialiazing bin folder" />
20 <mkdir dir="${lwjgl.bin}/lwjgl" taskname="initialiazing native bin folder" />
21 <mkdir dir="${lwjgl.lib}" taskname="initialiazing lib folder" />
22 <mkdir dir="${lwjgl.dist}" taskname="initialiazing dist folder" />
23 <mkdir dir="${lwjgl.docs}/javadoc" taskname="initialiazing docs folder" />
24 <mkdir dir="${lwjgl.res}" taskname="initialiazing res folder" />
25 <mkdir dir="${lwjgl.temp}" taskname="initialiazing temp folder" />
26 <mkdir dir="${lwjgl.temp}/jar" taskname="initialiazing temp/jar folder" />
27 <mkdir dir="${lwjgl.temp}/doc" taskname="initialiazing temp/doc folder" />
28 <mkdir dir="${lwjgl.temp}/res" taskname="initialiazing temp/res folder" />
29 <mkdir dir="${lwjgl.temp}/native" taskname="initialiazing temp/native folder" />
30 <mkdir dir="${lwjgl.temp}/native/windows" taskname="initialiazing temp/windows folder" />
31 <mkdir dir="${lwjgl.temp}/native/linux" taskname="initialiazing temp/linux folder" />
32 <mkdir dir="${lwjgl.temp}/native/macosx" taskname="initialiazing temp/macosx folder" />
33 <mkdir dir="${lwjgl.temp}/native/solaris" taskname="initialiazing temp/solaris folder" />
34 </target>
35
3536 <!-- Cleans up any files created during the execution of this script -->
36 <target name="clean" description="Cleans the diectories controlled by this ant script" depends="clean-generated">
37 <delete dir="${lwjgl.temp}" quiet="true" failonerror="false" taskname="cleaning temp folder" />
38 <delete dir="${lwjgl.docs}/javadoc" quiet="true" failonerror="false" taskname="cleaning javadoc folder" />
39 <delete dir="${lwjgl.bin}" quiet="true" failonerror="false" taskname="cleaning bin folder" />
40 </target>
41
37 <target name="clean" description="Cleans all directories controlled by this ant script" depends="clean-java, clean-native"/>
38
39 <!-- Cleans up any non-native files created during the execution of this script -->
40 <target name="clean-java" description="Cleans non-native files generated by this ant script" depends="clean-generated">
41 <delete dir="${lwjgl.temp}" quiet="true" failonerror="false" taskname="cleaning temp folder" />
42 <delete dir="${lwjgl.docs}/javadoc" quiet="true" failonerror="false" taskname="cleaning javadoc folder" />
43 <!-- Delete java classes only to avoid unnecessary native recompilation -->
44 <delete dir="${lwjgl.bin}/org" quiet="true" failonerror="false" taskname="cleaning bin folder" />
45 </target>
46
47 <!-- Useful when we need to force native recompilation -->
48 <target name="clean-native" description="Cleans native files generated by this ant script" depends="clean-generated-native">
49 <delete dir="${lwjgl.bin}/lwjgl" quiet="true" failonerror="false" taskname="cleaning native bin folder" />
50 </target>
51
4252 <!-- Creates a distribution of LWJGL -->
4353 <target name="release" description="Creates a distribution of LWJGL using supplied native binaries">
4454 <!-- Warn user -->
4555 <echo message="Before running the release target, please manually compile all platforms and place required files in ${lwjgl.lib}/windows, ${lwjgl.lib}/linux and ${lwjgl.lib}/macosx${line.separator}Missing files will result in a successfull built, but with incomplete release zips"/>
46 <input
47 message="All data in the ${lwjgl.dist} folder will be deleted. Continue? "
48 validargs="yes,no"
49 addproperty="do.delete"
50 />
51 <condition property="do.abort">
52 <equals arg1="no" arg2="${do.delete}"/>
53 </condition>
54 <fail if="do.abort">Build aborted by user.</fail>
55
56 <!-- prepare -->
57 <delete dir="${lwjgl.dist}" quiet="true" failonerror="false" />
58 <antcall target="clean" />
59 <antcall target="-initialize" />
60
61 <!-- compile and create jars -->
62 <antcall target="generate-debug"/>
63 <antcall target="compile" />
64 <antcall target="-createdebugjars" />
56 <input
57 message="All data in the ${lwjgl.dist} folder will be deleted. Continue? "
58 validargs="yes,no"
59 addproperty="do.delete"
60 />
61 <condition property="do.abort">
62 <equals arg1="no" arg2="${do.delete}"/>
63 </condition>
64 <fail if="do.abort">Build aborted by user.</fail>
65
66 <!-- prepare -->
67 <delete dir="${lwjgl.dist}" quiet="true" failonerror="false" />
68 <antcall target="clean-java" />
69 <antcall target="-initialize" />
70
71 <!-- compile and create debug jars -->
72 <antcall target="generate-debug" />
73 <antcall target="compile" />
74 <antcall target="-createdebugjars" />
75
6576 <!-- Generator will skip all templates if we don't clean -->
66 <delete dir="${lwjgl.bin}" quiet="true" failonerror="false" taskname="cleaning bin folder" />
67 <mkdir dir="${lwjgl.bin}" taskname="initialiazing bin folder" />
68 <antcall target="generate-all"/>
69 <antcall target="compile" />
70 <antcall target="-createjars" />
71 <antcall target="-jars_NoDEP" />
72 <antcall target="javadoc" />
73 <antcall target="applet-release" />
74
75 <!-- copy resources to res folder -->
76 <copy todir="${lwjgl.temp}/res">
77 <fileset dir="res"/>
78 </copy>
79
80 <!-- copy docs -->
77 <delete dir="${lwjgl.bin}/org" quiet="true" failonerror="false" taskname="cleaning bin folder" />
78
79 <!-- compile and create jars -->
80 <antcall target="generate-all" />
81 <antcall target="compile" />
82 <antcall target="-createjars" />
83
84 <antcall target="-jars_NoDEP" />
85 <antcall target="javadoc" />
86 <antcall target="applet-release" />
87
88 <!-- copy resources to res folder -->
89 <copy todir="${lwjgl.temp}/res">
90 <fileset dir="res"/>
91 </copy>
92
93 <!-- copy docs -->
8194 <copy todir="${lwjgl.temp}/doc">
8295 <fileset dir="${lwjgl.docs}">
8396 <patternset refid="lwjgl-docs.fileset" />
8497 </fileset>
85 </copy>
86
98 </copy>
99
87100 <!-- create distribution from files in libs/ and temp/ -->
88101 <antcall target="-distribution_javadoc" />
89102 <antcall target="-distribution_source" />
104117 </fileset>
105118 </move>
106119 </target>
107
120
108121 <!-- Packages the java files -->
109122 <target name="-createdebugjars">
110123 <!-- Create lwjgl.jar -->
115128 </manifest>
116129 </jar>
117130 </target>
118
131
119132 <!-- Packages the java files -->
120133 <target name="-createjars">
121134 <!-- Create lwjgl.jar -->
125138 <attribute name="Sealed" value="true"/>
126139 </manifest>
127140 </jar>
128
141
129142 <!-- Create lwjgl_util_applet.jar -->
130143 <jar destfile="${lwjgl.temp}/jar/lwjgl_util_applet.jar" taskname="lwjgl_util_applet.jar">
144 <fileset dir="${lwjgl.res}" includes="applet*"/>
131145 <fileset refid="lwjgl_util_applet.fileset" />
132146 <manifest>
133147 <attribute name="Sealed" value="true"/>
150164 <target name="-distribute">
151165 <delete>
152166 <fileset dir="${lwjgl.temp}/native/" includes="**/*"/>
153 </delete>
167 </delete>
154168
155169 <copy todir="${lwjgl.temp}/jar">
156170 <fileset dir="${lwjgl.lib}/" includes="*.jar"/>
174188 <fileset dir="${lwjgl.lib}/solaris">
175189 <patternset refid="lwjgl-solaris.fileset" />
176190 </fileset>
177 </copy>
178
191 </copy>
192
179193 <!-- create base package -->
180194 <zip destfile="${lwjgl.dist}/lwjgl-${lwjgl.version}.zip">
181195 <zipfileset dir="${lwjgl.temp}" prefix="lwjgl-${lwjgl.version}/">
182196 <patternset refid="lwjgl_base"/>
183 </zipfileset>
197 </zipfileset>
184198 </zip>
185
199
186200 <!-- create applet package -->
187201 <zip destfile="${lwjgl.dist}/lwjgl_applet-${lwjgl.version}.zip">
188202 <zipfileset dir="." prefix="lwjgl_applet-${lwjgl.version}/">
189203 <patternset refid="lwjgl_applet"/>
190 </zipfileset>
204 </zipfileset>
191205 </zip>
192206 </target>
193207
195209 <target name="-distribution_javadoc">
196210 <zip destfile="${lwjgl.dist}/lwjgl-docs-${lwjgl.version}.zip" basedir="${lwjgl.docs}" includes="javadoc/**" />
197211 </target>
198
212
199213 <!-- Creates a versioned distribution of the source code -->
200214 <target name="-distribution_source">
201215 <zip destfile="${lwjgl.dist}/lwjgl-source-${lwjgl.version}.zip">
202216 <fileset refid="lwjgl.source.fileset" />
203217 </zip>
204 </target>
205
218 </target>
219
206220 <!-- Generates the native headers from source files -->
207221 <target name="headers" description="invokes javah on java classes" depends="compile">
208222 <javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/linux" force="yes">
218232 <class name="org.lwjgl.opengl.LinuxContextImplementation" />
219233 <class name="org.lwjgl.opengl.LinuxCanvasImplementation" />
220234 </javah>
221
235
222236 <javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/windows" force="yes">
223237 <class name="org.lwjgl.opengl.WindowsKeyboard" />
224238 <class name="org.lwjgl.opengl.WindowsPbufferPeerInfo" />
230244 <class name="org.lwjgl.opengl.WindowsDisplayPeerInfo" />
231245 <class name="org.lwjgl.opengl.WindowsContextImplementation" />
232246 </javah>
233
247
234248 <javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/macosx" force="yes">
235249 <class name="org.lwjgl.MacOSXSysImplementation" />
236250 <class name="org.lwjgl.opengl.MacOSXMouseEventQueue" />
240254 <class name="org.lwjgl.opengl.MacOSXDisplay" />
241255 <class name="org.lwjgl.opengl.MacOSXContextImplementation" />
242256 </javah>
243
257
244258 <javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.headers}" force="yes">
245259 <class name="org.lwjgl.opengl.AWTSurfaceLock" />
246260 <class name="org.lwjgl.DefaultSysImplementation" />
250264 <class name="org.lwjgl.openal.AL" />
251265 <class name="org.lwjgl.opengl.GLContext" />
252266 <class name="org.lwjgl.opengl.Pbuffer" />
253 <class name="org.lwjgl.opengl.AMDDebugOutputCallback" />
267 <class name="org.lwjgl.opengl.CallbackUtil" />
268 <class name="org.lwjgl.opencl.CL" />
269 <class name="org.lwjgl.opencl.CallbackUtil" />
270 <class name="org.lwjgl.BufferUtils" />
254271 </javah>
255272 </target>
256
273
257274 <target name="touch-version">
258275 <touch file="${lwjgl.src.native}/windows/org_lwjgl_opengl_Display.c"/>
259276 <touch file="${lwjgl.src.native}/linux/org_lwjgl_opengl_Display.c"/>
260277 <touch file="${lwjgl.src.native}/macosx/org_lwjgl_opengl_Display.m"/>
261278 </target>
262
279
263280 <target name="version-mismatch">
264281 <loadfile srcfile="${lwjgl.src}/java/org/lwjgl/WindowsSysImplementation.java" property="lwjgl.java.windows.version">
265282 <filterchain>
274291 <containsstring contains="JNI_VERSION ="/>
275292 </tokenfilter>
276293 </filterchain>
277 </loadfile>
294 </loadfile>
278295 <loadfile srcfile="${lwjgl.src}/java/org/lwjgl/MacOSXSysImplementation.java" property="lwjgl.java.macosx.version">
279296 <filterchain>
280297 <tokenfilter>
295312 <containsstring contains="#define org_lwjgl_LinuxSysImplementation_JNI_VERSION"/>
296313 </tokenfilter>
297314 </filterchain>
298 </loadfile>
315 </loadfile>
299316 <loadfile srcfile="${lwjgl.src.native}/macosx/org_lwjgl_MacOSXSysImplementation.h" property="lwjgl.native.macosx.version">
300317 <filterchain>
301318 <tokenfilter>
305322 </loadfile>
306323 <echo>
307324 lwjgl.java.windows.version = ${lwjgl.java.windows.version}
308 lwjgl.native.windows.version = ${lwjgl.native.windows.version}
325 lwjgl.native.windows.version = ${lwjgl.native.windows.version}
309326 lwjgl.java.linux.version = ${lwjgl.java.linux.version}
310 lwjgl.native.linux.version = ${lwjgl.native.linux.version}
327 lwjgl.native.linux.version = ${lwjgl.native.linux.version}
311328 lwjgl.java.macosx.version = ${lwjgl.java.macosx.version}
312 lwjgl.native.macosx.version = ${lwjgl.native.macosx.version}
329 lwjgl.native.macosx.version = ${lwjgl.native.macosx.version}
313330 </echo>
314331 </target>
315
332
316333 <macrodef name="version-check">
317334 <attribute name="platform"/>
318335 <sequential>
319336 <java classname="org.lwjgl.test.NativeTest" logError="false" resultproperty="nativetest.res" outputproperty="nativetest.out" errorproperty="nativetest.err" fork="true">
320337 <jvmarg value="-Djava.library.path=libs/@{platform}"/>
338 <jvmarg value="-Dorg.lwjgl.util.Debug=true"/>
321339 <classpath>
322340 <pathelement path="${lwjgl.bin}"/>
323341 <pathelement path="${java.class.path}"/>
324342 </classpath>
325343 </java>
326
344
327345 <fail message="Unable to load native library: ${nativetest.err}">
328346 <condition>
329347 <not>
331349 </not>
332350 </condition>
333351 </fail>
334
352
335353 <echo message="Successfully executed NativeTest"/>
336354 </sequential>
337355 </macrodef>
338
356
339357 <!-- Compiles the Java source code -->
340358 <target name="compile" description="Compiles the java source code" depends="-initialize">
341 <javac debug="yes" destdir="${lwjgl.bin}" source="1.4" target="1.4" classpath="${lwjgl.lib}/jinput.jar:${lwjgl.lib}/AppleJavaExtensions.jar" taskname="core">
359 <javac debug="yes" destdir="${lwjgl.bin}" source="1.5" target="1.5" classpath="${lwjgl.lib}/jinput.jar:${lwjgl.lib}/AppleJavaExtensions.jar" taskname="core">
360 <!--<compilerarg value="-Xlint:unchecked"/>-->
342361 <src path="${lwjgl.src}/java/"/>
343362 <src path="${lwjgl.src}/generated/"/>
344363 <include name="org/lwjgl/*.java"/>
345364 <include name="org/lwjgl/input/**"/>
346365 <include name="org/lwjgl/opengl/**"/>
347366 <include name="org/lwjgl/openal/**"/>
367 <include name="org/lwjgl/opencl/**"/>
348368 <include name="org/lwjgl/util/**"/>
349369 <exclude name="org/lwjgl/util/generator/**"/>
350370 </javac>
351 <javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" includes="org/lwjgl/test/**" source="1.4" target="1.4" taskname="test" />
352 <javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" includes="org/lwjgl/examples/**" source="1.4" target="1.4" taskname="examples" />
353 </target>
354
355 <target name="compile_native" depends="headers, touch-version, version-mismatch" description="Compiles the native files">
371 <javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" includes="org/lwjgl/test/**" source="1.5" target="1.5" taskname="test" />
372 <javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" includes="org/lwjgl/examples/**" source="1.5" target="1.5" taskname="examples" />
373 </target>
374
375 <target name="compile_native" depends="-initialize, headers, touch-version, version-mismatch" description="Compiles the native files">
356376 <condition property="lwjgl.platform.windows">
357377 <os family="windows" />
358378 </condition>
372392 <os name="Mac OS X" />
373393 </condition>
374394 <antcall target="-compile_native_macosx" />
375 </target>
395 </target>
376396
377397 <!-- Compiles LWJGL on Win32 platforms -->
378398 <target name="-compile_native_win32" if="lwjgl.platform.windows">
408428 <copy file="${lwjgl.bin}/lwjgl/liblwjgl.jnilib" todir="${lwjgl.lib}/macosx"/>
409429 <version-check platform="macosx"/>
410430 </target>
411
431
412432 <target name="repack200" description="Pack200-repack a jar file">
413433 <pack200 src="${input}" destfile="${output}" repack="true"/>
414434 </target>
428448 <arg value="${output}"/>
429449 </java>
430450 </target>
431
451
432452 <target name="compress-sign-class">
433453 <antcall target="repack200">
434454 <param name="input" value="${dir}${jarfile}.jar"/>
441461 </antcall>
442462 <antcall target="lzma">
443463 <param name="input" value="${dir}${jarfile}.jar.pack"/>
444 <param name="output" value="${dir}${jarfile}.jar.pack.lzma"/>
464 <param name="output" value="${outputdir}${jarfile}.jar.pack.lzma"/>
445465 </antcall>
446 <delete file="${dir}${jarfile}-repack.jar"/>
466 <!--delete file="${dir}${jarfile}-repack.jar"/-->
447467 <delete file="${dir}${jarfile}.jar.pack"/>
448 <delete file="${dir}${jarfile}.jar"/>
449 </target>
450
468 <!--delete file="${dir}${jarfile}.jar"/-->
469 <rename src="${dir}${jarfile}-repack.jar" dest="${dir}${jarfile}.jar" replace="yes"/>
470 </target>
471
451472 <target name="compress-resource">
452473 <antcall target="lzma">
453474 <param name="input" value="${input}"/>
454475 <param name="output" value="${output}"/>
455476 </antcall>
456477 </target>
457
478
458479 <target name="applettest" depends="applet">
459480 <exec executable="appletviewer">
460481 <arg value="-J-Djava.security.policy=applet/appletviewer.policy"/>
484505 <sysproperty key="java.library.path" value="${native_path_expanded}"/>
485506 <arg line="${args}"/>
486507 </java>
487 </target>
488
508 </target>
509
489510 <!-- Creates the Javadoc -->
490511 <target name="javadoc" description="Creates javadoc from java source code">
491 <javadoc destdir="${lwjgl.docs}/javadoc" classpath="${lwjgl.lib}/jinput.jar" author="true" version="true" use="true" source="1.4" windowtitle="LWJGL API" useexternalfile="true">
512 <javadoc destdir="${lwjgl.docs}/javadoc" classpath="${lwjgl.lib}/jinput.jar" author="true" version="true" use="true" source="1.5" windowtitle="LWJGL API" useexternalfile="true">
492513 <fileset refid="lwjgl.javadoc.fileset" />
493514 <doctitle><![CDATA[<h1>Lightweight Java Game Toolkit</h1>]]></doctitle>
494515 <bottom><![CDATA[<i>Copyright &#169; 2002-2009 lwjgl.org. All Rights Reserved.</i>]]></bottom>
22 <!-- Create our packer task -->
33 <taskdef name="pack200" classname="com.sun.tools.apache.ant.pack200.Pack200Task" classpath="platform_build/Pack200Task.jar"/>
44
5 <target name="applet" depends="all">
5 <target name="applet">
66 <antcall target="-applet">
77 <param name="keystore" value="applet/lwjglkeystore"/>
88 <param name="alias" value="lwjgl"/>
3030 <target name="-applet">
3131
3232 <!-- Create lwjgl_applet.jar -->
33 <jar destfile="applet/lwjgl_applet.jar" taskname="lwjgl_applet.jar">
33 <jar destfile="applet/basic/lwjgl_applet.jar" taskname="lwjgl_applet.jar">
3434 <fileset refid="lwjgl_applet.fileset" />
3535 </jar>
3636
3737 <!-- create each of the native jars -->
38 <jar destfile="applet/windows_natives.jar" taskname="windows_natives.jar">
38 <jar destfile="applet/basic/windows_natives.jar" taskname="windows_natives.jar">
3939 <fileset dir="${lwjgl.lib}/windows">
4040 <patternset refid="lwjgl-windows.fileset"/>
4141 </fileset>
4242 </jar>
43 <signjar jar="applet/windows_natives.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
43 <signjar jar="applet/basic/windows_natives.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
4444
45 <jar destfile="applet/linux_natives.jar" taskname="linux_natives.jar">
45 <jar destfile="applet/basic/linux_natives.jar" taskname="linux_natives.jar">
4646 <fileset dir="${lwjgl.lib}/linux">
4747 <patternset refid="lwjgl-linux.fileset"/>
4848 </fileset>
4949 </jar>
50 <signjar jar="applet/linux_natives.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
50 <signjar jar="applet/basic/linux_natives.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
5151
52 <jar destfile="applet/macosx_natives.jar" taskname="macosx_natives.jar">
52 <jar destfile="applet/basic/macosx_natives.jar" taskname="macosx_natives.jar">
5353 <fileset dir="${lwjgl.lib}/macosx">
5454 <patternset refid="lwjgl-macosx.fileset"/>
5555 </fileset>
5656 </jar>
57 <signjar jar="applet/macosx_natives.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
57 <signjar jar="applet/basic/macosx_natives.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
5858
59 <jar destfile="applet/solaris_natives.jar" taskname="solaris_natives.jar">
59 <jar destfile="applet/basic/solaris_natives.jar" taskname="solaris_natives.jar">
6060 <fileset dir="${lwjgl.lib}/solaris">
6161 <patternset refid="lwjgl-solaris.fileset"/>
6262 </fileset>
6363 </jar>
64 <signjar jar="applet/solaris_natives.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
65
66 <jar destfile="${lwjgl.lib}/lwjgl_util_applet.jar" update="true">
67 <fileset dir="${lwjgl.res}" includes="applet*"/>
68 </jar>
64 <signjar jar="applet/basic/solaris_natives.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
6965
70 <copy file="${lwjgl.lib}/lwjgl.jar" todir="applet" overwrite="true"/>
71 <copy file="${lwjgl.lib}/lwjgl-debug.jar" todir="applet" overwrite="true"/>
72 <copy file="${lwjgl.lib}/lwjgl_util_applet.jar" todir="applet" overwrite="true"/>
73 <copy file="${lwjgl.lib}/lwjgl_util.jar" todir="applet" overwrite="true"/>
74 <copy file="${lwjgl.lib}/jinput.jar" todir="applet" overwrite="true"/>
75 <copy file="${lwjgl.lib}/lzma.jar" todir="applet" overwrite="true"/>
76 <zip destfile="applet/res.jar">
77 <zipfileset dir="${lwjgl.res}" includes="Footsteps.wav, ILtest.tga, Missing_you.mod"/>
78 </zip>
79 <signjar jar="applet/lwjgl_util_applet.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
80 <signjar jar="applet/lzma.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
66 <copy file="${lwjgl.lib}/lwjgl.jar" todir="applet/basic" overwrite="true"/>
67 <copy file="${lwjgl.lib}/lwjgl-debug.jar" todir="applet/basic" overwrite="true"/>
68 <copy file="${lwjgl.lib}/lwjgl_util_applet.jar" todir="applet/basic" overwrite="true"/>
69 <copy file="${lwjgl.lib}/lwjgl_util.jar" todir="applet/basic" overwrite="true"/>
70 <copy file="${lwjgl.lib}/jinput.jar" todir="applet/basic" overwrite="true"/>
71 <copy file="${lwjgl.lib}/lzma.jar" todir="applet/advance" overwrite="true"/>
8172
73 <signjar jar="applet/basic/lwjgl_util_applet.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
74 <signjar jar="applet/advance/lzma.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
75 <copy file="applet/basic/lwjgl_util_applet.jar" todir="applet/advance" overwrite="true"/>
76
8277 <!-- LZMA only, for 1.4 only clients -->
83 <antcall target="compress-resource">
84 <param name="input" value="applet/lwjgl.jar"/>
85 <param name="output" value="applet/lwjgl.jar.lzma"/>
78 <!--antcall target="compress-resource">
79 <param name="input" value="applet/basic/lwjgl.jar"/>
80 <param name="output" value="applet/advance/lwjgl.jar.lzma"/>
8681 </antcall>
8782 <antcall target="compress-resource">
88 <param name="input" value="applet/lwjgl-debug.jar"/>
89 <param name="output" value="applet/lwjgl-debug.jar.lzma"/>
83 <param name="input" value="applet/basic/lwjgl-debug.jar"/>
84 <param name="output" value="applet/advance/lwjgl-debug.jar.lzma"/>
9085 </antcall>
9186
9287 <antcall target="compress-resource">
93 <param name="input" value="applet/lwjgl_util.jar"/>
94 <param name="output" value="applet/lwjgl_util.jar.lzma"/>
88 <param name="input" value="applet/basic/lwjgl_util.jar"/>
89 <param name="output" value="applet/advance/lwjgl_util.jar.lzma"/>
9590 </antcall>
9691 <antcall target="compress-resource">
97 <param name="input" value="applet/jinput.jar"/>
98 <param name="output" value="applet/jinput.jar.lzma"/>
92 <param name="input" value="applet/basic/jinput.jar"/>
93 <param name="output" value="applet/advance/jinput.jar.lzma"/>
9994 </antcall>
10095 <antcall target="compress-resource">
101 <param name="input" value="applet/lwjgl_applet.jar"/>
102 <param name="output" value="applet/lwjgl_applet.jar.lzma"/>
96 <param name="input" value="applet/basic/lwjgl_applet.jar"/>
97 <param name="output" value="applet/advance/lwjgl_applet.jar.lzma"/>
10398 </antcall>
10499 <antcall target="compress-resource">
105 <param name="input" value="applet/windows_natives.jar"/>
106 <param name="output" value="applet/windows_natives.jar.lzma"/>
107 </antcall>
100 <param name="input" value="applet/basic/windows_natives.jar"/>
101 <param name="output" value="applet/advance/windows_natives.jar.lzma"/>
102 </antcall -->
103
108104 <antcall target="compress-sign-class">
109 <param name="dir" value="applet/"/>
105 <param name="dir" value="applet/basic/"/>
106 <param name="outputdir" value="applet/advance/"/>
110107 <param name="jarfile" value="lwjgl"/>
111108 </antcall>
112109 <antcall target="compress-sign-class">
113 <param name="dir" value="applet/"/>
110 <param name="dir" value="applet/basic/"/>
111 <param name="outputdir" value="applet/advance/"/>
114112 <param name="jarfile" value="lwjgl-debug"/>
115113 </antcall>
116114 <antcall target="compress-sign-class">
117 <param name="dir" value="applet/"/>
115 <param name="dir" value="applet/basic/"/>
116 <param name="outputdir" value="applet/advance/"/>
118117 <param name="jarfile" value="lwjgl_util"/>
119118 </antcall>
120119 <antcall target="compress-sign-class">
121 <param name="dir" value="applet/"/>
120 <param name="dir" value="applet/basic/"/>
121 <param name="outputdir" value="applet/advance/"/>
122122 <param name="jarfile" value="jinput"/>
123123 </antcall>
124124 <antcall target="compress-sign-class">
125 <param name="dir" value="applet/"/>
125 <param name="dir" value="applet/basic/"/>
126 <param name="outputdir" value="applet/advance/"/>
126127 <param name="jarfile" value="lwjgl_applet"/>
127128 </antcall>
128129 <antcall target="compress-resource">
129 <param name="input" value="applet/windows_natives.jar"/>
130 <param name="output" value="applet/windows_natives.jar.lzma"/>
130 <param name="input" value="applet/basic/windows_natives.jar"/>
131 <param name="output" value="applet/advance/windows_natives.jar.lzma"/>
131132 </antcall>
132133 <antcall target="compress-resource">
133 <param name="input" value="applet/macosx_natives.jar"/>
134 <param name="output" value="applet/macosx_natives.jar.lzma"/>
134 <param name="input" value="applet/basic/macosx_natives.jar"/>
135 <param name="output" value="applet/advance/macosx_natives.jar.lzma"/>
135136 </antcall>
136137 <antcall target="compress-resource">
137 <param name="input" value="applet/linux_natives.jar"/>
138 <param name="output" value="applet/linux_natives.jar.lzma"/>
138 <param name="input" value="applet/basic/linux_natives.jar"/>
139 <param name="output" value="applet/advance/linux_natives.jar.lzma"/>
139140 </antcall>
140141 <antcall target="compress-resource">
141 <param name="input" value="applet/solaris_natives.jar"/>
142 <param name="output" value="applet/solaris_natives.jar.lzma"/>
143 </antcall>
144
145 <antcall target="compress-resource">
146 <param name="input" value="applet/res.jar"/>
147 <param name="output" value="applet/res.jar.lzma"/>
142 <param name="input" value="applet/basic/solaris_natives.jar"/>
143 <param name="output" value="applet/advance/solaris_natives.jar.lzma"/>
148144 </antcall>
149145 </target>
150146 </project>
11 <!-- ================================================================== -->
22 <!-- Global properties for build -->
33 <!-- ================================================================== -->
4 <property name="lwjgl.src" location="src" />
5 <property name="lwjgl.src.native" location="${lwjgl.src}/native" />
6 <property name="lwjgl.src.headers" location="${lwjgl.src.native}/common" />
7 <property name="lwjgl.src.templates" location="${lwjgl.src}/templates" />
8 <property name="lwjgl.bin" location="bin" />
9 <property name="lwjgl.lib" location="libs" />
10 <property name="lwjgl.dist" location="dist" />
11 <property name="lwjgl.docs" location="doc" />
12 <property name="lwjgl.temp" location="temp" />
13 <property name="lwjgl.res" location="res" />
14 <property name="lwjgl.version" value="2.5" />
4 <property name="lwjgl.src" location="src" />
5 <property name="lwjgl.src.native" location="${lwjgl.src}/native" />
6 <property name="lwjgl.src.headers" location="${lwjgl.src.native}/common" />
7 <property name="lwjgl.src.templates" location="${lwjgl.src}/templates" />
8 <property name="lwjgl.bin" location="bin" />
9 <property name="lwjgl.lib" location="libs" />
10 <property name="lwjgl.dist" location="dist" />
11 <property name="lwjgl.docs" location="doc" />
12 <property name="lwjgl.temp" location="temp" />
13 <property name="lwjgl.res" location="res" />
14 <property name="lwjgl.version" value="2.7.1" />
15 <property name="lwjgl.web" location="www" />
1516
1617 <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"/>
18 <property name="opencl-template-pattern-extensions" value="org/lwjgl/opencl/KHR*.java,org/lwjgl/opencl/EXT*.java,org/lwjgl/opencl/APPLE*.java,org/lwjgl/opencl/AMD*.java,org/lwjgl/opencl/NV*.java"/>
19 <property name="opencl-template-pattern" value="org/lwjgl/opencl/CL*.java,${opencl-template-pattern-extensions}"/>
20
1721 <!-- ================================================================== -->
1822 <!-- Filesets used for targets -->
1923 <!-- ================================================================== -->
2024
2125 <!-- Files to include in the lwjgl.jar file -->
2226 <fileset id="lwjgl.fileset" dir="${lwjgl.bin}">
23 <include name="org/**/*" />
24 <exclude name="org/lwjgl/d3d/**" />
25 <exclude name="org/lwjgl/test/**" />
26 <exclude name="org/lwjgl/util/**" />
27 <exclude name="org/lwjgl/examples/**" />
27 <patternset id="lwjgl.package.pattern">
28 <include name="org/**/*" />
29 <exclude name="org/lwjgl/d3d/**" />
30 <exclude name="org/lwjgl/test/**" />
31 <exclude name="org/lwjgl/util/**" />
32 <exclude name="org/lwjgl/examples/**" />
33 </patternset>
2834 </fileset>
29
35
36 <!-- Files to include in the lwjgl_util_applet.jar file -->
3037 <fileset id="lwjgl_util_applet.fileset" dir="${lwjgl.bin}">
31 <exclude name="**.*"/>
32 <include name="org/lwjgl/util/applet/**"/>
38 <patternset id="lwjgl_util_applet.package.pattern">
39 <exclude name="**.*"/>
40 <include name="org/lwjgl/util/applet/**"/>
41 </patternset>
3342 </fileset>
3443
3544 <!-- Files to include in the lwjgl_test.jar file -->
3847 <include name="org/lwjgl/test/**" />
3948 <include name="org/lwjgl/examples/**" />
4049 </fileset>
41
50
4251 <!-- More files to include in the lwjgl_test.jar file -->
4352 <fileset id="lwjgl_test_extra.fileset" dir="${lwjgl.src}/java">
4453 <exclude name="**.*" />
45 <include name="org/lwjgl/test/opengl/shaders/shaderFP.fp" />
46 <include name="org/lwjgl/test/opengl/shaders/shaderFP.vp" />
47 <include name="org/lwjgl/test/opengl/shaders/shaderFSH.fsh" />
48 <include name="org/lwjgl/test/opengl/shaders/shaderFSH.vsh" />
49 <include name="org/lwjgl/test/opengl/shaders/shaderVP.vp" />
50 <include name="org/lwjgl/test/opengl/shaders/shaderVSH.vsh" />
51 <include name="org/lwjgl/test/opengl/shaders/shaderUNI.vsh" />
52 </fileset>
54 <include name="org/lwjgl/test/opengl/shaders/*.fp" />
55 <include name="org/lwjgl/test/opengl/shaders/*.vp" />
56 <include name="org/lwjgl/test/opengl/shaders/*.vsh" />
57 <include name="org/lwjgl/test/opengl/shaders/*.fsh" />
58 <include name="org/lwjgl/test/opencl/gl/*.cl" />
59 </fileset>
5360
5461 <!-- Files to include in the lwjgl_util.jar file -->
5562 <fileset id="lwjgl_util.fileset" dir="${lwjgl.bin}">
56 <exclude name="**.*" />
57 <exclude name="org/lwjgl/util/generator/**" />
58 <exclude name="org/lwjgl/util/applet/**" />
59 <include name="org/lwjgl/util/**" />
63 <patternset id="lwjgl_util.package.pattern">
64 <exclude name="**.*" />
65 <exclude name="org/lwjgl/util/generator/**" />
66 <exclude name="org/lwjgl/util/applet/**" />
67 <include name="org/lwjgl/util/**" />
68 </patternset>
6069 </fileset>
70
6171
6272 <!-- Files to include in the lwjgl_applet.jar file -->
6373 <fileset id="lwjgl_applet.fileset" dir="${lwjgl.bin}">
6575 <include name="org/lwjgl/test/applet/**"/>
6676 <include name="org/lwjgl/test/opengl/awt/AWTGearsCanvas.class"/>
6777 </fileset>
68
78
6979 <!-- Files to make Javadoc from -->
7080 <fileset id="lwjgl.javadoc.fileset" dir="${lwjgl.src}">
7181 <include name="**/*.java" />
8797
8898 <!-- Files to include in windows package -->
8999 <patternset id="lwjgl-windows.fileset">
90 <include name="lwjgl.dll" />
91 <include name="lwjgl64.dll" />
92 <include name="OpenAL32.dll" />
93 <include name="OpenAL64.dll" />
94 <include name="jinput-dx8*.dll" />
95 <include name="jinput-raw*.dll" />
100 <patternset id="lwjgl-windows-lwjgl.fileset">
101 <include name="lwjgl.dll" />
102 <include name="lwjgl64.dll" />
103 <include name="OpenAL32.dll" />
104 <include name="OpenAL64.dll" />
105 </patternset>
106 <patternset id="lwjgl-windows-jinput.fileset">
107 <include name="jinput-dx8*.dll" />
108 <include name="jinput-raw*.dll" />
109 </patternset>
96110 </patternset>
97
111
98112 <!-- Files to include in linux, glibc2.3 package -->
99113 <patternset id="lwjgl-linux.fileset">
100 <include name="liblwjgl*.so" />
101 <include name="libopenal*.so" />
102 <include name="libjinput-linux.so" />
103 <include name="libjinput-linux64.so" />
114 <patternset id="lwjgl-linux-lwjgl.fileset">
115 <include name="liblwjgl*.so" />
116 <include name="libopenal*.so" />
117 </patternset>
118 <patternset id="lwjgl-linux-jinput.fileset">
119 <include name="libjinput-linux.so" />
120 <include name="libjinput-linux64.so" />
121 </patternset>
104122 </patternset>
105
123
106124 <!-- Files to include in mac os x package -->
107125 <patternset id="lwjgl-macosx.fileset">
108 <include name="liblwjgl.jnilib" />
109 <include name="openal.dylib" />
110 <include name="libjinput-osx.jnilib" />
111 <include name="libjinput-osx-legacy.jnilib" />
126 <patternset id="lwjgl-macosx-lwjgl.fileset">
127 <include name="liblwjgl.jnilib" />
128 <include name="openal.dylib" />
129 </patternset>
130 <patternset id="lwjgl-macosx-jinput.fileset">
131 <include name="libjinput-osx.jnilib" />
132 <include name="libjinput-osx-legacy.jnilib" />
133 </patternset>
112134 </patternset>
113
135
114136 <!-- Files to include in solaris package -->
115137 <patternset id="lwjgl-solaris.fileset">
116138 <include name="liblwjgl*.so" />
117 <include name="libopenal.so" />
139 <include name="libopenal*.so" />
118140 </patternset>
119
141
120142 <!-- Files to include in source distribution -->
121143 <fileset id="lwjgl.source.fileset" dir=".">
122144 <include name="build.xml" />
131153 <exclude name="res/Missing_you.mod" />
132154 <exclude name="res/phero*.*" />
133155 </patternset>
134
156
135157 <!-- files in the optional package -->
136158 <patternset id="lwjgl_optional">
137159 <include name="res/**" />
142164 <include name="doc/CREDITS" />
143165 <include name="doc/LICENSE" />
144166 <include name="doc/README" />
145 </patternset>
146
167 </patternset>
168
147169 <!-- files in the lwjgl_applet package -->
148170 <patternset id="lwjgl_applet">
149171 <include name="applet/**" />
150172 <exclude name="applet/appletviewer.policy" />
151173 <exclude name="applet/lwjglkeystore" />
152 </patternset>
153
174 </patternset>
175
154176 <uptodate property="lwjgl.main.built" targetfile="${lwjgl.lib}/windows/lwjgl.dll" >
155177 <srcfiles dir= "${lwjgl.src.native}/common" includes="*.c*"/>
156178 <srcfiles dir= "${lwjgl.src.native}/windows" includes="*.c"/>
157179 </uptodate>
158 </project>
180 </project>
00 <project name="generator">
11
22 <!-- clean the generated files -->
3 <target name="clean-generated" description="Deletes the generated java and native source">
3 <target name="clean-generated" description="Deletes the generated java source">
44 <delete quiet="true" failonerror="false">
55 <fileset dir="${lwjgl.src}/generated" includes="**"/>
6 <fileset dir="${lwjgl.src.native}/generated" includes="**"/>
76 </delete>
87 </target>
9
8
9 <target name="clean-generated-native" description="Deletes the generated native source" depends="clean-generated">
10 <delete quiet="false" failonerror="false">
11 <fileset dir="${lwjgl.src.native}/generated" includes="**"/>
12 </delete>
13 </target>
14
1015 <!-- Compiles the Java generator source code -->
1116 <target name="generators" description="Compiles the native method generators">
1217 <javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" includes="org/lwjgl/util/generator/**.java" source="1.5" target="1.5" taskname="generator">
18 <include name="org/lwjgl/util/generator/openal/**.java"/>
19 <include name="org/lwjgl/util/generator/opengl/**.java"/>
20 <include name="org/lwjgl/util/generator/opencl/**.java"/>
1321 <compilerarg value="-Xlint:all"/>
1422 </javac>
1523 <!-- Compile helper classes used by the templates -->
16 <javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" source="1.4" target="1.4" taskname="generator">
24 <javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" source="1.5" target="1.5" taskname="generator">
25 <include name="org/lwjgl/PointerWrapper.java"/>
26 <include name="org/lwjgl/PointerBuffer.java"/>
27 <!-- OpenGL -->
1728 <include name="org/lwjgl/opengl/GLSync.java"/>
1829 <include name="org/lwjgl/opengl/AMDDebugOutputCallback.java"/>
19 <include name="org/lwjgl/opengl/PointerWrapper.java"/>
30 <include name="org/lwjgl/opengl/ARBDebugOutputCallback.java"/>
31 <!-- OpenCL -->
32 <include name="org/lwjgl/opencl/CLPlatform.java"/>
33 <include name="org/lwjgl/opencl/CLDevice.java"/>
34 <include name="org/lwjgl/opencl/CLContext.java"/>
35 <include name="org/lwjgl/opencl/CLContextCallback.java"/>
36 <include name="org/lwjgl/opencl/CLCommandQueue.java"/>
37 <include name="org/lwjgl/opencl/CLMem.java"/>
38 <include name="org/lwjgl/opencl/CLMemObjectDestructorCallback.java"/>
39 <include name="org/lwjgl/opencl/CLBuildProgramCallback.java"/>
40 <include name="org/lwjgl/opencl/CLNativeKernel.java"/>
41 <include name="org/lwjgl/opencl/CLEventCallback.java"/>
42 <include name="org/lwjgl/opencl/CLFunctionAddress.java"/>
2043 </javac>
2144 </target>
2245
2346 <!-- Proxy target to generate it all -->
24 <target name="generate-all" depends="generate-openal, generate-opengl, generate-opengl-capabilities, generate-opengl-references" description="Generates java and native source"/>
25
26 <target name="generate-debug" depends="generate-openal-debug, generate-opengl-debug, generate-opengl-capabilities-debug, generate-opengl-references" description="Generates java and native source"/>
47 <target name="generate-all" depends="generate-openal, generate-opengl, generate-opengl-capabilities, generate-opengl-references, generate-opencl, generate-opencl-capabilities" description="Generates java and native source"/>
48
49 <target name="generate-debug" depends="generate-openal-debug, generate-opengl-debug, generate-opengl-capabilities-debug, generate-opengl-references, generate-opencl-debug, generate-opencl-capabilities-debug" description="Generates java and native source with debug functionality"/>
2750
2851 <!-- Generate OpenAL -->
2952 <target name="generate-openal" depends="generators" description="Generates java and native source for AL">
3760 <arg path="${lwjgl.src}/generated"/>
3861 <arg value="-d"/>
3962 <arg path="${lwjgl.src.native}/generated"/>
40 <arg value="-Atypemap=org.lwjgl.util.generator.ALTypeMap"/>
63 <arg value="-Atypemap=org.lwjgl.util.generator.openal.ALTypeMap"/>
4164 <fileset dir="${lwjgl.src.templates}" includes="org/lwjgl/openal/AL10.java, org/lwjgl/openal/AL11.java, org/lwjgl/openal/EFX10.java"/>
4265 </apply>
4366 </target>
44
67
4568 <!-- Generate OpenAL [DEBUG] -->
4669 <target name="generate-openal-debug" depends="generators" description="Generates java and native source for AL">
4770 <apply executable="apt" parallel="true">
5477 <arg path="${lwjgl.src}/generated"/>
5578 <arg value="-d"/>
5679 <arg path="${lwjgl.src.native}/generated"/>
57 <arg value="-Atypemap=org.lwjgl.util.generator.ALTypeMap"/>
80 <arg value="-Atypemap=org.lwjgl.util.generator.openal.ALTypeMap"/>
5881 <arg value="-Ageneratechecks"/>
5982 <fileset dir="${lwjgl.src.templates}" includes="org/lwjgl/openal/AL10.java, org/lwjgl/openal/AL11.java, org/lwjgl/openal/EFX10.java"/>
6083 </apply>
7396 <arg value="-d"/>
7497 <arg path="${lwjgl.src.native}/generated"/>
7598 <arg value="-Acontextspecific"/>
76 <arg value="-Atypemap=org.lwjgl.util.generator.GLTypeMap"/>
99 <arg value="-Atypemap=org.lwjgl.util.generator.opengl.GLTypeMap"/>
77100 <fileset dir="${lwjgl.src.templates}" includes="${opengl-template-pattern}"/>
78101 </apply>
79102 </target>
92115 <arg path="${lwjgl.src.native}/generated"/>
93116 <arg value="-Ageneratechecks"/>
94117 <arg value="-Acontextspecific"/>
95 <arg value="-Atypemap=org.lwjgl.util.generator.GLTypeMap"/>
96 <fileset dir="${lwjgl.src.templates}" includes="${opengl-template-pattern}"/>
97 </apply>
98 </target>
99
100 <!-- Generate references -->
118 <arg value="-Atypemap=org.lwjgl.util.generator.opengl.GLTypeMap"/>
119 <fileset dir="${lwjgl.src.templates}" includes="${opengl-template-pattern}"/>
120 </apply>
121 </target>
122
123 <!-- Generate OpenGL references -->
101124 <target name="generate-opengl-references" depends="generators" description="Generates java and native source for GL">
102125 <apply executable="apt" parallel="true">
103126 <arg value="-nocompile"/>
104127 <arg value="-factory"/>
105 <arg value="org.lwjgl.util.generator.ReferencesGeneratorProcessorFactory"/>
106 <arg value="-cp"/>
107 <arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
108 <arg value="-s"/>
109 <arg path="${lwjgl.src}/generated"/>
110 <fileset dir="${lwjgl.src.templates}" includes="${opengl-template-pattern}"/>
111 </apply>
112 </target>
113
114 <!-- Generate context capabilities -->
128 <arg value="org.lwjgl.util.generator.opengl.GLReferencesGeneratorProcessorFactory"/>
129 <arg value="-cp"/>
130 <arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
131 <arg value="-s"/>
132 <arg path="${lwjgl.src}/generated"/>
133 <fileset dir="${lwjgl.src.templates}" includes="${opengl-template-pattern}"/>
134 </apply>
135 </target>
136
137 <!-- Generate OpenGL context capabilities -->
115138 <target name="generate-opengl-capabilities" depends="generators" description="Generates java and native source for GL">
116139 <apply executable="apt" parallel="true">
117140 <arg value="-nocompile"/>
118141 <arg value="-factory"/>
119 <arg value="org.lwjgl.util.generator.ContextGeneratorProcessorFactory"/>
120 <arg value="-cp"/>
121 <arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
122 <arg value="-s"/>
123 <arg path="${lwjgl.src}/generated"/>
124 <arg value="-Acontextspecific"/>
125 <fileset dir="${lwjgl.src.templates}" includes="${opengl-template-pattern}"/>
126 </apply>
127 </target>
128
129 <!-- Generate context capabilities [DEBUG] -->
142 <arg value="org.lwjgl.util.generator.opengl.GLGeneratorProcessorFactory"/>
143 <arg value="-cp"/>
144 <arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
145 <arg value="-s"/>
146 <arg path="${lwjgl.src}/generated"/>
147 <arg value="-Acontextspecific"/>
148 <fileset dir="${lwjgl.src.templates}" includes="${opengl-template-pattern}"/>
149 </apply>
150 </target>
151
152 <!-- Generate OpenGL context capabilities [DEBUG] -->
130153 <target name="generate-opengl-capabilities-debug" depends="generators" description="Generates java and native source for GL">
131154 <apply executable="apt" parallel="true">
132155 <arg value="-nocompile"/>
133156 <arg value="-factory"/>
134 <arg value="org.lwjgl.util.generator.ContextGeneratorProcessorFactory"/>
157 <arg value="org.lwjgl.util.generator.opengl.GLGeneratorProcessorFactory"/>
135158 <arg value="-cp"/>
136159 <arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
137160 <arg value="-s"/>
140163 <arg value="-Acontextspecific"/>
141164 <fileset dir="${lwjgl.src.templates}" includes="${opengl-template-pattern}"/>
142165 </apply>
143 </target>
166 </target>
167
168 <!-- Generate OpenCL -->
169 <target name="generate-opencl" depends="generators" description="Generates java and native source for CL">
170 <apply executable="apt" parallel="true">
171 <arg value="-nocompile"/>
172 <arg value="-factory"/>
173 <arg value="org.lwjgl.util.generator.GeneratorProcessorFactory"/>
174 <arg value="-cp"/>
175 <arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
176 <arg value="-s"/>
177 <arg path="${lwjgl.src}/generated"/>
178 <arg value="-d"/>
179 <arg path="${lwjgl.src.native}/generated"/>
180 <arg value="-Acontextspecific"/>
181 <arg value="-Atypemap=org.lwjgl.util.generator.opencl.CLTypeMap"/>
182 <fileset dir="${lwjgl.src.templates}" includes="${opencl-template-pattern}"/>
183 </apply>
184 </target>
185
186 <!-- Generate OpenCL [DEBUG] -->
187 <target name="generate-opencl-debug" depends="generators" description="Generates java and native source for CL">
188 <apply executable="apt" parallel="true">
189 <arg value="-nocompile"/>
190 <arg value="-factory"/>
191 <arg value="org.lwjgl.util.generator.GeneratorProcessorFactory"/>
192 <arg value="-cp"/>
193 <arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
194 <arg value="-s"/>
195 <arg path="${lwjgl.src}/generated"/>
196 <arg value="-d"/>
197 <arg path="${lwjgl.src.native}/generated"/>
198 <arg value="-Ageneratechecks"/>
199 <arg value="-Acontextspecific"/>
200 <arg value="-Atypemap=org.lwjgl.util.generator.opencl.CLTypeMap"/>
201 <fileset dir="${lwjgl.src.templates}" includes="${opencl-template-pattern}"/>
202 </apply>
203 </target>
204
205 <!-- Generate OpenCL capabilities -->
206 <target name="generate-opencl-capabilities" depends="generators" description="Generates capabilities for CL">
207 <apply executable="apt" parallel="true">
208 <arg value="-nocompile"/>
209 <arg value="-factory"/>
210 <arg value="org.lwjgl.util.generator.opencl.CLGeneratorProcessorFactory"/>
211 <arg value="-cp"/>
212 <arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
213 <arg value="-s"/>
214 <arg path="${lwjgl.src}/generated"/>
215 <arg value="-Acontextspecific"/>
216 <fileset dir="${lwjgl.src.templates}" includes="${opencl-template-pattern}"/>
217 </apply>
218 </target>
219
220 <!-- Generate OpenCL capabilities [DEBUG] -->
221 <target name="generate-opencl-capabilities-debug" depends="generators" description="Generates capabilities for CL">
222 <apply executable="apt" parallel="true">
223 <arg value="-nocompile"/>
224 <arg value="-factory"/>
225 <arg value="org.lwjgl.util.generator.opencl.CLGeneratorProcessorFactory"/>
226 <arg value="-cp"/>
227 <arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
228 <arg value="-s"/>
229 <arg path="${lwjgl.src}/generated"/>
230 <arg value="-Ageneratechecks"/>
231 <arg value="-Acontextspecific"/>
232 <fileset dir="${lwjgl.src.templates}" includes="${opencl-template-pattern}"/>
233 </apply>
234 </target>
144235 </project>
0 <project name="maven">
1 <property name="lwjgl.src.java" location="${lwjgl.src}/java" />
2 <property name="lwjgl.src.generated" location="${lwjgl.src}/generated" />
3 <property name="lwjgl.maven" location="maven" />
4 <property name="lwjgl.dstMaven" location="${lwjgl.temp}/maven" />
5
6 <property name="lwjgl.src.java" location="${lwjgl.src}/java" />
7
8 <property name="lwjgl-maven-version" value="2.7.0"/>
9
10 <fileset id="lwjgl-sources.manual.fileset" dir="${lwjgl.src.java}">
11 <patternset refid="lwjgl.package.pattern" />
12 </fileset>
13
14 <fileset id="lwjgl-sources.generated.fileset" dir="${lwjgl.src.generated}">
15 <include name="**/*" />
16 </fileset>
17 <fileset id="lwjgl_util_applet-sources.fileset" dir="${lwjgl.src.java}">
18 <patternset refid="lwjgl_util_applet.package.pattern" />
19 </fileset>
20
21 <fileset id="lwjgl_util-sources.fileset" dir="${lwjgl.src.java}">
22 <patternset refid="lwjgl_util.package.pattern" />
23 </fileset>
24
25
26 <target name="maven-full">
27 <antcall target="clean-java" />
28 <antcall target="-initialize" />
29
30 <antcall target="generate-all" />
31 <antcall target="compile" />
32 <antcall target="-createjars" />
33 <antcall target="maven"/>
34 </target>
35
36 <target name="maven">
37 <delete dir="${lwjgl.dstMaven}" quiet="true" failonerror="false" taskname="cleaning maven dist" />
38 <mkdir dir="${lwjgl.dstMaven}" taskname="initialiazing temp maven folder" />
39 <antcall target="-copylwjgljars" />
40 <antcall target="-createmavensourcejars" />
41 <antcall target="-createmavenjavadocs" />
42 <antcall target="-createmavennativejars" />
43 <antcall target="-copymavenpoms"/>
44 <antcall target="-copymavendeploybuild"/>
45 <antcall target="-copymaventdist"/>
46 </target>
47
48
49 <target name="-copylwjgljars">
50 <copy todir="${lwjgl.dstMaven}">
51 <fileset dir="${lwjgl.temp}/jar/">
52 <patternset>
53 <include name="lwjgl.jar" />
54 <include name="lwjgl_util.jar" />
55 <include name="lwjgl_util_applet.jar" />
56 </patternset>
57 </fileset>
58 </copy>
59 </target>
60
61 <!-- Packages the java files -->
62 <target name="-createmavensourcejars">
63
64 <jar destfile="${lwjgl.dstMaven}/lwjgl-sources.jar" taskname="lwjgl-sources.jar">
65 <fileset refid="lwjgl-sources.manual.fileset" />
66 <fileset refid="lwjgl-sources.generated.fileset" />
67 </jar>
68
69 <jar destfile="${lwjgl.dstMaven}/lwjgl_util_applet-sources.jar" taskname="lwjgl_util_applet-sources.jar">
70 <fileset refid="lwjgl_util_applet-sources.fileset" />
71 </jar>
72
73 <jar destfile="${lwjgl.dstMaven}/lwjgl_util-sources.jar" taskname="lwjgl_util-sources.jar">
74 <fileset refid="lwjgl_util-sources.fileset" />
75 </jar>
76 </target>
77
78 <target name="-createmavenjavadocs">
79 <!-- Creates the Javadoc -->
80
81 <javadoc destdir="${lwjgl.dstMaven}/lwjgl-javadoc" classpath="${lwjgl.lib}/jinput.jar" author="true" version="true" use="true" source="1.5" windowtitle="LWJGL API" useexternalfile="true">
82 <fileset refid="lwjgl-sources.manual.fileset"/>
83 <fileset refid="lwjgl-sources.generated.fileset"/>
84 <doctitle><![CDATA[<h1>Lightweight Java Game Toolkit</h1>]]></doctitle>
85 <bottom><![CDATA[<i>Copyright &#169; 2002-2010 lwjgl.org. All Rights Reserved.</i>]]></bottom>
86 </javadoc>
87 <jar destfile="${lwjgl.dstMaven}/lwjgl-javadoc.jar" taskname="lwjgl-javadoc.jar">
88 <fileset dir="${lwjgl.dstMaven}/lwjgl-javadoc" />
89 </jar>
90
91 <javadoc destdir="${lwjgl.dstMaven}/lwjgl_util-javadoc" classpath="${lwjgl.lib}/jinput.jar:${lwjgl.lib}/lwjgl.jar" author="true" version="true" use="true" source="1.5" windowtitle="LWJGL UTIL API" useexternalfile="true">
92 <fileset refid="lwjgl_util-sources.fileset"/>
93 <doctitle><![CDATA[<h1>Lightweight Java Game Toolkit</h1>]]></doctitle>
94 <bottom><![CDATA[<i>Copyright &#169; 2002-2010 lwjgl.org. All Rights Reserved.</i>]]></bottom>
95 </javadoc>
96 <jar destfile="${lwjgl.dstMaven}/lwjgl_util-javadoc.jar" taskname="lwjgl_util-javadoc.jar">
97 <fileset dir="${lwjgl.dstMaven}/lwjgl_util-javadoc" />
98 </jar>
99
100 <javadoc destdir="${lwjgl.dstMaven}/lwjgl_util_applet-javadoc" classpath="${lwjgl.lib}/jinput.jar:${lwjgl.lib}/lwjgl.jar" author="true" version="true" use="true" source="1.5" windowtitle="LWJGL UTIL API" useexternalfile="true">
101 <fileset refid="lwjgl_util_applet-sources.fileset"/>
102 <doctitle><![CDATA[<h1>Lightweight Java Game Toolkit</h1>]]></doctitle>
103 <bottom><![CDATA[<i>Copyright &#169; 2002-2010 lwjgl.org. All Rights Reserved.</i>]]></bottom>
104 </javadoc>
105 <jar destfile="${lwjgl.dstMaven}/lwjgl_util_applet-javadoc.jar" taskname="lwjgl_util_applet-javadoc.jar">
106 <fileset dir="${lwjgl.dstMaven}/lwjgl_util_applet-javadoc" />
107 </jar>
108
109 <delete dir="${lwjgl.dstMaven}/lwjgl-javadoc" quiet="true" failonerror="false" taskname="cleaning maven javadoc temps lwjgl" />
110 <delete dir="${lwjgl.dstMaven}/lwjgl_util-javadoc" quiet="true" failonerror="false" taskname="cleaning maven javadoc temps lwjgl_util" />
111 <delete dir="${lwjgl.dstMaven}/lwjgl_util_applet-javadoc" quiet="true" failonerror="false" taskname="cleaning maven javadoc temps lwjgl_util_applet" />
112 </target>
113
114 <target name="-createmavennativejars">
115 <jar destfile="${lwjgl.dstMaven}/lwjgl-platform-natives-win.jar" taskname="lwjgl-platform-natives-win.jar">
116 <fileset dir="${lwjgl.lib}/windows">
117 <patternset refid="lwjgl-windows-lwjgl.fileset"/>
118 </fileset>
119 </jar>
120 <jar destfile="${lwjgl.dstMaven}/lwjgl-platform-natives-linux.jar" taskname="lwjgl-platform-natives-linux.jar">
121 <fileset dir="${lwjgl.lib}/linux">
122 <patternset refid="lwjgl-linux-lwjgl.fileset"/>
123 </fileset>
124 </jar>
125 <jar destfile="${lwjgl.dstMaven}/lwjgl-platform-natives-mac.jar" taskname="lwjgl-platform-natives-mac.jar">
126 <fileset dir="${lwjgl.lib}/macosx">
127 <patternset refid="lwjgl-macosx-lwjgl.fileset"/>
128 </fileset>
129 </jar>
130 </target>
131
132 <target name="-copymavenpoms">
133 <copy todir="${lwjgl.dstMaven}">
134 <fileset dir="${lwjgl.maven}">
135 <include name="*.pom" />
136 </fileset>
137 <filterset>
138 <filter token="VERSION" value="${lwjgl-maven-version}"/>
139 </filterset>
140 </copy>
141 </target>
142
143 <target name="-copymavendeploybuild">
144 <copy todir="${lwjgl.dstMaven}">
145 <fileset dir="${lwjgl.maven}">
146 <include name="build.xml" />
147 </fileset>
148 </copy>
149 </target>
150
151 <target name="-copymaventdist">
152 <zip destfile="${lwjgl.dist}/lwjgl-maven-${lwjgl.version}.zip" basedir="${lwjgl.temp}" includes="maven/**" />
153 </target>
154 </project>
1010 <input message="Please type the password for the keystore" addproperty="sign.pwd"/>
1111
1212 <antcall target="-webstart_demo">
13 <param name="keystore" value="signing/matzon_java_code_signing.keystore"/>
14 <param name="alias" value="oddlabs_java_code_signing"/>
13 <param name="keystore" value="signing/lwjgl.jks"/>
14 <param name="alias" value="lwjgl"/>
1515 <param name="password" value="${sign.pwd}"/>
1616 </antcall>
1717 </target>
1818
19 <!-- -->
19 <!-- Create webstart demo and extension from release files -->
2020 <target name="-webstart_demo" description="Using released files, creates the necessary files used for jnlp demos">
2121
2222 <!-- delete existing temp -->
2323 <delete dir="${lwjgl.temp}"/>
2424
25 <!-- unzip common files -->
26 <unzip src="${lwjgl.dist}/lwjgl-${lwjgl.version}.zip" dest="${lwjgl.temp}/jnlp/temp" overwrite="true"/>
27 <copy file="${lwjgl.lib}/lwjgl_test.jar" tofile="${lwjgl.temp}/jnlp/temp/lwjgl-${lwjgl.version}/lwjgl_test.jar"/>
28 <copy file="${lwjgl.lib}/lwjgl_util.jar" tofile="${lwjgl.temp}/jnlp/temp/lwjgl-${lwjgl.version}/lwjgl_util.jar"/>
25 <!-- unzip release to temp dir -->
26 <unzip src="${lwjgl.dist}/lwjgl-${lwjgl.version}.zip" dest="${lwjgl.temp}/webstart/temp" overwrite="true"/>
2927
30 <!-- move files to unified structure -->
31 <move todir="${lwjgl.temp}/jnlp/temp">
32 <fileset dir="${lwjgl.temp}/jnlp/temp/lwjgl-${lwjgl.version}/">
33 <include name="**"/>
28 <!-- DEMO SECTION -->
29 <move file="${lwjgl.temp}/webstart/temp/lwjgl-${lwjgl.version}/jar/lwjgl_test.jar" tofile="${lwjgl.temp}/webstart/lwjgl_test.jar"/>
30 <jar destfile="${lwjgl.temp}/webstart/lwjgl_test.jar" update="true">
31 <manifest>
32 <attribute name="Sealed" value="true"/>
33 </manifest>
34 </jar>
35 <jar destfile="${lwjgl.temp}/webstart/media.jar" basedir="${lwjgl.res}">
36 <manifest>
37 <attribute name="Sealed" value="true"/>
38 </manifest>
39 </jar>
40
41 <!-- EXTENSION SECTION -->
42 <move todir="${lwjgl.temp}/webstart/${lwjgl.version}/" flatten="true">
43 <fileset dir="${lwjgl.temp}/webstart/temp">
44 <include name="**/jinput.jar"/>
45 <include name="**/lwjgl*.jar"/>
46 <exclude name="**/lwjgl_util_applet.jar"/>
47 <exclude name="**/lwjgl-debug.jar"/>
3448 </fileset>
3549 </move>
3650
37 <!-- move relevant files to root -->
38 <move todir="${lwjgl.temp}/jnlp/" flatten="true">
39 <fileset dir="${lwjgl.temp}/jnlp/temp">
40 <include name="**/jinput.jar"/>
41 <include name="**/lwjgl*.jar"/>
42 </fileset>
43 </move>
44
45 <!-- update Trusted-Library -->
46 <jar destfile="${lwjgl.temp}/jnlp/lwjgl.jar" update="true">
51 <jar destfile="${lwjgl.temp}/webstart/${lwjgl.version}/lwjgl.jar" update="true">
4752 <manifest>
53 <attribute name="Specification-Title" value="LWJGL ${lwjgl.version}"/>
54 <attribute name="Specification-Version" value="${lwjgl.version}"/>
55 <attribute name="Specification-Vendor" value="lwjgl.org"/>
56 <attribute name="Implementation-Title" value="LWJGL ${lwjgl.version}"/>
57 <attribute name="Implementation-Version" value="${lwjgl.version}"/>
58 <attribute name="Implementation-Vendor" value="lwjgl.org"/>
59 <attribute name="Implementation-Vendor-Id" value="org.lwjgl"/>
60 <attribute name="Extension-Name" value="org.lwjgl"/>
4861 <attribute name="Sealed" value="true"/>
4962 <attribute name="Trusted-Library" value="true"/>
5063 </manifest>
5164 </jar>
5265
53 <jar destfile="${lwjgl.temp}/jnlp/jinput.jar" update="true">
66 <jar destfile="${lwjgl.temp}/webstart/${lwjgl.version}/jinput.jar" update="true">
5467 <manifest>
68 <attribute name="Specification-Title" value="LWJGL ${lwjgl.version}"/>
69 <attribute name="Specification-Version" value="${lwjgl.version}"/>
70 <attribute name="Specification-Vendor" value="lwjgl.org"/>
71 <attribute name="Implementation-Title" value="LWJGL ${lwjgl.version}"/>
72 <attribute name="Implementation-Version" value="${lwjgl.version}"/>
73 <attribute name="Implementation-Vendor" value="lwjgl.org"/>
74 <attribute name="Implementation-Vendor-Id" value="org.lwjgl"/>
75 <attribute name="Extension-Name" value="org.lwjgl"/>
5576 <attribute name="Sealed" value="true"/>
77 <attribute name="Trusted-Library" value="true"/>
5678 </manifest>
5779 </jar>
5880
59 <jar destfile="${lwjgl.temp}/jnlp/lwjgl_util.jar" update="true">
81 <jar destfile="${lwjgl.temp}/webstart/${lwjgl.version}/lwjgl_util.jar" update="true">
6082 <manifest>
83 <attribute name="Specification-Title" value="LWJGL ${lwjgl.version}"/>
84 <attribute name="Specification-Version" value="${lwjgl.version}"/>
85 <attribute name="Specification-Vendor" value="lwjgl.org"/>
86 <attribute name="Implementation-Title" value="LWJGL ${lwjgl.version}"/>
87 <attribute name="Implementation-Version" value="${lwjgl.version}"/>
88 <attribute name="Implementation-Vendor" value="lwjgl.org"/>
89 <attribute name="Implementation-Vendor-Id" value="org.lwjgl"/>
90 <attribute name="Extension-Name" value="org.lwjgl"/>
6191 <attribute name="Sealed" value="true"/>
92 <attribute name="Trusted-Library" value="true"/>
6293 </manifest>
63 </jar>
94 </jar>
6495
6596 <!-- create native jars -->
66 <jar destfile="${lwjgl.temp}/jnlp/native_windows.jar" basedir="${lwjgl.temp}/jnlp/temp/native/windows">
97 <jar destfile="${lwjgl.temp}/webstart/${lwjgl.version}/native_windows.jar" basedir="${lwjgl.temp}/webstart/temp/lwjgl-${lwjgl.version}/native/windows">
6798 <manifest>
99 <attribute name="Specification-Title" value="LWJGL ${lwjgl.version}"/>
100 <attribute name="Specification-Version" value="${lwjgl.version}"/>
101 <attribute name="Specification-Vendor" value="lwjgl.org"/>
102 <attribute name="Implementation-Title" value="LWJGL ${lwjgl.version}"/>
103 <attribute name="Implementation-Version" value="${lwjgl.version}"/>
104 <attribute name="Implementation-Vendor" value="lwjgl.org"/>
105 <attribute name="Implementation-Vendor-Id" value="org.lwjgl"/>
106 <attribute name="Extension-Name" value="org.lwjgl"/>
68107 <attribute name="Sealed" value="true"/>
108 <attribute name="Trusted-Library" value="true"/>
69109 </manifest>
70110 </jar>
71111
72 <jar destfile="${lwjgl.temp}/jnlp/native_linux.jar" basedir="${lwjgl.temp}/jnlp/temp/native/linux">
112 <jar destfile="${lwjgl.temp}/webstart/${lwjgl.version}/native_linux.jar" basedir="${lwjgl.temp}/webstart/temp/lwjgl-${lwjgl.version}/native/linux">
73113 <manifest>
114 <attribute name="Specification-Title" value="LWJGL ${lwjgl.version}"/>
115 <attribute name="Specification-Version" value="${lwjgl.version}"/>
116 <attribute name="Specification-Vendor" value="lwjgl.org"/>
117 <attribute name="Implementation-Title" value="LWJGL ${lwjgl.version}"/>
118 <attribute name="Implementation-Version" value="${lwjgl.version}"/>
119 <attribute name="Implementation-Vendor" value="lwjgl.org"/>
120 <attribute name="Implementation-Vendor-Id" value="org.lwjgl"/>
121 <attribute name="Extension-Name" value="org.lwjgl"/>
74122 <attribute name="Sealed" value="true"/>
123 <attribute name="Trusted-Library" value="true"/>
75124 </manifest>
76125 </jar>
77126
78 <jar destfile="${lwjgl.temp}/jnlp/native_macosx.jar" basedir="${lwjgl.temp}/jnlp/temp/native/macosx">
127 <jar destfile="${lwjgl.temp}/webstart/${lwjgl.version}/native_macosx.jar" basedir="${lwjgl.temp}/webstart/temp/lwjgl-${lwjgl.version}/native/macosx">
79128 <manifest>
129 <attribute name="Specification-Title" value="LWJGL ${lwjgl.version}"/>
130 <attribute name="Specification-Version" value="${lwjgl.version}"/>
131 <attribute name="Specification-Vendor" value="lwjgl.org"/>
132 <attribute name="Implementation-Title" value="LWJGL ${lwjgl.version}"/>
133 <attribute name="Implementation-Version" value="${lwjgl.version}"/>
134 <attribute name="Implementation-Vendor" value="lwjgl.org"/>
135 <attribute name="Implementation-Vendor-Id" value="org.lwjgl"/>
136 <attribute name="Extension-Name" value="org.lwjgl"/>
80137 <attribute name="Sealed" value="true"/>
138 <attribute name="Trusted-Library" value="true"/>
81139 </manifest>
82140 </jar>
83141
84 <jar destfile="${lwjgl.temp}/jnlp/native_solaris.jar" basedir="${lwjgl.temp}/jnlp/temp/native/solaris">
142 <jar destfile="${lwjgl.temp}/webstart/${lwjgl.version}/native_solaris.jar" basedir="${lwjgl.temp}/webstart/temp/lwjgl-${lwjgl.version}/native/solaris">
85143 <manifest>
144 <attribute name="Specification-Title" value="LWJGL ${lwjgl.version}"/>
145 <attribute name="Specification-Version" value="${lwjgl.version}"/>
146 <attribute name="Specification-Vendor" value="lwjgl.org"/>
147 <attribute name="Implementation-Title" value="LWJGL ${lwjgl.version}"/>
148 <attribute name="Implementation-Version" value="${lwjgl.version}"/>
149 <attribute name="Implementation-Vendor" value="lwjgl.org"/>
150 <attribute name="Implementation-Vendor-Id" value="org.lwjgl"/>
151 <attribute name="Extension-Name" value="org.lwjgl"/>
86152 <attribute name="Sealed" value="true"/>
87 </manifest>
88 </jar>
89
90 <!-- create media jar -->
91 <jar destfile="${lwjgl.temp}/jnlp/media.jar" basedir="${lwjgl.res}">
92 <manifest>
93 <attribute name="Sealed" value="true"/>
153 <attribute name="Trusted-Library" value="true"/>
94154 </manifest>
95155 </jar>
96156
97157 <!-- sign 'em -->
98 <signjar jar="${lwjgl.temp}/jnlp/lwjgl.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
99 <signjar jar="${lwjgl.temp}/jnlp/lwjgl_util.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
100 <signjar jar="${lwjgl.temp}/jnlp/native_solaris.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
101 <signjar jar="${lwjgl.temp}/jnlp/native_linux.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
102 <signjar jar="${lwjgl.temp}/jnlp/native_macosx.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
103 <signjar jar="${lwjgl.temp}/jnlp/native_windows.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
104 <signjar jar="${lwjgl.temp}/jnlp/jinput.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
105 <signjar jar="${lwjgl.temp}/jnlp/media.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
158 <signjar jar="${lwjgl.temp}/webstart/${lwjgl.version}/lwjgl.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
159 <signjar jar="${lwjgl.temp}/webstart/${lwjgl.version}/lwjgl_util.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
160 <signjar jar="${lwjgl.temp}/webstart/${lwjgl.version}/jinput.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
161 <signjar jar="${lwjgl.temp}/webstart/${lwjgl.version}/native_solaris.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
162 <signjar jar="${lwjgl.temp}/webstart/${lwjgl.version}/native_linux.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
163 <signjar jar="${lwjgl.temp}/webstart/${lwjgl.version}/native_macosx.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
164 <signjar jar="${lwjgl.temp}/webstart/${lwjgl.version}/native_windows.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
165
166 <!-- copy over extension jnlp file -->
167 <copy todir="${lwjgl.temp}/webstart/${lwjgl.version}">
168 <fileset dir="${lwjgl.web}/webstart">
169 <include name="extension.jnlp"/>
170 </fileset>
171 <filterset>
172 <filter token="LWJGL_VERSION" value="${lwjgl.version}"/>
173 </filterset>
174 </copy>
175
176 <!-- nuke extracted dir -->
177 <delete dir="${lwjgl.temp}/webstart/temp"/>
178
106179 </target>
107180 </project>
1515 <fileset dir="." includes="*.so"/>
1616 </delete>
1717 </target>
18
18
1919 <target name="compile">
2020 <exec executable="uname" outputproperty="hwplatform">
2121 <arg value="-m"/>
2626 <condition property="cflags_pthread" value="-pthreads" else="-pthread">
2727 <os name="SunOS" />
2828 </condition>
29 <condition property="version_script_flags32" value="" else="-Wl,--version-script=${native}/linux/lwjgl.map">
29 <condition property="version_script_flags32" value="" else="-Wl,--version-script='${native}/linux/lwjgl.map'">
3030 <os name="SunOS" />
3131 </condition>
32 <condition property="version_script_flags64" value="-m64" else="-Wl,--version-script=${native}/linux/lwjgl.map">
32 <condition property="version_script_flags64" value="-m64" else="-Wl,--version-script='${native}/linux/lwjgl.map'">
3333 <and>
3434 <os name="SunOS" />
3535 </and>
4949 </or>
5050 </not>
5151 </condition>
52
52
5353 <!-- On linux, the 64 bit jre doesn't have the 32 bit libs -->
5454 <condition property="build.64bit.only">
5555 <and>
5757 <equals arg1="${hwplatform}" arg2="x86_64"/>
5858 </and>
5959 </condition>
60
60
6161 <antcall target="compile32"/>
6262 <antcall target="compile64"/>
6363 </target>
64
64
6565 <target name="compile32" unless="build.64bit.only">
6666 <mkdir dir="x32"/>
6767 <apply dir="x32" executable="gcc" skipemptyfilesets="true" failonerror="true">
8888 </apply>
8989 </target>
9090
91 <target name="compile64" unless="build.32bit.only">
91 <target name="compile64" unless="build.32bit.only">
9292 <mkdir dir="x64"/>
9393 <apply dir="x64" executable="gcc" skipemptyfilesets="true" failonerror="true">
9494 <arg line="${cflags64} ${cflags_pthread}"/>
3030 */
3131 package org.lwjgl;
3232
33 import java.nio.Buffer;
34 import java.nio.ByteBuffer;
35 import java.nio.DoubleBuffer;
36 import java.nio.FloatBuffer;
37 import java.nio.IntBuffer;
38 import java.nio.ShortBuffer;
39 import java.nio.LongBuffer;
33 import java.nio.*;
4034
4135 /**
4236 * <p>A class to check buffer boundaries in general. If there is unsufficient space
4741 * </p>
4842 * @author cix_foo <cix_foo@users.sourceforge.net>
4943 * @author elias_naur <elias_naur@users.sourceforge.net>
50 * @version $Revision: 3334 $
51 * $Id: BufferChecks.java 3334 2010-04-22 23:21:48Z spasi $
44 * @version $Revision: 3419 $
45 * $Id: BufferChecks.java 3419 2010-09-30 17:21:50Z spasi $
5246 */
5347 public class BufferChecks {
5448 /** Static methods only! */
8680 }
8781 }
8882
89 /** Helper methods to ensure an IntBuffer is null-terminated */
83 /** Helper method to ensure an IntBuffer is null-terminated */
9084 public static void checkNullTerminated(IntBuffer buf) {
91 if ( buf.get(buf.limit() - 1) != 0 ) {
85 if ( LWJGLUtil.CHECKS && buf.get(buf.limit() - 1) != 0 ) {
86 throw new IllegalArgumentException("Missing null termination");
87 }
88 }
89
90 /** Helper method to ensure a LongBuffer is null-terminated */
91 public static void checkNullTerminated(LongBuffer buf) {
92 if ( LWJGLUtil.CHECKS && buf.get(buf.limit() - 1) != 0 ) {
93 throw new IllegalArgumentException("Missing null termination");
94 }
95 }
96
97 /** Helper method to ensure a PointerBuffer is null-terminated */
98 public static void checkNullTerminated(PointerBuffer buf) {
99 if ( LWJGLUtil.CHECKS && buf.get(buf.limit() - 1) != 0 ) {
92100 throw new IllegalArgumentException("Missing null termination");
93101 }
94102 }
137145 }
138146 }
139147
148 public static void checkDirect(PointerBuffer buf) {
149 // NO-OP, PointerBuffer is always direct.
150 }
151
152 public static void checkArray(Object[] array) {
153 if ( LWJGLUtil.CHECKS && (array == null || array.length == 0) )
154 throw new IllegalArgumentException("Invalid array");
155 }
156
140157 /**
141158 * This is a separate call to help inline checkBufferSize.
142159 */
143160 private static void throwBufferSizeException(Buffer buf, int size) {
144161 throw new IllegalArgumentException("Number of remaining buffer elements is " + buf.remaining() + ", must be at least " + size);
162 }
163
164 private static void throwBufferSizeException(PointerBuffer buf, int size) {
165 throw new IllegalArgumentException("Number of remaining pointer buffer elements is " + buf.remaining() + ", must be at least " + size);
166 }
167
168 private static void throwArraySizeException(Object[] array, int size) {
169 throw new IllegalArgumentException("Number of array elements is " + array.length + ", must be at least " + size);
170 }
171
172 private static void throwArraySizeException(long[] array, int size) {
173 throw new IllegalArgumentException("Number of array elements is " + array.length + ", must be at least " + size);
145174 }
146175
147176 /**
160189 }
161190 }
162191
192 /**
193 * Detects the buffer type and performs the corresponding check
194 * and also returns the buffer position in bytes.
195 *
196 * @param buffer the buffer to check
197 * @param size the size to check
198 *
199 * @return the buffer position in bytes
200 */
201 public static int checkBuffer(final Buffer buffer, final int size) {
202 final int posShift;
203 if ( buffer instanceof ByteBuffer ) {
204 BufferChecks.checkBuffer((ByteBuffer)buffer, size);
205 posShift = 0;
206 } else if ( buffer instanceof ShortBuffer ) {
207 BufferChecks.checkBuffer((ShortBuffer)buffer, size);
208 posShift = 1;
209 } else if ( buffer instanceof IntBuffer ) {
210 BufferChecks.checkBuffer((IntBuffer)buffer, size);
211 posShift = 2;
212 } else if ( buffer instanceof LongBuffer ) {
213 BufferChecks.checkBuffer((LongBuffer)buffer, size);
214 posShift = 4;
215 } else if ( buffer instanceof FloatBuffer ) {
216 BufferChecks.checkBuffer((FloatBuffer)buffer, size);
217 posShift = 2;
218 } else if ( buffer instanceof DoubleBuffer ) {
219 BufferChecks.checkBuffer((DoubleBuffer)buffer, size);
220 posShift = 4;
221 } else
222 throw new IllegalArgumentException("Unsupported Buffer type specified: " + buffer.getClass());
223
224 return buffer.position() << posShift;
225 }
226
163227 public static void checkBuffer(ByteBuffer buf, int size) {
164228 if ( LWJGLUtil.CHECKS ) {
165229 checkBufferSize(buf, size);
201265 checkDirect(buf);
202266 }
203267 }
204 }
268
269 public static void checkBuffer(PointerBuffer buf, int size) {
270 if ( LWJGLUtil.CHECKS && buf.remaining() < size ) {
271 throwBufferSizeException(buf, size);
272 }
273 }
274
275 public static void checkArray(Object[] array, int size) {
276 if ( LWJGLUtil.CHECKS && array.length < size )
277 throwArraySizeException(array, size);
278 }
279
280 public static void checkArray(long[] array, int size) {
281 if ( LWJGLUtil.CHECKS && array.length < size )
282 throwArraySizeException(array, size);
283 }
284
285 }
4444 * Some often-used Buffer code for creating native buffers of the appropriate size.
4545 *
4646 * @author $Author: matzon $
47 * @version $Revision: 2983 $
48 * $Id: BufferUtils.java 2983 2008-04-07 18:36:09Z matzon $
47 * @version $Revision: 3456 $
48 * $Id: BufferUtils.java 3456 2010-11-24 21:48:23Z matzon $
4949 */
5050
5151 public final class BufferUtils {
120120 }
121121
122122 /**
123 * Construct a PointerBuffer with the specified number
124 * of elements.
125 * @param size The size, in memory addresses
126 * @return a PointerBuffer
127 */
128 public static PointerBuffer createPointerBuffer(int size) {
129 return PointerBuffer.allocateDirect(size);
130 }
131
132 /**
123133 * @return n, where buffer_element_size=2^n.
124134 */
125135 public static int getElementSizeExponent(Buffer buf) {
144154 return buffer.position() << getElementSizeExponent(buffer);
145155 }
146156
157 /** Fill buffer with zeros from position to remaining */
158 public static void zeroBuffer(ByteBuffer b) {
159 zeroBuffer0(b, b.position(), b.remaining());
160 }
161
162 /** Fill buffer with zeros from position to remaining */
163 public static void zeroBuffer(ShortBuffer b) {
164 zeroBuffer0(b, b.position()*2L, b.remaining()*2L);
165 }
166
167 /** Fill buffer with zeros from position to remaining */
168 public static void zeroBuffer(CharBuffer b) {
169 zeroBuffer0(b, b.position()*2L, b.remaining()*2L);
170 }
171
172 /** Fill buffer with zeros from position to remaining */
173 public static void zeroBuffer(IntBuffer b) {
174 zeroBuffer0(b, b.position()*4L, b.remaining()*4L);
175 }
176
177 /** Fill buffer with zeros from position to remaining */
178 public static void zeroBuffer(FloatBuffer b) {
179 zeroBuffer0(b, b.position()*4L, b.remaining()*4L);
180 }
181
182 /** Fill buffer with zeros from position to remaining */
183 public static void zeroBuffer(LongBuffer b) {
184 zeroBuffer0(b, b.position()*8L, b.remaining()*8L);
185 }
186
187 /** Fill buffer with zeros from position to remaining */
188 public static void zeroBuffer(DoubleBuffer b) {
189 zeroBuffer0(b, b.position()*8L, b.remaining()*8L);
190 }
191
192 /** Fill buffer with zeros from position to remaining */
193 private static native void zeroBuffer0(Buffer b, long off, long size);
147194 }
3434 /**
3535 *
3636 * @author elias_naur <elias_naur@users.sourceforge.net>
37 * @version $Revision: 3055 $
38 * $Id: DefaultSysImplementation.java 3055 2008-04-30 14:58:47Z elias_naur $
37 * @version $Revision: 3426 $
38 * $Id: DefaultSysImplementation.java 3426 2010-10-01 22:20:14Z spasi $
3939 */
4040 abstract class DefaultSysImplementation implements SysImplementation {
4141 public native int getJNIVersion();
42 public native int getPointerSize();
4243 public native void setDebug(boolean debug);
4344
4445 public long getTimerResolution() {
3131 package org.lwjgl;
3232
3333 import java.io.File;
34 import java.lang.reflect.Field;
3435 import java.lang.reflect.Method;
36 import java.lang.reflect.Modifier;
3537 import java.nio.ByteBuffer;
3638 import java.security.AccessController;
3739 import java.security.PrivilegedAction;
3840 import java.security.PrivilegedActionException;
3941 import java.security.PrivilegedExceptionAction;
40 import java.util.ArrayList;
41 import java.util.List;
42 import java.util.StringTokenizer;
43
42 import java.util.*;
4443
4544 /**
4645 * <p>
4847 * </p>
4948 *
5049 * @author Brian Matzon <brian@matzon.dk>
51 * @version $Revision: 3334 $
52 * $Id: LWJGLUtil.java 3334 2010-04-22 23:21:48Z spasi $
50 * @version $Revision: 3475 $
51 * $Id: LWJGLUtil.java 3475 2011-01-23 07:48:50Z matzon $
5352 */
5453 public class LWJGLUtil {
5554 public static final int PLATFORM_LINUX = 1;
5857 public static final String PLATFORM_LINUX_NAME = "linux";
5958 public static final String PLATFORM_MACOSX_NAME = "macosx";
6059 public static final String PLATFORM_WINDOWS_NAME = "windows";
61
60
6261 /** LWJGL Logo - 16 by 16 pixels */
63 public static final ByteBuffer LWJGLIcon16x16 = BufferUtils.createByteBuffer(16 * 16 * 4).put(new byte[] {
62 public static final ByteBuffer LWJGLIcon16x16 = BufferUtils.createByteBuffer(16 * 16 * 4).put(new byte[] {
6463 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
6564 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, -1, -1, -1, -62, -41, -24, -1, 116, -92, -53, -1, 80, -117,
6665 -67, -1, 84, -114, -65, -1, -122, -81, -46, -1, -25, -17, -10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
105104 });
106105
107106 /** LWJGL Logo - 32 by 32 pixels */
108 public static final ByteBuffer LWJGLIcon32x32 = BufferUtils.createByteBuffer(32 * 32 * 4).put(new byte[] {
107 public static final ByteBuffer LWJGLIcon32x32 = BufferUtils.createByteBuffer(32 * 32 * 4).put(new byte[] {
109108 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
110109 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
111110 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -6, -4, -3, -1, -53, -35,
268267
269268 public static final boolean CHECKS = !getPrivilegedBoolean("org.lwjgl.util.NoChecks");
270269
270 private static final int PLATFORM;
271
271272 static {
272273 LWJGLIcon16x16.flip();
273274 LWJGLIcon32x32.flip();
274 }
275
275
276 final String osName = getPrivilegedProperty("os.name");
277 if ( osName.startsWith("Windows") )
278 PLATFORM = PLATFORM_WINDOWS;
279 else if ( osName.startsWith("Linux") || osName.startsWith("FreeBSD") || osName.startsWith("SunOS") )
280 PLATFORM = PLATFORM_LINUX;
281 else if ( osName.startsWith("Mac OS X") || osName.startsWith("Darwin") )
282 PLATFORM = PLATFORM_MACOSX;
283 else
284 throw new LinkageError("Unknown platform: " + osName);
285 }
286
276287 /**
277288 * @see #PLATFORM_WINDOWS
278289 * @see #PLATFORM_LINUX
280291 * @return the current platform type
281292 */
282293 public static int getPlatform() {
283 String osName = getPrivilegedProperty("os.name");
284
285 if (osName.startsWith("Windows")) {
286 return PLATFORM_WINDOWS;
287 } else if (osName.startsWith("Linux") || osName.startsWith("FreeBSD") || osName.startsWith("SunOS")) {
288 return PLATFORM_LINUX;
289 } else if (osName.startsWith("Mac OS X")) {
290 return PLATFORM_MACOSX;
291 } else {
292 throw new LinkageError("Unknown platform: " + osName);
293 }
294 }
295
294 return PLATFORM;
295 }
296
296297
297298 /**
298299 * @see #PLATFORM_WINDOWS_NAME
311312 default:
312313 return "unknown";
313314 }
314 }
315 }
315316
316317 /**
317318 * Locates the paths required by a library.
335336 */
336337 public static String[] getLibraryPaths(String libname, String[] platform_lib_names, ClassLoader classloader) {
337338 // need to pass path of possible locations of library to native side
338 List possible_paths = new ArrayList();
339 List<String> possible_paths = new ArrayList<String>();
339340
340341 String classloader_path = getPathFromClassLoader(libname, classloader);
341342 if (classloader_path != null) {
343344 possible_paths.add(classloader_path);
344345 }
345346
346 for (int i = 0; i < platform_lib_names.length; i++) {
347 String platform_lib_name = platform_lib_names[i];
347 for ( String platform_lib_name : platform_lib_names ) {
348348 String lwjgl_classloader_path = getPathFromClassLoader("lwjgl", classloader);
349 if (lwjgl_classloader_path != null) {
349 if ( lwjgl_classloader_path != null ) {
350350 log("getPathFromClassLoader: Path found: " + lwjgl_classloader_path);
351351 possible_paths.add(lwjgl_classloader_path.substring(0, lwjgl_classloader_path.lastIndexOf(File.separator))
352 + File.separator + platform_lib_name);
352 + File.separator + platform_lib_name);
353353 }
354354
355355 // add Installer path
356356 String alternative_path = getPrivilegedProperty("org.lwjgl.librarypath");
357 if (alternative_path != null) {
357 if ( alternative_path != null ) {
358358 possible_paths.add(alternative_path + File.separator + platform_lib_name);
359 }
359 }
360360
361361 // Add all possible paths from java.library.path
362362 String java_library_path = getPrivilegedProperty("java.library.path");
363363
364364 StringTokenizer st = new StringTokenizer(java_library_path, File.pathSeparator);
365 while (st.hasMoreTokens()) {
365 while ( st.hasMoreTokens() ) {
366366 String path = st.nextToken();
367367 possible_paths.add(path + File.separator + platform_lib_name);
368368 }
376376 }
377377
378378 //create needed string array
379 String[] paths = new String[possible_paths.size()];
380 possible_paths.toArray(paths);
381 return paths;
379 return possible_paths.toArray(new String[possible_paths.size()]);
382380 }
383381
384382 static void execPrivileged(final String[] cmd_array) throws Exception {
385383 try {
386 Process process = (Process)AccessController.doPrivileged(new PrivilegedExceptionAction() {
387 public Object run() throws Exception {
384 Process process = AccessController.doPrivileged(new PrivilegedExceptionAction<Process>() {
385 public Process run() throws Exception {
388386 return Runtime.getRuntime().exec(cmd_array);
389387 }
390388 });
398396 }
399397
400398 private static String getPrivilegedProperty(final String property_name) {
401 return (String)AccessController.doPrivileged(new PrivilegedAction() {
402 public Object run() {
399 return AccessController.doPrivileged(new PrivilegedAction<String>() {
400 public String run() {
403401 return System.getProperty(property_name);
404402 }
405403 });
419417 private static String getPathFromClassLoader(final String libname, final ClassLoader classloader) {
420418 try {
421419 log("getPathFromClassLoader: searching for: " + libname);
422 Class c = classloader.getClass();
420 Class<?> c = classloader.getClass();
423421 while (c != null) {
424 final Class clazz = c;
422 final Class<?> clazz = c;
425423 try {
426 return (String)AccessController.doPrivileged(new PrivilegedExceptionAction() {
427 public Object run() throws Exception {
428 Method findLibrary = clazz.getDeclaredMethod("findLibrary", new Class[]{String.class});
424 return AccessController.doPrivileged(new PrivilegedExceptionAction<String>() {
425 public String run() throws Exception {
426 Method findLibrary = clazz.getDeclaredMethod("findLibrary", String.class);
429427 findLibrary.setAccessible(true);
430 Object[] arguments = new Object[] {libname};
431 String path = (String)findLibrary.invoke(classloader, arguments);
428 String path = (String)findLibrary.invoke(classloader, libname);
432429 return path;
433430 }
434431 });
447444 * Gets a boolean property as a privileged action.
448445 */
449446 private static boolean getPrivilegedBoolean(final String property_name) {
450 Boolean value = (Boolean)AccessController.doPrivileged(new PrivilegedAction() {
451 public Object run() {
452 return new Boolean(Boolean.getBoolean(property_name));
447 Boolean value = AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
448 public Boolean run() {
449 return Boolean.getBoolean(property_name);
453450 }
454451 });
455 return value.booleanValue();
456 }
457
452 return value;
453 }
454
458455 /**
459456 * Prints the given message to System.err if DEBUG is true.
460 *
457 *
461458 * @param msg Message to print
462459 */
463460 public static void log(String msg) {
465462 System.err.println(msg);
466463 }
467464 }
468
465
469466 /**
470467 * Method to determine if the current system is running a version of
471468 * Mac OS X better than the given version. This is only useful for Mac OS X
488485 }
489486 return major > major_required || (major == major_required && minor >= minor_required);
490487 }
491
492 }
488
489 /**
490 * Returns a map of public static final integer fields in the specified classes, to their String representations.
491 * An optional filter can be specified to only include specific fields. The target map may be null, in which
492 * case a new map is allocated and returned.
493 * <p>
494 * This method is useful when debugging to quickly identify values returned from the AL/GL/CL APIs.
495 *
496 * @param filter the filter to use (optional)
497 * @param target the target map (optional)
498 * @param tokenClasses an array of classes to get tokens from
499 *
500 * @return the token map
501 */
502
503 public static Map<Integer, String> getClassTokens(final TokenFilter filter, final Map<Integer, String> target, final Class ... tokenClasses) {
504 return getClassTokens(filter, target, Arrays.asList(tokenClasses));
505 }
506
507 /**
508 * Returns a map of public static final integer fields in the specified classes, to their String representations.
509 * An optional filter can be specified to only include specific fields. The target map may be null, in which
510 * case a new map is allocated and returned.
511 * <p>
512 * This method is useful when debugging to quickly identify values returned from the AL/GL/CL APIs.
513 *
514 * @param filter the filter to use (optional)
515 * @param target the target map (optional)
516 * @param tokenClasses the classes to get tokens from
517 *
518 * @return the token map
519 */
520 public static Map<Integer, String> getClassTokens(final TokenFilter filter, Map<Integer, String> target, final Iterable<Class> tokenClasses) {
521 if ( target == null )
522 target = new HashMap<Integer, String>();
523
524 final int TOKEN_MODIFIERS = Modifier.PUBLIC | Modifier.STATIC | Modifier.FINAL;
525
526 for ( final Class tokenClass : tokenClasses ) {
527 for ( final Field field : tokenClass.getDeclaredFields() ) {
528 // Get only <public static final int> fields.
529 if ( (field.getModifiers() & TOKEN_MODIFIERS) == TOKEN_MODIFIERS && field.getType() == int.class ) {
530 try {
531 final int value = field.getInt(null);
532 if ( filter != null && !filter.accept(field, value) )
533 continue;
534
535 if ( target.containsKey(value) ) // Print colliding tokens in their hex representation.
536 target.put(value, toHexString(value));
537 else
538 target.put(value, field.getName());
539 } catch (IllegalAccessException e) {
540 // Ignore
541 }
542 }
543 }
544 }
545
546 return target;
547 }
548
549 /**
550 * Returns a string representation of the integer argument as an
551 * unsigned integer in base&nbsp;16. The string will be uppercase
552 * and will have a leading '0x'.
553 *
554 * @param value the integer value
555 *
556 * @return the hex string representation
557 */
558 public static String toHexString(final int value) {
559 return "0x" + Integer.toHexString(value).toUpperCase();
560 }
561
562 /** Simple interface for Field filtering. */
563 public interface TokenFilter {
564
565 /**
566 * Should return true if the specified Field passes the filter.
567 *
568 * @param field the Field to test
569 * @param value the integer value of the field
570 *
571 * @result true if the Field is accepted
572 */
573 boolean accept(Field field, int value);
574
575 }
576
577 }
3434 /**
3535 *
3636 * @author elias_naur <elias_naur@users.sourceforge.net>
37 * @version $Revision: 3298 $
38 * $Id: LinuxSysImplementation.java 3298 2010-03-28 23:11:17Z matzon $
37 * @version $Revision: 3418 $
38 * $Id: LinuxSysImplementation.java 3418 2010-09-28 21:11:35Z spasi $
3939 */
4040 final class LinuxSysImplementation extends J2SESysImplementation {
41 private final static int JNI_VERSION = 18;
41 private static final int JNI_VERSION = 19;
4242
4343 static {
4444 java.awt.Toolkit.getDefaultToolkit(); // This will make sure libjawt.so is loaded
5454
5555 String[] browsers = {"xdg-open", "firefox", "mozilla", "opera", "konqueror", "nautilus", "galeon", "netscape"};
5656
57 for (int i = 0; i < browsers.length; i ++) {
58 final String browser = browsers[i];
57 for ( final String browser : browsers ) {
5958 try {
6059 LWJGLUtil.execPrivileged(new String[] { browser, url });
6160 return true;
3737 /**
3838 *
3939 * @author elias_naur <elias_naur@users.sourceforge.net>
40 * @version $Revision: 3298 $
41 * $Id: MacOSXSysImplementation.java 3298 2010-03-28 23:11:17Z matzon $
40 * @version $Revision: 3418 $
41 * $Id: MacOSXSysImplementation.java 3418 2010-09-28 21:11:35Z spasi $
4242 */
4343 final class MacOSXSysImplementation extends J2SESysImplementation {
44 private final static int JNI_VERSION = 18;
44 private static final int JNI_VERSION = 19;
4545
4646 static {
4747 // Make sure AWT is properly initialized. This avoids hangs on Mac OS X 10.3
4848 * $Id: BufferChecks.java 2762 2007-04-11 16:13:05Z elias_naur $
4949 */
5050 public final class NondirectBufferWrapper {
51 private final static int INITIAL_BUFFER_SIZE = 1;
52
53 private final static ThreadLocal thread_buffer = new ThreadLocal() {
54 protected Object initialValue() {
51 private static final int INITIAL_BUFFER_SIZE = 1;
52
53 private static final ThreadLocal<CachedBuffers> thread_buffer = new ThreadLocal<CachedBuffers>() {
54 protected CachedBuffers initialValue() {
5555 return new CachedBuffers(INITIAL_BUFFER_SIZE);
5656 }
5757 };
5858
5959 private static CachedBuffers getCachedBuffers(int minimum_byte_size) {
60 CachedBuffers buffers = (CachedBuffers)thread_buffer.get();
60 CachedBuffers buffers = thread_buffer.get();
6161 int current_byte_size = buffers.byte_buffer.capacity();
6262 if (minimum_byte_size > current_byte_size) {
6363 buffers = new CachedBuffers(minimum_byte_size);
377377 return direct_buffer;
378378 }
379379
380 private final static class CachedBuffers {
380 private static final class CachedBuffers {
381381 private final ByteBuffer byte_buffer;
382382 private final ShortBuffer short_buffer_big;
383383 private final IntBuffer int_buffer_big;
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;
32
33 import java.lang.reflect.Method;
34 import java.nio.*;
35
36 /**
37 * This class is a container for architecture independent pointer data.
38 * The interface mirrors the NIO LongBuffer API for convenience.
39 *
40 * @author Spasi
41 */
42 public class PointerBuffer implements Comparable {
43
44 private static final boolean is64Bit;
45
46 static {
47 // Use reflection so that we can compile this class for the Generator.
48 boolean is64 = false;
49 try {
50 Method m = Class.forName("org.lwjgl.Sys").getDeclaredMethod("is64Bit", (Class[])null);
51 is64 = (Boolean)m.invoke(null, (Object[])null);
52 } catch (Throwable t) {
53 // ignore
54 } finally {
55 is64Bit = is64;
56 }
57 }
58
59 protected final ByteBuffer pointers;
60
61 protected final Buffer view;
62 protected final IntBuffer view32;
63 protected final LongBuffer view64;
64
65 /**
66 * Creates a new PointerBuffer with the specified capacity.
67 *
68 * @param capacity the PointerBuffer size, in number of pointers
69 */
70 public PointerBuffer(final int capacity) {
71 this(BufferUtils.createByteBuffer(capacity * getPointerSize()));
72 }
73
74 /**
75 * Creates a new PointerBuffer using the specified ByteBuffer as its pointer
76 * data source. This is useful for users that do their own memory management
77 * over a big ByteBuffer, instead of allocating many small ones.
78 *
79 * @param source the source buffer
80 */
81 public PointerBuffer(final ByteBuffer source) {
82 if ( !source.isDirect() )
83 throw new IllegalArgumentException("ByteBuffer is not direct");
84
85 pointers = source.slice().order(source.order());
86
87 if ( is64Bit ) {
88 view32 = null;
89 view = view64 = pointers.asLongBuffer();
90 } else {
91 view = view32 = pointers.asIntBuffer();
92 view64 = null;
93 }
94 }
95
96 /**
97 * Returns the ByteBuffer that backs this PointerBuffer.
98 *
99 * @return the pointer ByteBuffer
100 */
101 public ByteBuffer getBuffer() {
102 return pointers;
103 }
104
105 /** Returns true if the underlying architecture is 64bit. */
106 public static boolean is64Bit() {
107 return is64Bit;
108 }
109
110 /**
111 * Returns the pointer size in bytes, based on the underlying architecture.
112 *
113 * @return The pointer size in bytes
114 */
115 public static int getPointerSize() {
116 return is64Bit ? 8 : 4;
117 }
118
119 /**
120 * Returns this buffer's capacity. </p>
121 *
122 * @return The capacity of this buffer
123 */
124 public final int capacity() {
125 return view.capacity();
126 }
127
128 /**
129 * Returns this buffer's position. </p>
130 *
131 * @return The position of this buffer
132 */
133 public final int position() {
134 return view.position();
135 }
136
137 /**
138 * Returns this buffer's position, in bytes. </p>
139 *
140 * @return The position of this buffer in bytes.
141 */
142 public final int positionByte() {
143 return position() * getPointerSize();
144 }
145
146 /**
147 * Sets this buffer's position. If the mark is defined and larger than the
148 * new position then it is discarded. </p>
149 *
150 * @param newPosition The new position value; must be non-negative
151 * and no larger than the current limit
152 *
153 * @return This buffer
154 *
155 * @throws IllegalArgumentException If the preconditions on <tt>newPosition</tt> do not hold
156 */
157 public final PointerBuffer position(int newPosition) {
158 view.position(newPosition);
159 return this;
160 }
161
162 /**
163 * Returns this buffer's limit. </p>
164 *
165 * @return The limit of this buffer
166 */
167 public final int limit() {
168 return view.limit();
169 }
170
171 /**
172 * Sets this buffer's limit. If the position is larger than the new limit
173 * then it is set to the new limit. If the mark is defined and larger than
174 * the new limit then it is discarded. </p>
175 *
176 * @param newLimit The new limit value; must be non-negative
177 * and no larger than this buffer's capacity
178 *
179 * @return This buffer
180 *
181 * @throws IllegalArgumentException If the preconditions on <tt>newLimit</tt> do not hold
182 */
183 public final PointerBuffer limit(int newLimit) {
184 view.limit(newLimit);
185 return this;
186 }
187
188 /**
189 * Sets this buffer's mark at its position. </p>
190 *
191 * @return This buffer
192 */
193 public final PointerBuffer mark() {
194 view.mark();
195 return this;
196 }
197
198 /**
199 * Resets this buffer's position to the previously-marked position.
200 * <p/>
201 * <p> Invoking this method neither changes nor discards the mark's
202 * value. </p>
203 *
204 * @return This buffer
205 *
206 * @throws java.nio.InvalidMarkException If the mark has not been set
207 */
208 public final PointerBuffer reset() {
209 view.reset();
210 return this;
211 }
212
213 /**
214 * Clears this buffer. The position is set to zero, the limit is set to
215 * the capacity, and the mark is discarded.
216 * <p/>
217 * <p> Invoke this method before using a sequence of channel-read or
218 * <i>put</i> operations to fill this buffer. For example:
219 * <p/>
220 * <blockquote><pre>
221 * buf.clear(); // Prepare buffer for reading
222 * in.read(buf); // Read data</pre></blockquote>
223 * <p/>
224 * <p> This method does not actually erase the data in the buffer, but it
225 * is named as if it did because it will most often be used in situations
226 * in which that might as well be the case. </p>
227 *
228 * @return This buffer
229 */
230 public final PointerBuffer clear() {
231 view.clear();
232 return this;
233 }
234
235 /**
236 * Flips this buffer. The limit is set to the current position and then
237 * the position is set to zero. If the mark is defined then it is
238 * discarded.
239 * <p/>
240 * <p> After a sequence of channel-read or <i>put</i> operations, invoke
241 * this method to prepare for a sequence of channel-write or relative
242 * <i>get</i> operations. For example:
243 * <p/>
244 * <blockquote><pre>
245 * buf.put(magic); // Prepend header
246 * in.read(buf); // Read data into rest of buffer
247 * buf.flip(); // Flip buffer
248 * out.write(buf); // Write header + data to channel</pre></blockquote>
249 * <p/>
250 * <p> This method is often used in conjunction with the {@link
251 * java.nio.ByteBuffer#compact compact} method when transferring data from
252 * one place to another. </p>
253 *
254 * @return This buffer
255 */
256 public final PointerBuffer flip() {
257 view.flip();
258 return this;
259 }
260
261 /**
262 * Rewinds this buffer. The position is set to zero and the mark is
263 * discarded.
264 * <p/>
265 * <p> Invoke this method before a sequence of channel-write or <i>get</i>
266 * operations, assuming that the limit has already been set
267 * appropriately. For example:
268 * <p/>
269 * <blockquote><pre>
270 * out.write(buf); // Write remaining data
271 * buf.rewind(); // Rewind buffer
272 * buf.get(array); // Copy data into array</pre></blockquote>
273 *
274 * @return This buffer
275 */
276 public final PointerBuffer rewind() {
277 view.rewind();
278 return this;
279 }
280
281 /**
282 * Returns the number of elements between the current position and the
283 * limit. </p>
284 *
285 * @return The number of elements remaining in this buffer
286 */
287 public final int remaining() {
288 return view.remaining();
289 }
290
291 /**
292 * Returns the number of bytes between the current position and the
293 * limit. </p>
294 *
295 * @return The number of bytes remaining in this buffer
296 */
297 public final int remainingByte() {
298 return remaining() * getPointerSize();
299 }
300
301 /**
302 * Tells whether there are any elements between the current position and
303 * the limit. </p>
304 *
305 * @return <tt>true</tt> if, and only if, there is at least one element
306 * remaining in this buffer
307 */
308 public final boolean hasRemaining() {
309 return view.hasRemaining();
310 }
311
312 /**
313 * Allocates a new pointer buffer.
314 * <p/>
315 * <p> The new buffer's position will be zero, its limit will be its
316 * capacity, and its mark will be undefined. </p>
317 *
318 * @param capacity The new buffer's capacity, in pointers
319 *
320 * @return The new pointer buffer
321 *
322 * @throws IllegalArgumentException If the <tt>capacity</tt> is a negative integer
323 */
324 public static PointerBuffer allocateDirect(int capacity) {
325 return new PointerBuffer(capacity);
326 }
327
328 /**
329 * This method is used in slice and duplicate instead of normal object construction,
330 * so that subclasses can return themselves.
331 *
332 * @param source
333 *
334 * @return A new PointerBuffer instance
335 */
336 protected PointerBuffer newInstance(final ByteBuffer source) {
337 return new PointerBuffer(source);
338 }
339
340 /**
341 * Creates a new pointer buffer whose content is a shared subsequence of
342 * this buffer's content.
343 * <p/>
344 * <p> The content of the new buffer will start at this buffer's current
345 * position. Changes to this buffer's content will be visible in the new
346 * buffer, and vice versa; the two buffers' position, limit, and mark
347 * values will be independent.
348 * <p/>
349 * <p> The new buffer's position will be zero, its capacity and its limit
350 * will be the number of longs remaining in this buffer, and its mark
351 * will be undefined. The new buffer will be direct if, and only if, this
352 * buffer is direct, and it will be read-only if, and only if, this buffer
353 * is read-only. </p>
354 *
355 * @return The new pointer buffer
356 */
357 public PointerBuffer slice() {
358 final int pointerSize = getPointerSize();
359
360 pointers.position(view.position() * pointerSize);
361 pointers.limit(view.limit() * pointerSize);
362
363 try {
364 // We're slicing in the constructor.
365 return newInstance(pointers);
366 } finally {
367 pointers.clear();
368 }
369 }
370
371 /**
372 * Creates a new pointer buffer that shares this buffer's content.
373 * <p/>
374 * <p> The content of the new buffer will be that of this buffer. Changes
375 * to this buffer's content will be visible in the new buffer, and vice
376 * versa; the two buffers' position, limit, and mark values will be
377 * independent.
378 * <p/>
379 * <p> The new buffer's capacity, limit and position will be
380 * identical to those of this buffer. The new buffer will be direct if,
381 * and only if, this buffer is direct, and it will be read-only if, and
382 * only if, this buffer is read-only. </p>
383 *
384 * @return The new pointer buffer
385 */
386 public PointerBuffer duplicate() {
387 final PointerBuffer buffer = newInstance(pointers);
388
389 buffer.position(view.position());
390 buffer.limit(view.limit());
391
392 return buffer;
393 }
394
395 /**
396 * Creates a new, read-only pointer buffer that shares this buffer's
397 * content.
398 * <p/>
399 * <p> The content of the new buffer will be that of this buffer. Changes
400 * to this buffer's content will be visible in the new buffer; the new
401 * buffer itself, however, will be read-only and will not allow the shared
402 * content to be modified. The two buffers' position, limit, and mark
403 * values will be independent.
404 * <p/>
405 * <p> The new buffer's capacity, limit and position will be
406 * identical to those of this buffer.
407 * <p/>
408 * <p> If this buffer is itself read-only then this method behaves in
409 * exactly the same way as the {@link #duplicate duplicate} method. </p>
410 *
411 * @return The new, read-only pointer buffer
412 */
413 public PointerBuffer asReadOnlyBuffer() {
414 final PointerBuffer buffer = new PointerBufferR(pointers);
415
416 buffer.position(view.position());
417 buffer.limit(view.limit());
418
419 return buffer;
420 }
421
422 public boolean isReadOnly() {
423 return false;
424 }
425
426 /**
427 * Relative <i>get</i> method. Reads the long at this buffer's
428 * current position, and then increments the position. </p>
429 *
430 * @return The long at the buffer's current position
431 *
432 * @throws BufferUnderflowException If the buffer's current position is not smaller than its limit
433 */
434 public long get() {
435 if ( is64Bit )
436 return view64.get();
437 else
438 return view32.get() & 0x00000000FFFFFFFFL;
439 }
440
441 /**
442 * Relative <i>put</i> method&nbsp;&nbsp;<i>(optional operation)</i>.
443 * <p/>
444 * <p> Writes the given long into this buffer at the current
445 * position, and then increments the position. </p>
446 *
447 * @param l The long to be written
448 *
449 * @return This buffer
450 *
451 * @throws BufferOverflowException If this buffer's current position is not smaller than its limit
452 * @throws ReadOnlyBufferException If this buffer is read-only
453 */
454 public PointerBuffer put(long l) {
455 if ( is64Bit )
456 view64.put(l);
457 else
458 view32.put((int)l);
459 return this;
460 }
461
462 /**
463 * Convenience put that accepts PointerWrapper objects.
464 *
465 * @see #put(long)
466 */
467 public PointerBuffer put(final PointerWrapper pointer) {
468 return put(pointer.getPointer());
469 }
470
471 /**
472 * Convenience put on a target ByteBuffer.
473 *
474 * @param target the target ByteBuffer
475 * @param l the long value to be written
476 */
477 public static void put(final ByteBuffer target, long l) {
478 if ( is64Bit )
479 target.putLong(l);
480 else
481 target.putInt((int)l);
482 }
483
484 /**
485 * Absolute <i>get</i> method. Reads the long at the given
486 * index. </p>
487 *
488 * @param index The index from which the long will be read
489 *
490 * @return The long at the given index
491 *
492 * @throws IndexOutOfBoundsException If <tt>index</tt> is negative
493 * or not smaller than the buffer's limit
494 */
495 public long get(int index) {
496 if ( is64Bit )
497 return view64.get(index);
498 else
499 return view32.get(index) & 0x00000000FFFFFFFFL;
500 }
501
502 /**
503 * Absolute <i>put</i> method&nbsp;&nbsp;<i>(optional operation)</i>.
504 * <p/>
505 * <p> Writes the given long into this buffer at the given
506 * index. </p>
507 *
508 * @param index The index at which the long will be written
509 * @param l The long value to be written
510 *
511 * @return This buffer
512 *
513 * @throws IndexOutOfBoundsException If <tt>index</tt> is negative
514 * or not smaller than the buffer's limit
515 * @throws ReadOnlyBufferException If this buffer is read-only
516 */
517 public PointerBuffer put(int index, long l) {
518 if ( is64Bit )
519 view64.put(index, l);
520 else
521 view32.put(index, (int)l);
522 return this;
523 }
524
525 /**
526 * Convenience put that accepts PointerWrapper objects.
527 *
528 * @see #put(int, long)
529 */
530 public PointerBuffer put(int index, PointerWrapper pointer) {
531 return put(index, pointer.getPointer());
532 }
533
534 /**
535 * Convenience put on a target ByteBuffer.
536 *
537 * @param target the target ByteBuffer
538 * @param index the index at which the long will be written
539 * @param l the long value to be written
540 */
541 public static void put(final ByteBuffer target, int index, long l) {
542 if ( is64Bit )
543 target.putLong(index * 8, l);
544 else
545 target.putInt(index * 4, (int)l);
546 }
547
548 // -- Bulk get operations --
549
550 /**
551 * Relative bulk <i>get</i> method.
552 * <p/>
553 * <p> This method transfers longs from this buffer into the given
554 * destination array. If there are fewer longs remaining in the
555 * buffer than are required to satisfy the request, that is, if
556 * <tt>length</tt>&nbsp;<tt>&gt;</tt>&nbsp;<tt>remaining()</tt>, then no
557 * longs are transferred and a {@link BufferUnderflowException} is
558 * thrown.
559 * <p/>
560 * <p> Otherwise, this method copies <tt>length</tt> longs from this
561 * buffer into the given array, starting at the current position of this
562 * buffer and at the given offset in the array. The position of this
563 * buffer is then incremented by <tt>length</tt>.
564 * <p/>
565 * <p> In other words, an invocation of this method of the form
566 * <tt>src.get(dst,&nbsp;off,&nbsp;len)</tt> has exactly the same effect as
567 * the loop
568 * <p/>
569 * <pre>
570 * for (int i = off; i < off + len; i++)
571 * dst[i] = src.get(); </pre>
572 * <p/>
573 * except that it first checks that there are sufficient longs in
574 * this buffer and it is potentially much more efficient. </p>
575 *
576 * @param dst The array into which longs are to be written
577 * @param offset The offset within the array of the first long to be
578 * written; must be non-negative and no larger than
579 * <tt>dst.length</tt>
580 * @param length The maximum number of longs to be written to the given
581 * array; must be non-negative and no larger than
582 * <tt>dst.length - offset</tt>
583 *
584 * @return This buffer
585 *
586 * @throws BufferUnderflowException If there are fewer than <tt>length</tt> longs
587 * remaining in this buffer
588 * @throws IndexOutOfBoundsException If the preconditions on the <tt>offset</tt> and <tt>length</tt>
589 * parameters do not hold
590 */
591 public PointerBuffer get(long[] dst, int offset, int length) {
592 if ( is64Bit )
593 view64.get(dst, offset, length);
594 else {
595 checkBounds(offset, length, dst.length);
596 if ( length > view32.remaining() )
597 throw new BufferUnderflowException();
598 int end = offset + length;
599 for ( int i = offset; i < end; i++ )
600 dst[i] = view32.get() & 0x00000000FFFFFFFFL;
601 }
602
603 return this;
604 }
605
606 /**
607 * Relative bulk <i>get</i> method.
608 * <p/>
609 * <p> This method transfers longs from this buffer into the given
610 * destination array. An invocation of this method of the form
611 * <tt>src.get(a)</tt> behaves in exactly the same way as the invocation
612 * <p/>
613 * <pre>
614 * src.get(a, 0, a.length) </pre>
615 *
616 * @return This buffer
617 *
618 * @throws BufferUnderflowException If there are fewer than <tt>length</tt> longs
619 * remaining in this buffer
620 */
621 public PointerBuffer get(long[] dst) {
622 return get(dst, 0, dst.length);
623 }
624
625 /**
626 * Relative bulk <i>put</i> method&nbsp;&nbsp;<i>(optional operation)</i>.
627 * <p/>
628 * <p> This method transfers the longs remaining in the given source
629 * buffer into this buffer. If there are more longs remaining in the
630 * source buffer than in this buffer, that is, if
631 * <tt>src.remaining()</tt>&nbsp;<tt>&gt;</tt>&nbsp;<tt>remaining()</tt>,
632 * then no longs are transferred and a {@link
633 * BufferOverflowException} is thrown.
634 * <p/>
635 * <p> Otherwise, this method copies
636 * <i>n</i>&nbsp;=&nbsp;<tt>src.remaining()</tt> longs from the given
637 * buffer into this buffer, starting at each buffer's current position.
638 * The positions of both buffers are then incremented by <i>n</i>.
639 * <p/>
640 * <p> In other words, an invocation of this method of the form
641 * <tt>dst.put(src)</tt> has exactly the same effect as the loop
642 * <p/>
643 * <pre>
644 * while (src.hasRemaining())
645 * dst.put(src.get()); </pre>
646 * <p/>
647 * except that it first checks that there is sufficient space in this
648 * buffer and it is potentially much more efficient. </p>
649 *
650 * @param src The source buffer from which longs are to be read;
651 * must not be this buffer
652 *
653 * @return This buffer
654 *
655 * @throws BufferOverflowException If there is insufficient space in this buffer
656 * for the remaining longs in the source buffer
657 * @throws IllegalArgumentException If the source buffer is this buffer
658 * @throws ReadOnlyBufferException If this buffer is read-only
659 */
660 public PointerBuffer put(PointerBuffer src) {
661 if ( is64Bit )
662 view64.put(src.view64);
663 else
664 view32.put(src.view32);
665 return this;
666 }
667
668 /**
669 * Relative bulk <i>put</i> method&nbsp;&nbsp;<i>(optional operation)</i>.
670 * <p/>
671 * <p> This method transfers longs into this buffer from the given
672 * source array. If there are more longs to be copied from the array
673 * than remain in this buffer, that is, if
674 * <tt>length</tt>&nbsp;<tt>&gt;</tt>&nbsp;<tt>remaining()</tt>, then no
675 * longs are transferred and a {@link BufferOverflowException} is
676 * thrown.
677 * <p/>
678 * <p> Otherwise, this method copies <tt>length</tt> longs from the
679 * given array into this buffer, starting at the given offset in the array
680 * and at the current position of this buffer. The position of this buffer
681 * is then incremented by <tt>length</tt>.
682 * <p/>
683 * <p> In other words, an invocation of this method of the form
684 * <tt>dst.put(src,&nbsp;off,&nbsp;len)</tt> has exactly the same effect as
685 * the loop
686 * <p/>
687 * <pre>
688 * for (int i = off; i < off + len; i++)
689 * dst.put(a[i]); </pre>
690 * <p/>
691 * except that it first checks that there is sufficient space in this
692 * buffer and it is potentially much more efficient. </p>
693 *
694 * @param src The array from which longs are to be read
695 * @param offset The offset within the array of the first long to be read;
696 * must be non-negative and no larger than <tt>array.length</tt>
697 * @param length The number of longs to be read from the given array;
698 * must be non-negative and no larger than
699 * <tt>array.length - offset</tt>
700 *
701 * @return This buffer
702 *
703 * @throws BufferOverflowException If there is insufficient space in this buffer
704 * @throws IndexOutOfBoundsException If the preconditions on the <tt>offset</tt> and <tt>length</tt>
705 * parameters do not hold
706 * @throws ReadOnlyBufferException If this buffer is read-only
707 */
708 public PointerBuffer put(long[] src, int offset, int length) {
709 if ( is64Bit )
710 view64.put(src, offset, length);
711 else {
712 checkBounds(offset, length, src.length);
713 if ( length > view32.remaining() )
714 throw new BufferOverflowException();
715 int end = offset + length;
716 for ( int i = offset; i < end; i++ )
717 view32.put((int)src[i]);
718 }
719
720 return this;
721 }
722
723 /**
724 * Relative bulk <i>put</i> method&nbsp;&nbsp;<i>(optional operation)</i>.
725 * <p/>
726 * <p> This method transfers the entire content of the given source
727 * long array into this buffer. An invocation of this method of the
728 * form <tt>dst.put(a)</tt> behaves in exactly the same way as the
729 * invocation
730 * <p/>
731 * <pre>
732 * dst.put(a, 0, a.length) </pre>
733 *
734 * @return This buffer
735 *
736 * @throws BufferOverflowException If there is insufficient space in this buffer
737 * @throws ReadOnlyBufferException If this buffer is read-only
738 */
739 public final PointerBuffer put(long[] src) {
740 return put(src, 0, src.length);
741 }
742
743 /**
744 * Compacts this buffer&nbsp;&nbsp;<i>(optional operation)</i>.
745 * <p/>
746 * <p> The longs between the buffer's current position and its limit,
747 * if any, are copied to the beginning of the buffer. That is, the
748 * long at index <i>p</i>&nbsp;=&nbsp;<tt>position()</tt> is copied
749 * to index zero, the long at index <i>p</i>&nbsp;+&nbsp;1 is copied
750 * to index one, and so forth until the long at index
751 * <tt>limit()</tt>&nbsp;-&nbsp;1 is copied to index
752 * <i>n</i>&nbsp;=&nbsp;<tt>limit()</tt>&nbsp;-&nbsp;<tt>1</tt>&nbsp;-&nbsp;<i>p</i>.
753 * The buffer's position is then set to <i>n+1</i> and its limit is set to
754 * its capacity. The mark, if defined, is discarded.
755 * <p/>
756 * <p> The buffer's position is set to the number of longs copied,
757 * rather than to zero, so that an invocation of this method can be
758 * followed immediately by an invocation of another relative <i>put</i>
759 * method. </p>
760 *
761 * @return This buffer
762 *
763 * @throws ReadOnlyBufferException If this buffer is read-only
764 */
765 public PointerBuffer compact() {
766 if ( is64Bit )
767 view64.compact();
768 else
769 view32.compact();
770 return this;
771 }
772
773 /**
774 * Retrieves this buffer's byte order.
775 * <p/>
776 * <p> The byte order of a pointer buffer created by allocation or by
777 * wrapping an existing <tt>long</tt> array is the {@link
778 * ByteOrder#nativeOrder </code>native order<code>} of the underlying
779 * hardware. The byte order of a pointer buffer created as a <a
780 * href="ByteBuffer.html#views">view</a> of a byte buffer is that of the
781 * byte buffer at the moment that the view is created. </p>
782 *
783 * @return This buffer's byte order
784 */
785 public ByteOrder order() {
786 if ( is64Bit )
787 return view64.order();
788 else
789 return view32.order();
790 }
791
792 /**
793 * Returns a string summarizing the state of this buffer. </p>
794 *
795 * @return A summary string
796 */
797 public String toString() {
798 StringBuilder sb = new StringBuilder(48);
799 sb.append(getClass().getName());
800 sb.append("[pos=");
801 sb.append(position());
802 sb.append(" lim=");
803 sb.append(limit());
804 sb.append(" cap=");
805 sb.append(capacity());
806 sb.append("]");
807 return sb.toString();
808 }
809
810 /**
811 * Returns the current hash code of this buffer.
812 * <p/>
813 * <p> The hash code of a pointer buffer depends only upon its remaining
814 * elements; that is, upon the elements from <tt>position()</tt> up to, and
815 * including, the element at <tt>limit()</tt>&nbsp;-&nbsp;<tt>1</tt>.
816 * <p/>
817 * <p> Because buffer hash codes are content-dependent, it is inadvisable
818 * to use buffers as keys in hash maps or similar data structures unless it
819 * is known that their contents will not change. </p>
820 *
821 * @return The current hash code of this buffer
822 */
823 public int hashCode() {
824 int h = 1;
825 int p = position();
826 for ( int i = limit() - 1; i >= p; i-- )
827 h = 31 * h + (int)get(i);
828 return h;
829 }
830
831 /**
832 * Tells whether or not this buffer is equal to another object.
833 * <p/>
834 * <p> Two pointer buffers are equal if, and only if,
835 * <p/>
836 * <p><ol>
837 * <p/>
838 * <li><p> They have the same element type, </p></li>
839 * <p/>
840 * <li><p> They have the same number of remaining elements, and
841 * </p></li>
842 * <p/>
843 * <li><p> The two sequences of remaining elements, considered
844 * independently of their starting positions, are pointwise equal.
845 * </p></li>
846 * <p/>
847 * </ol>
848 * <p/>
849 * <p> A pointer buffer is not equal to any other type of object. </p>
850 *
851 * @param ob The object to which this buffer is to be compared
852 *
853 * @return <tt>true</tt> if, and only if, this buffer is equal to the
854 * given object
855 */
856 public boolean equals(Object ob) {
857 if ( !(ob instanceof PointerBuffer) )
858 return false;
859 PointerBuffer that = (PointerBuffer)ob;
860 if ( this.remaining() != that.remaining() )
861 return false;
862 int p = this.position();
863 for ( int i = this.limit() - 1, j = that.limit() - 1; i >= p; i--, j-- ) {
864 long v1 = this.get(i);
865 long v2 = that.get(j);
866 if ( v1 != v2 ) {
867 return false;
868 }
869 }
870 return true;
871 }
872
873 /**
874 * Compares this buffer to another.
875 * <p/>
876 * <p> Two pointer buffers are compared by comparing their sequences of
877 * remaining elements lexicographically, without regard to the starting
878 * position of each sequence within its corresponding buffer.
879 * <p/>
880 * <p> A pointer buffer is not comparable to any other type of object.
881 *
882 * @return A negative integer, zero, or a positive integer as this buffer
883 * is less than, equal to, or greater than the given buffer
884 */
885 public int compareTo(Object o) {
886 final PointerBuffer that = (PointerBuffer)o;
887 int n = this.position() + Math.min(this.remaining(), that.remaining());
888 for ( int i = this.position(), j = that.position(); i < n; i++, j++ ) {
889 long v1 = this.get(i);
890 long v2 = that.get(j);
891 if ( v1 == v2 )
892 continue;
893 if ( v1 < v2 )
894 return -1;
895 return +1;
896 }
897 return this.remaining() - that.remaining();
898 }
899
900 private static void checkBounds(int off, int len, int size) {
901 if ( (off | len | (off + len) | (size - (off + len))) < 0 )
902 throw new IndexOutOfBoundsException();
903 }
904
905 /**
906 * Read-only version of PointerBuffer.
907 *
908 * @author Spasi
909 */
910 private static final class PointerBufferR extends PointerBuffer {
911
912 PointerBufferR(final ByteBuffer source) {
913 super(source);
914 }
915
916 public boolean isReadOnly() {
917 return true;
918 }
919
920 protected PointerBuffer newInstance(final ByteBuffer source) {
921 return new PointerBufferR(source);
922 }
923
924 public PointerBuffer asReadOnlyBuffer() {
925 return duplicate();
926 }
927
928 public PointerBuffer put(final long l) {
929 throw new ReadOnlyBufferException();
930 }
931
932 public PointerBuffer put(final int index, final long l) {
933 throw new ReadOnlyBufferException();
934 }
935
936 public PointerBuffer put(final PointerBuffer src) {
937 throw new ReadOnlyBufferException();
938 }
939
940 public PointerBuffer put(final long[] src, final int offset, final int length) {
941 throw new ReadOnlyBufferException();
942 }
943
944 public PointerBuffer compact() {
945 throw new ReadOnlyBufferException();
946 }
947
948 }
949
950 }
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;
32
33 /**
34 * A common interface for classes that wrap pointer addresses.
35 *
36 * @author Spasi
37 */
38 public interface PointerWrapper {
39
40 long getPointer();
41
42 }
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;
32
33 /**
34 * Base PointerWrapper implementation.
35 *
36 * @author Spasi
37 */
38 public abstract class PointerWrapperAbstract implements PointerWrapper {
39
40 protected final long pointer;
41
42 protected PointerWrapperAbstract(final long pointer) {
43 this.pointer = pointer;
44 }
45
46 /**
47 * Returns true if this object represents a valid pointer.
48 * The pointer might be invalid because it is NULL or because
49 * some other action has deleted the object that this pointer
50 * represents.
51 *
52 * @return true if the pointer is valid
53 */
54 public boolean isValid() {
55 return pointer != 0;
56 }
57
58 /**
59 * Checks if the pointer is valid and throws an IllegalStateException if
60 * it is not. This method is a NO-OP, unless the org.lwjgl.util.Debug
61 * property has been set to true.
62 */
63 public final void checkValid() {
64 if ( LWJGLUtil.DEBUG && !isValid() )
65 throw new IllegalStateException("This " + getClass().getSimpleName() + " pointer is not valid.");
66 }
67
68 public final long getPointer() {
69 checkValid();
70 return pointer;
71 }
72
73 public boolean equals(final Object o) {
74 if ( this == o ) return true;
75 if ( !(o instanceof PointerWrapperAbstract) ) return false;
76
77 final PointerWrapperAbstract that = (PointerWrapperAbstract)o;
78
79 if ( pointer != that.pointer ) return false;
80
81 return true;
82 }
83
84 public int hashCode() {
85 return (int)(pointer ^ (pointer >>> 32));
86 }
87
88 public String toString() {
89 return getClass().getSimpleName() + " pointer (0x" + Long.toHexString(pointer).toUpperCase() + ")";
90 }
91 }
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: 3353 $
49 * $Id: Sys.java 3353 2010-05-24 22:39:06Z matzon $
48 * @version $Revision: 3488 $
49 * $Id: Sys.java 3488 2011-02-09 21:09:33Z 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.5";
56 private static final String VERSION = "2.7.1";
57
58 private static final String POSTFIX64BIT = "64";
5759
5860 /** The implementation instance to delegate platform specific behavior to */
59 private final static SysImplementation implementation;
60
61 private final static String POSTFIX64BIT = "64";
62
61 private static final SysImplementation implementation;
62 private static final boolean is64Bit;
63
6364 private static void doLoadLibrary(final String lib_name) {
64 AccessController.doPrivileged(new PrivilegedAction() {
65 AccessController.doPrivileged(new PrivilegedAction<Object>() {
6566 public Object run() {
6667 String library_path = System.getProperty("org.lwjgl.librarypath");
6768 if (library_path != null) {
68 System.load(library_path + File.separator +
69 System.load(library_path + File.separator +
6970 System.mapLibraryName(lib_name));
7071 } else {
7172 System.loadLibrary(lib_name);
9091 // Throw original error
9192 throw e;
9293 }
93 }
94 }
9495
9596 static {
9697 implementation = createImplementation();
9798 loadLibrary(JNI_LIBRARY_NAME);
98
99 is64Bit = implementation.getPointerSize() == 8;
100
99101 int native_jni_version = implementation.getJNIVersion();
100102 int required_version = implementation.getRequiredJNIVersion();
101103 if (native_jni_version != required_version)
102104 throw new LinkageError("Version mismatch: jar version is '" + required_version +
103 "', native libary version is '" + native_jni_version + "'");
105 "', native library version is '" + native_jni_version + "'");
104106 implementation.setDebug(LWJGLUtil.DEBUG);
105107 }
106108
129131 public static String getVersion() {
130132 return VERSION;
131133 }
132
134
133135 /**
134136 * Initialization. This is just a dummy method to trigger the static constructor.
135137 */
136138 public static void initialize() {
139 }
140
141 /** Returns true if a 64bit implementation was loaded. */
142 public static boolean is64Bit() {
143 return is64Bit;
137144 }
138145
139146 /**
207214 // Attempt to use Webstart if we have it available
208215 try {
209216 // Lookup the javax.jnlp.BasicService object
210 final Class serviceManagerClass = Class.forName("javax.jnlp.ServiceManager");
211 Method lookupMethod = (Method)AccessController.doPrivileged(new PrivilegedExceptionAction() {
212 public Object run() throws Exception {
213 return serviceManagerClass.getMethod("lookup", new Class[] {String.class});
217 final Class<?> serviceManagerClass = Class.forName("javax.jnlp.ServiceManager");
218 Method lookupMethod = AccessController.doPrivileged(new PrivilegedExceptionAction<Method>() {
219 public Method run() throws Exception {
220 return serviceManagerClass.getMethod("lookup", String.class);
214221 }
215222 });
216223 Object basicService = lookupMethod.invoke(serviceManagerClass, new Object[] {"javax.jnlp.BasicService"});
217 final Class basicServiceClass = Class.forName("javax.jnlp.BasicService");
218 Method showDocumentMethod = (Method)AccessController.doPrivileged(new PrivilegedExceptionAction() {
219 public Object run() throws Exception {
220 return basicServiceClass.getMethod("showDocument", new Class[] {URL.class});
224 final Class<?> basicServiceClass = Class.forName("javax.jnlp.BasicService");
225 Method showDocumentMethod = AccessController.doPrivileged(new PrivilegedExceptionAction<Method>() {
226 public Method run() throws Exception {
227 return basicServiceClass.getMethod("showDocument", URL.class);
221228 }
222229 });
223230 try {
224 Boolean ret = (Boolean) showDocumentMethod.invoke(basicService, new Object[] {new URL(url)});
225 return ret.booleanValue();
231 Boolean ret = (Boolean)showDocumentMethod.invoke(basicService, new URL(url));
232 return ret;
226233 } catch (MalformedURLException e) {
227234 e.printStackTrace(System.err);
228235 return false;
3636 *
3737 * @author cix_foo <cix_foo@users.sourceforge.net>
3838 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 3054 $
40 * $Id: SysImplementation.java 3054 2008-04-30 14:34:54Z elias_naur $
39 * @version $Revision: 3426 $
40 * $Id: SysImplementation.java 3426 2010-10-01 22:20:14Z spasi $
4141 */
4242 interface SysImplementation {
4343 /**
4949 * Return the version of the native library
5050 */
5151 int getJNIVersion();
52
53 /**
54 * Returns the platform's pointer size in bytes
55 */
56 int getPointerSize();
5257
5358 void setDebug(boolean debug);
5459
4040 /**
4141 * <p>
4242 * @author $Author: spasi $
43 * @version $Revision: 3300 $
44 * $Id: WindowsSysImplementation.java 3300 2010-03-31 20:56:07Z spasi $
43 * @version $Revision: 3418 $
44 * $Id: WindowsSysImplementation.java 3418 2010-09-28 21:11:35Z spasi $
4545 */
4646 final class WindowsSysImplementation extends DefaultSysImplementation {
47 private final static int JNI_VERSION = 22;
47 private static final int JNI_VERSION = 23;
4848
4949 static {
5050 Sys.initialize();
5151 }
52
52
5353 public int getRequiredJNIVersion() {
5454 return JNI_VERSION;
5555 }
6363 }
6464 private static native long nGetTime();
6565
66 public final boolean has64Bit() {
66 public boolean has64Bit() {
6767 return true;
6868 }
6969
7474 * public
7575 */
7676 try {
77 Long hwnd_obj = (Long)AccessController.doPrivileged(new PrivilegedExceptionAction() {
78 public Object run() throws Exception {
79 Method getImplementation_method = Display.class.getDeclaredMethod("getImplementation", null);
77 return AccessController.doPrivileged(new PrivilegedExceptionAction<Long>() {
78 public Long run() throws Exception {
79 Method getImplementation_method = Display.class.getDeclaredMethod("getImplementation");
8080 getImplementation_method.setAccessible(true);
81 Object display_impl = getImplementation_method.invoke(null, null);
82 Class WindowsDisplay_class = Class.forName("org.lwjgl.opengl.WindowsDisplay");
83 Method getHwnd_method = WindowsDisplay_class.getDeclaredMethod("getHwnd", null);
81 Object display_impl = getImplementation_method.invoke(null);
82 Class<?> WindowsDisplay_class = Class.forName("org.lwjgl.opengl.WindowsDisplay");
83 Method getHwnd_method = WindowsDisplay_class.getDeclaredMethod("getHwnd");
8484 getHwnd_method.setAccessible(true);
85 Long hwnd = (Long)getHwnd_method.invoke(display_impl, null);
86 return hwnd;
85 return (Long)getHwnd_method.invoke(display_impl);
8786 }
8887 });
89 return hwnd_obj.longValue();
9088 } catch (PrivilegedActionException e) {
9189 throw new Error(e);
9290 }
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 */
3434 import org.lwjgl.input.Keyboard;
3535 import org.lwjgl.openal.AL;
3636 import org.lwjgl.opengl.Display;
37 import org.lwjgl.opengl.GL11;
37
38 import static org.lwjgl.opengl.GL11.*;
3839
3940 /**
4041 *
4142 * This is a <em>very basic</em> skeleton to init a game and run it.
4243 *
43 * @author $Author: matzon $
44 * @version $Revision: 3108 $
45 * $Id: Game.java 3108 2008-07-02 20:00:49Z matzon $
44 * @author $Author: spasi $
45 * @version $Revision: 3418 $
46 * $Id: Game.java 3418 2010-09-28 21:11:35Z spasi $
4647 */
4748 public class Game {
48
49
4950 /** Game title */
5051 public static final String GAME_TITLE = "My Game";
51
52
5253 /** Desired frame time */
5354 private static final int FRAMERATE = 60;
54
55
5556 /** Exit the game */
5657 private static boolean finished;
57
58
5859 /** A rotating square! */
5960 private static float angle;
60
61
6162 /**
6263 * No constructor needed - this class is static
6364 */
6465 private Game() {}
65
66
6667 /**
6768 * Application init
6869 * @param args Commandline args
7778 } finally {
7879 cleanup();
7980 }
80
81
8182 System.exit(0);
8283 }
83
84
8485 /**
8586 * Initialise the game
8687 * @throws Exception if init fails
9394
9495 // Enable vsync if we can
9596 Display.setVSyncEnabled(true);
96
97
9798 Display.create();
98
99
99100 // Start up the sound system
100101 AL.create();
101
102
102103 // TODO: Load in your textures etc here
103
104
104105 // Put the window into orthographic projection mode with 1:1 pixel ratio.
105106 // We haven't used GLU here to do this to avoid an unnecessary dependency.
106 GL11.glMatrixMode(GL11.GL_PROJECTION);
107 GL11.glLoadIdentity();
108 GL11.glOrtho(0.0, Display.getDisplayMode().getWidth(), 0.0, Display.getDisplayMode().getHeight(), -1.0, 1.0);
109 GL11.glMatrixMode(GL11.GL_MODELVIEW);
110 GL11.glLoadIdentity();
111 GL11.glViewport(0, 0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight());
112
107 glMatrixMode(GL_PROJECTION);
108 glLoadIdentity();
109 glOrtho(0.0, Display.getDisplayMode().getWidth(), 0.0, Display.getDisplayMode().getHeight(), -1.0, 1.0);
110 glMatrixMode(GL_MODELVIEW);
111 glLoadIdentity();
112 glViewport(0, 0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight());
113
113114 }
114
115
115116 /**
116117 * Runs the game (the "main loop")
117118 */
119120 while (!finished) {
120121 // Always call Window.update(), all the time
121122 Display.update();
122
123
123124 if (Display.isCloseRequested()) {
124125 // Check for O/S close requests
125126 finished = true;
143144 }
144145 }
145146 }
146
147
147148 /**
148149 * Do any game-specific cleanup
149150 */
152153
153154 // Stop the sound
154155 AL.destroy();
155
156
156157 // Close the window
157158 Display.destroy();
158159 }
159
160
160161 /**
161162 * Do all calculations, handle input, etc.
162163 */
169170 // TODO: all your game logic goes here.
170171 angle += 2.0f % 360;
171172 }
172
173
173174 /**
174175 * Render the current frame
175176 */
176177 private static void render() {
177 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT);
178 glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
178179
179180 // TODO: all your rendering goes here
180 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
181 GL11.glPushMatrix();
182 GL11.glTranslatef(Display.getDisplayMode().getWidth() / 2, Display.getDisplayMode().getHeight() / 2, 0.0f);
183 GL11.glRotatef(angle, 0, 0, 1.0f);
184 GL11.glBegin(GL11.GL_QUADS);
185 GL11.glVertex2i(-50, -50);
186 GL11.glVertex2i(50, -50);
187 GL11.glVertex2i(50, 50);
188 GL11.glVertex2i(-50, 50);
189 GL11.glEnd();
190 GL11.glPopMatrix();
181 glClear(GL_COLOR_BUFFER_BIT);
182 glPushMatrix();
183 glTranslatef(Display.getDisplayMode().getWidth() / 2, Display.getDisplayMode().getHeight() / 2, 0.0f);
184 glRotatef(angle, 0, 0, 1.0f);
185 glBegin(GL_QUADS);
186 glVertex2i(-50, -50);
187 glVertex2i(50, -50);
188 glVertex2i(50, 50);
189 glVertex2i(-50, 50);
190 glEnd();
191 glPopMatrix();
191192 }
192193 }
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 */
3636 * An entity represents any element that appears in the game. The
3737 * entity is responsible for resolving collisions and movement
3838 * based on a set of properties defined either by subclass or externally.
39 *
39 *
4040 * Note that doubles are used for positions. This may seem strange
4141 * given that pixels locations are integers. However, using double means
4242 * that an entity can move a partial pixel. It doesn't of course mean that
4343 * they will be display half way through a pixel but allows us not lose
4444 * accuracy as we move.
45 *
45 *
4646 * @author Kevin Glass
4747 */
4848 public abstract class Entity {
7070
7171 /**
7272 * Construct a entity based on a sprite image and a location.
73 *
74 * @param ref The reference to the image to be displayed for this entity
73 *
74 * @param sprite The reference to the image to be displayed for this entity
7575 * @param x The initial x location of this entity
7676 * @param y The initial y location of this entity
7777 */
78 public Entity(Sprite sprite, int x, int y) {
78 protected Entity(Sprite sprite, int x, int y) {
7979 this.sprite = sprite;
8080 this.x = x;
8181 this.y = y;
8484 /**
8585 * Request that this entity move itself based on a certain ammount
8686 * of time passing.
87 *
87 *
8888 * @param delta The ammount of time that has passed in milliseconds
8989 */
9090 public void move(long delta) {
9595
9696 /**
9797 * Set the horizontal speed of this entity
98 *
98 *
9999 * @param dx The horizontal speed of this entity (pixels/sec)
100100 */
101101 public void setHorizontalMovement(float dx) {
104104
105105 /**
106106 * Set the vertical speed of this entity
107 *
107 *
108108 * @param dy The vertical speed of this entity (pixels/sec)
109109 */
110110 public void setVerticalMovement(float dy) {
113113
114114 /**
115115 * Get the horizontal speed of this entity
116 *
116 *
117117 * @return The horizontal speed of this entity (pixels/sec)
118118 */
119119 public float getHorizontalMovement() {
122122
123123 /**
124124 * Get the vertical speed of this entity
125 *
125 *
126126 * @return The vertical speed of this entity (pixels/sec)
127127 */
128128 public float getVerticalMovement() {
145145
146146 /**
147147 * Get the x location of this entity
148 *
148 *
149149 * @return The x location of this entity
150150 */
151151 public int getX() {
154154
155155 /**
156156 * Get the y location of this entity
157 *
157 *
158158 * @return The y location of this entity
159159 */
160160 public int getY() {
163163
164164 /**
165165 * Check if this entity collised with another.
166 *
166 *
167167 * @param other The other entity to check collision against
168168 * @return True if the entities collide with each other
169169 */
176176
177177 /**
178178 * Notification that this entity collided with another.
179 *
179 *
180180 * @param other The entity with which this entity collided.
181181 */
182182 public abstract void collidedWith(Entity other);
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 */
3838 import org.lwjgl.input.Mouse;
3939 import org.lwjgl.opengl.Display;
4040 import org.lwjgl.opengl.DisplayMode;
41 import org.lwjgl.opengl.GL11;
41
42 import static org.lwjgl.opengl.GL11.*;
4243
4344 /**
4445 * The main hook of our game. This class with both act as a manager
45 * for the display and central mediator for the game logic.
46 *
46 * for the display and central mediator for the game logic.
47 *
4748 * Display management will consist of a loop that cycles round all
4849 * entities in the game asking them to move and then drawing them
4950 * in the appropriate place. With the help of an inner class it
5051 * will also allow the player to control the main ship.
51 *
52 *
5253 * As a mediator it will be informed when entities within our game
5354 * detect events (e.g. alient killed, played died) and will take
5455 * appropriate game actions.
55 *
56 *
5657 * <p>
5758 * NOTE:<br>
5859 * This game is a LWJGLized implementation of the Space Invaders game by Kevin
59 * Glass. The original implementation is renderer agnostic and supports other
60 * Glass. The original implementation is renderer agnostic and supports other
6061 * OpenGL implementations as well as Java2D. This version has been made specific
61 * for LWJGL, and has added input control as well as sound (which the original doesn't,
62 * for LWJGL, and has added input control as well as sound (which the original doesn't,
6263 * at the time of writing).
6364 * You can find the original article here:<br>
6465 * <a href="http://www.cokeandcode.com/" target="_blank">http://www.cokeandcode.com</a>
6566 * </p>
66 *
67 *
6768 * @author Kevin Glass
6869 * @author Brian Matzon
6970 */
8283 private TextureLoader textureLoader;
8384
8485 /** The list of all the entities that exist in our game */
85 private ArrayList entities = new ArrayList();
86 private ArrayList<Entity> entities = new ArrayList<Entity>();
8687
8788 /** The list of entities that need to be removed from the game this loop */
88 private ArrayList removeList = new ArrayList();
89 private ArrayList<Entity> removeList = new ArrayList<Entity>();
8990
9091 /** The entity representing the player */
9192 private ShipEntity ship;
112113 private float moveSpeed = 300;
113114
114115 /** The time at which last fired a shot */
115 private long lastFire = 0;
116 private long lastFire;
116117
117118 /** The interval between our players shot (ms) */
118119 private long firingInterval = 500;
124125 private boolean waitingForKeyPress = true;
125126
126127 /** True if game logic needs to be applied this loop, normally as a result of a game event */
127 private boolean logicRequiredThisLoop = false;
128 private boolean logicRequiredThisLoop;
128129
129130 /** The time at which the last rendering looped started from the point of view of the game logic */
130131 private long lastLoopTime = getTime();
131132
132133 /** True if the fire key has been released */
133 private boolean fireHasBeenReleased = false;
134 private boolean fireHasBeenReleased;
134135
135136 /** The time since the last record of fps */
136 private long lastFpsTime = 0;
137 private long lastFpsTime;
137138
138139 /** The recorded fps */
139140 private int fps;
166167
167168 /** Mouse movement on x axis */
168169 private int mouseX;
169
170
170171 /** Is this an application or applet */
171 private static boolean isApplication = false;
172 private static boolean isApplication;
172173
173174 /**
174175 * Construct our game and set it running.
175176 * @param fullscreen
176 *
177 * @param renderingType The type of rendering to use (should be one of the contansts from ResourceFactory)
177 *
178178 */
179179 public Game(boolean fullscreen) {
180180 this.fullscreen = fullscreen;
183183
184184 /**
185185 * Get the high resolution time in milliseconds
186 *
186 *
187187 * @return The high resolution time in milliseconds
188188 */
189189 public static long getTime() {
195195 }
196196
197197 /**
198 * Sleep for a fixed number of milliseconds.
199 *
198 * Sleep for a fixed number of milliseconds.
199 *
200200 * @param duration The amount of time in milliseconds to sleep for
201201 */
202202 public static void sleep(long duration) {
216216 Display.setTitle(WINDOW_TITLE);
217217 Display.setFullscreen(fullscreen);
218218 Display.create();
219
219
220220 // grab the mouse, dont want that hideous cursor when we're playing!
221 if (isApplication) {
221 if (isApplication) {
222222 Mouse.setGrabbed(true);
223223 }
224224
225225 // enable textures since we're going to use these for our sprites
226 GL11.glEnable(GL11.GL_TEXTURE_2D);
226 glEnable(GL_TEXTURE_2D);
227227
228228 // disable the OpenGL depth test since we're rendering 2D graphics
229 GL11.glDisable(GL11.GL_DEPTH_TEST);
230
231 GL11.glMatrixMode(GL11.GL_PROJECTION);
232 GL11.glLoadIdentity();
233
234 GL11.glOrtho(0, width, height, 0, -1, 1);
235 GL11.glMatrixMode(GL11.GL_MODELVIEW);
236 GL11.glLoadIdentity();
237 GL11.glViewport(0, 0, width, height);
229 glDisable(GL_DEPTH_TEST);
230
231 glMatrixMode(GL_PROJECTION);
232 glLoadIdentity();
233
234 glOrtho(0, width, height, 0, -1, 1);
235 glMatrixMode(GL_MODELVIEW);
236 glLoadIdentity();
237 glViewport(0, 0, width, height);
238238
239239 textureLoader = new TextureLoader();
240240
288288 "height=" + height,
289289 "freq=" + 60,
290290 "bpp=" + org.lwjgl.opengl.Display.getDisplayMode().getBitsPerPixel()
291 });
291 });
292292 return true;
293293 } catch (Exception e) {
294294 e.printStackTrace();
340340 /**
341341 * Remove an entity from the game. The entity removed will
342342 * no longer move or be drawn.
343 *
343 *
344344 * @param entity The entity that should be removed
345345 */
346346 public void removeEntity(Entity entity) {
348348 }
349349
350350 /**
351 * Notification that the player has died.
351 * Notification that the player has died.
352352 */
353353 public void notifyDeath() {
354354 if (!waitingForKeyPress) {
381381
382382 // if there are still some aliens left then they all need to get faster, so
383383 // speed up all the existing aliens
384 for (int i = 0; i < entities.size(); i++) {
385 Entity entity = (Entity) entities.get(i);
386
387 if (entity instanceof AlienEntity) {
384 for ( Entity entity : entities ) {
385 if ( entity instanceof AlienEntity ) {
388386 // speed up by 2%
389387 entity.setHorizontalMovement(entity.getHorizontalMovement() * 1.02f);
390388 }
395393
396394 /**
397395 * Attempt to fire a shot from the player. Its called "try"
398 * since we must first check that the player can fire at this
396 * since we must first check that the player can fire at this
399397 * point, i.e. has he/she waited long enough between shots
400398 */
401399 public void tryToFire() {
420418 private void gameLoop() {
421419 while (Game.gameRunning) {
422420 // clear screen
423 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
424 GL11.glMatrixMode(GL11.GL_MODELVIEW);
425 GL11.glLoadIdentity();
421 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
422 glMatrixMode(GL_MODELVIEW);
423 glLoadIdentity();
426424
427425 // let subsystem paint
428426 frameRendering();
430428 // update window contents
431429 Display.update();
432430 }
433
431
434432 // clean up
435433 soundManager.destroy();
436434 Display.destroy();
461459
462460 // cycle round asking each entity to move itself
463461 if (!waitingForKeyPress && !soundManager.isPlayingSound()) {
464 for (int i = 0; i < entities.size(); i++) {
465 Entity entity = (Entity) entities.get(i);
462 for ( Entity entity : entities ) {
466463 entity.move(delta);
467464 }
468465 }
469466
470467 // cycle round drawing all the entities we have in the game
471 for (int i = 0; i < entities.size(); i++) {
472 Entity entity = (Entity) entities.get(i);
468 for ( Entity entity : entities ) {
473469 entity.draw();
474470 }
475471
476472 // brute force collisions, compare every entity against
477 // every other entity. If any of them collide notify
473 // every other entity. If any of them collide notify
478474 // both entities that the collision has occured
479475 for (int p = 0; p < entities.size(); p++) {
480476 for (int s = p + 1; s < entities.size(); s++) {
481 Entity me = (Entity) entities.get(p);
482 Entity him = (Entity) entities.get(s);
477 Entity me = entities.get(p);
478 Entity him = entities.get(s);
483479
484480 if (me.collidesWith(him)) {
485481 me.collidedWith(him);
496492 // be resolved, cycle round every entity requesting that
497493 // their personal logic should be considered.
498494 if (logicRequiredThisLoop) {
499 for (int i = 0; i < entities.size(); i++) {
500 Entity entity = (Entity) entities.get(i);
495 for ( Entity entity : entities ) {
501496 entity.doLogic();
502497 }
503498
504499 logicRequiredThisLoop = false;
505500 }
506501
507 // if we're waiting for an "any key" press then draw the
508 // current message
502 // if we're waiting for an "any key" press then draw the
503 // current message
509504 if (waitingForKeyPress) {
510505 message.draw(325, 250);
511506 }
512507
513 // resolve the movemfent of the ship. First assume the ship
508 // resolve the movemfent of the ship. First assume the ship
514509 // isn't moving. If either cursor key is pressed then
515510 // update the movement appropraitely
516511 ship.setHorizontalMovement(0);
556551 }
557552
558553 /**
559 * @param key_left
554 * @param direction
560555 * @return
561556 */
562557 private boolean hasInput(int direction) {
563558 switch(direction) {
564559 case Keyboard.KEY_LEFT:
565 return
560 return
566561 Keyboard.isKeyDown(Keyboard.KEY_LEFT) ||
567562 mouseX < 0;
568
563
569564 case Keyboard.KEY_RIGHT:
570 return
565 return
571566 Keyboard.isKeyDown(Keyboard.KEY_RIGHT) ||
572567 mouseX > 0;
573
568
574569 case Keyboard.KEY_SPACE:
575 return
570 return
576571 Keyboard.isKeyDown(Keyboard.KEY_SPACE) ||
577572 Mouse.isButtonDown(0);
578573 }
583578 * The entry point into the game. We'll simply create an
584579 * instance of class which will start the display and game
585580 * loop.
586 *
581 *
587582 * @param argv The arguments that are passed into our game
588583 */
589584 public static void main(String argv[]) {
590585 isApplication = true;
591586 System.out.println("Use -fullscreen for fullscreen mode");
592 new Game((argv.length > 0 && argv[0].equalsIgnoreCase("-fullscreen"))).execute();
587 new Game((argv.length > 0 && "-fullscreen".equalsIgnoreCase(argv[0]))).execute();
593588 System.exit(0);
594589 }
595590
596591 /**
597 *
592 *
598593 */
599594 public void execute() {
600595 gameLoop();
603598 /**
604599 * Create or get a sprite which displays the image that is pointed
605600 * to in the classpath by "ref"
606 *
601 *
607602 * @param ref A reference to the image to load
608603 * @return A sprite that can be drawn onto the current graphics context.
609604 */
77 import org.lwjgl.opengl.Display;
88
99 public class GameApplet extends Applet {
10
10
1111 /** The Canvas where the LWJGL Display is added */
1212 Canvas display_parent;
13
13
1414 /** Thread which runs the main game loop */
1515 Thread gameThread;
16
16
1717 /** The Game instance */
1818 Game game;
19
19
2020 /**
21 * Once the Canvas is created its add notify method will call this method to
21 * Once the Canvas is created its add notify method will call this method to
2222 * start the LWJGL Display and game loop in another thread.
2323 */
2424 public void startLWJGL() {
2525 gameThread = new Thread() {
2626 public void run() {
27
27
2828 try {
2929 Display.setParent(display_parent);
30
30
3131 } catch (LWJGLException e) {
3232 e.printStackTrace();
3333 }
3838 };
3939 gameThread.start();
4040 }
41
42
41
42
4343 /**
4444 * Tell game loop to stop running, after which the LWJGL Display will be destoryed.
4545 * The main thread will wait for the Display.destroy() to complete
5454 }
5555
5656 public void start() {
57
57
5858 }
5959
6060 public void stop() {
61
61
6262 }
63
63
6464 /**
65 * Applet Destroy method will remove the canvas, before canvas is destroyed it will notify
65 * Applet Destroy method will remove the canvas, before canvas is destroyed it will notify
6666 * stopLWJGL() to stop main game loop and to destroy the Display
6767 */
6868 public void destroy() {
7070 super.destroy();
7171 System.out.println("Clear up");
7272 }
73
73
7474 /**
7575 * initialise applet by adding a canvas to it, this canvas will start the LWJGL Display and game loop
76 * in another thread. It will also stop the game loop and destroy the display on canvas removal when
76 * in another thread. It will also stop the game loop and destroy the display on canvas removal when
7777 * applet is destroyed.
7878 */
7979 public void init() {
8080 setLayout(new BorderLayout());
8181 try {
8282 display_parent = new Canvas() {
83 public final void addNotify() {
83 public void addNotify() {
8484 super.addNotify();
8585 startLWJGL();
8686 }
87 public final void removeNotify() {
87 public void removeNotify() {
8888 stopLWJGL();
8989 super.removeNotify();
9090 }
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 */
3232
3333 /**
3434 * An entity representing a shot fired by the player's ship
35 *
35 *
3636 * @author Kevin Glass
3737 * @author Brian Matzon
3838 */
4848 private Game game;
4949
5050 /** True if this shot has been "used", i.e. its hit something */
51 private boolean used = false;
51 private boolean used;
5252
5353 /**
5454 * Create a new shot from the player
55 *
55 *
5656 * @param game The game in which the shot has been created
5757 * @param sprite The sprite representing this shot
5858 * @param x The initial x location of the shot
6767
6868 /**
6969 * Reinitializes this entity, for reuse
70 *
70 *
7171 * @param x new x coordinate
7272 * @param y new y coordinate
7373 */
7979
8080 /**
8181 * Request that this shot moved based on time elapsed
82 *
82 *
8383 * @param delta The time that has elapsed since last move
8484 */
8585 public void move(long delta) {
9595 /**
9696 * Notification that this shot has collided with another
9797 * entity
98 *
98 *
9999 * @param other The other entity with which we've collided
100100 */
101101 public void collidedWith(Entity other) {
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 */
4646 * whether it's playing.
4747 * </p>
4848 * @author Brian Matzon <brian@matzon.dk>
49 * @version $Revision: 2983 $
50 * $Id: SoundManager.java 2983 2008-04-07 18:36:09Z matzon $
49 * @version $Revision: 3418 $
50 * $Id: SoundManager.java 3418 2010-09-28 21:11:35Z spasi $
5151 */
5252 public class SoundManager {
5353
5454 /** We support at most 256 buffers*/
5555 private int[] buffers = new int[256];
56
56
5757 /** Number of sources is limited tby user (and hardware) */
5858 private int[] sources;
59
59
6060 /** Our internal scratch buffer */
6161 private IntBuffer scratchBuffer = BufferUtils.createIntBuffer(256);
62
62
6363 /** Whether we're running in no sound mode */
6464 private boolean soundOutput;
65
65
6666 /** Current index in our buffers */
6767 private int bufferIndex;
68
68
6969 /** Current index in our source list */
7070 private int sourceIndex;
71
71
7272 /**
7373 * Creates a new SoundManager
7474 */
7777
7878 /**
7979 * Plays a sound effect
80 * @param buffer Buffer index to play gotten from addSound
80 * @param buffer Buffer index to play gotten from addSound
8181 */
8282 public void playEffect(int buffer) {
8383 if(soundOutput) {
8484 // make sure we never choose last channel, since it is used for special sounds
8585 int channel = sources[(sourceIndex++ % (sources.length-1))];
86
86
8787 // link buffer and source, and play it
8888 AL10.alSourcei(channel, AL10.AL_BUFFER, buffers[buffer]);
8989 AL10.alSourcePlay(channel);
100100 AL10.alSourcePlay(sources[sources.length-1]);
101101 }
102102 }
103
103
104104 /**
105105 * Whether a sound is playing on last source
106106 * @return true if a source is playing right now on source n
108108 public boolean isPlayingSound() {
109109 return AL10.alGetSourcei(sources[sources.length-1], AL10.AL_SOURCE_STATE) == AL10.AL_PLAYING;
110110 }
111
111
112112 /**
113113 * Initializes the SoundManager
114 *
115 * @param sources Number of sources to create
114 *
115 * @param channels Number of channels to create
116116 */
117117 public void initialize(int channels) {
118118 try {
119119 AL.create();
120
120
121121 // allocate sources
122122 scratchBuffer.limit(channels);
123123 AL10.alGenSources(scratchBuffer);
124124 scratchBuffer.rewind();
125125 scratchBuffer.get(sources = new int[channels]);
126
126
127127 // could we allocate all channels?
128128 if(AL10.alGetError() != AL10.AL_NO_ERROR) {
129129 throw new LWJGLException("Unable to allocate " + channels + " sources");
130130 }
131
131
132132 // we have sound
133133 soundOutput = true;
134134 } catch (LWJGLException le) {
136136 System.out.println("Sound disabled");
137137 }
138138 }
139
139
140140 /**
141141 * Adds a sound to the Sound Managers pool
142 *
142 *
143143 * @param path Path to file to load
144144 * @return index into SoundManagers buffer list
145145 */
148148 scratchBuffer.rewind().position(0).limit(1);
149149 AL10.alGenBuffers(scratchBuffer);
150150 buffers[bufferIndex] = scratchBuffer.get(0);
151
151
152152 // load wave data from buffer
153153 WaveData wavefile = WaveData.create("spaceinvaders/" + path);
154154
155155 // copy to buffers
156156 AL10.alBufferData(buffers[bufferIndex], wavefile.format, wavefile.data, wavefile.samplerate);
157
157
158158 // unload file again
159 wavefile.dispose();
160
159 wavefile.dispose();
160
161161 // return index for this sound
162162 return bufferIndex++;
163163 }
164
164
165165 /**
166166 * Destroy this SoundManager
167167 */
168168 public void destroy() {
169169 if(soundOutput) {
170
170
171171 // stop playing sounds
172172 scratchBuffer.position(0).limit(sources.length);
173173 scratchBuffer.put(sources).flip();
175175
176176 // destroy sources
177177 AL10.alDeleteSources(scratchBuffer);
178
178
179179 // destroy buffers
180180 scratchBuffer.position(0).limit(bufferIndex);
181181 scratchBuffer.put(buffers, 0, bufferIndex).flip();
182182 AL10.alDeleteBuffers(scratchBuffer);
183
183
184184 // destory OpenAL
185185 AL.destroy();
186186 }
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 */
3232
3333 import java.io.IOException;
3434
35 import org.lwjgl.opengl.GL11;
35 import static org.lwjgl.opengl.GL11.*;
3636
3737 /**
3838 * Implementation of sprite that uses an OpenGL quad and a texture
3939 * to render a given image to the screen.
40 *
40 *
4141 * @author Kevin Glass
4242 * @author Brian Matzon
4343 */
5454
5555 /**
5656 * Create a new sprite from a specified image.
57 *
58 * @param window The window in which the sprite will be displayed
57 *
58 * @param loader the texture loader to use
5959 * @param ref A reference to the image on which this sprite should be based
6060 */
6161 public Sprite(TextureLoader loader, String ref) {
7171
7272 /**
7373 * Get the width of this sprite in pixels
74 *
74 *
7575 * @return The width of this sprite in pixels
7676 */
7777 public int getWidth() {
8080
8181 /**
8282 * Get the height of this sprite in pixels
83 *
83 *
8484 * @return The height of this sprite in pixels
8585 */
8686 public int getHeight() {
8989
9090 /**
9191 * Draw the sprite at the specified location
92 *
92 *
9393 * @param x The x location at which to draw this sprite
9494 * @param y The y location at which to draw this sprite
9595 */
9696 public void draw(int x, int y) {
9797 // store the current model matrix
98 GL11.glPushMatrix();
98 glPushMatrix();
9999
100100 // bind to the appropriate texture for this sprite
101101 texture.bind();
102102
103103 // translate to the right location and prepare to draw
104 GL11.glTranslatef(x, y, 0);
104 glTranslatef(x, y, 0);
105105
106106 // draw a quad textured to match the sprite
107 GL11.glBegin(GL11.GL_QUADS);
107 glBegin(GL_QUADS);
108108 {
109 GL11.glTexCoord2f(0, 0);
110 GL11.glVertex2f(0, 0);
109 glTexCoord2f(0, 0);
110 glVertex2f(0, 0);
111111
112 GL11.glTexCoord2f(0, texture.getHeight());
113 GL11.glVertex2f(0, height);
112 glTexCoord2f(0, texture.getHeight());
113 glVertex2f(0, height);
114114
115 GL11.glTexCoord2f(texture.getWidth(), texture.getHeight());
116 GL11.glVertex2f(width, height);
115 glTexCoord2f(texture.getWidth(), texture.getHeight());
116 glVertex2f(width, height);
117117
118 GL11.glTexCoord2f(texture.getWidth(), 0);
119 GL11.glVertex2f(width, 0);
118 glTexCoord2f(texture.getWidth(), 0);
119 glVertex2f(width, 0);
120120 }
121 GL11.glEnd();
121 glEnd();
122122
123123 // restore the model view matrix to prevent contamination
124 GL11.glPopMatrix();
124 glPopMatrix();
125125 }
126126 }
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 package org.lwjgl.examples.spaceinvaders;
3232
33 import org.lwjgl.opengl.GL11;
33 import static org.lwjgl.opengl.GL11.*;
3434
3535 /**
36 * A texture to be bound within OpenGL. This object is responsible for
36 * A texture to be bound within OpenGL. This object is responsible for
3737 * keeping track of a given OpenGL texture and for calculating the
3838 * texturing mapping coordinates of the full image.
39 *
39 *
4040 * Since textures need to be powers of 2 the actual texture may be
4141 * considerably bigged that the source image and hence the texture
4242 * mapping coordinates need to be adjusted to matchup drawing the
7474 /**
7575 * Create a new texture
7676 *
77 * @param target The GL target
77 * @param target The GL target
7878 * @param textureID The GL texture ID
7979 */
8080 public Texture(int target, int textureID) {
8484
8585 /**
8686 * Bind the specified GL context to a texture
87 *
88 * @param gl The GL context to bind to
8987 */
9088 public void bind() {
91 GL11.glBindTexture(target, textureID);
89 glBindTexture(target, textureID);
9290 }
9391
9492 /**
120118 return height;
121119 }
122120
123 /**
121 /**
124122 * Get the width of the original image
125123 *
126124 * @return The width of the original image
148146 }
149147
150148 /**
151 * Set the height of this texture
149 * Set the height of this texture
152150 *
153151 * @param texHeight The height of the texture
154152 */
158156 }
159157
160158 /**
161 * Set the width of this texture
159 * Set the width of this texture
162160 *
163161 * @param texWidth The width of the texture
164162 */
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 */
3232
3333 import java.awt.Color;
3434 import java.awt.Graphics;
35 import java.awt.Image;
3536 import java.awt.color.ColorSpace;
3637 import java.awt.image.BufferedImage;
3738 import java.awt.image.ColorModel;
4041 import java.awt.image.DataBufferByte;
4142 import java.awt.image.Raster;
4243 import java.awt.image.WritableRaster;
43 import java.io.BufferedInputStream;
4444 import java.io.IOException;
4545 import java.net.URL;
4646 import java.nio.ByteBuffer;
4949 import java.util.HashMap;
5050 import java.util.Hashtable;
5151
52 import javax.imageio.ImageIO;
52 import javax.swing.ImageIcon;
5353
5454 import org.lwjgl.BufferUtils;
55 import org.lwjgl.opengl.GL11;
55
56 import static org.lwjgl.opengl.GL11.*;
5657
5758 /**
5859 * A utility class to load textures for OpenGL. This source is based
5960 * on a texture that can be found in the Java Gaming (www.javagaming.org)
6061 * Wiki. It has been simplified slightly for explicit 2D graphics use.
61 *
62 * OpenGL uses a particular image format. Since the images that are
62 *
63 * OpenGL uses a particular image format. Since the images that are
6364 * loaded from disk may not match this format this loader introduces
6465 * a intermediate image which the source image is copied into. In turn,
6566 * this image is used as source for the OpenGL texture.
6970 */
7071 public class TextureLoader {
7172 /** The table of textures that have been loaded in this loader */
72 private HashMap table = new HashMap();
73 private HashMap<String, Texture> table = new HashMap<String, Texture>();
7374
7475 /** The colour model including alpha for the GL image */
7576 private ColorModel glAlphaColorModel;
76
77
7778 /** The colour model for the GL image */
7879 private ColorModel glColorModel;
79
80
8081 /** Scratch buffer for texture ID's */
81 private IntBuffer textureIDBuffer = BufferUtils.createIntBuffer(1);
82
83 /**
82 private IntBuffer textureIDBuffer = BufferUtils.createIntBuffer(1);
83
84 /**
8485 * Create a new texture loader based on the game panel
85 *
86 * @param gl The GL content in which the textures should be loaded
8786 */
8887 public TextureLoader() {
8988 glAlphaColorModel = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
9291 false,
9392 ComponentColorModel.TRANSLUCENT,
9493 DataBuffer.TYPE_BYTE);
95
94
9695 glColorModel = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
9796 new int[] {8,8,8,0},
9897 false,
10099 ComponentColorModel.OPAQUE,
101100 DataBuffer.TYPE_BYTE);
102101 }
103
104 /**
105 * Create a new texture ID
102
103 /**
104 * Create a new texture ID
106105 *
107106 * @return A new texture ID
108107 */
109108 private int createTextureID() {
110 GL11.glGenTextures(textureIDBuffer);
109 glGenTextures(textureIDBuffer);
111110 return textureIDBuffer.get(0);
112 }
113
111 }
112
114113 /**
115114 * Load a texture
116115 *
119118 * @throws IOException Indicates a failure to access the resource
120119 */
121120 public Texture getTexture(String resourceName) throws IOException {
122 Texture tex = (Texture) table.get(resourceName);
123
121 Texture tex = table.get(resourceName);
122
124123 if (tex != null) {
125124 return tex;
126125 }
127
126
128127 tex = getTexture(resourceName,
129 GL11.GL_TEXTURE_2D, // target
130 GL11.GL_RGBA, // dst pixel format
131 GL11.GL_LINEAR, // min filter (unused)
132 GL11.GL_LINEAR);
133
128 GL_TEXTURE_2D, // target
129 GL_RGBA, // dst pixel format
130 GL_LINEAR, // min filter (unused)
131 GL_LINEAR);
132
134133 table.put(resourceName,tex);
135
134
136135 return tex;
137136 }
138
137
139138 /**
140139 * Load a texture into OpenGL from a image reference on
141140 * disk.
148147 * @return The loaded texture
149148 * @throws IOException Indicates a failure to access the resource
150149 */
151 public Texture getTexture(String resourceName,
152 int target,
153 int dstPixelFormat,
154 int minFilter,
155 int magFilter) throws IOException {
156 int srcPixelFormat = 0;
157
158 // create the texture ID for this texture
159 int textureID = createTextureID();
160 Texture texture = new Texture(target,textureID);
161
162 // bind this texture
163 GL11.glBindTexture(target, textureID);
164
165 BufferedImage bufferedImage = loadImage(resourceName);
150 public Texture getTexture(String resourceName,
151 int target,
152 int dstPixelFormat,
153 int minFilter,
154 int magFilter) throws IOException {
155 int srcPixelFormat;
156
157 // create the texture ID for this texture
158 int textureID = createTextureID();
159 Texture texture = new Texture(target,textureID);
160
161 // bind this texture
162 glBindTexture(target, textureID);
163
164 BufferedImage bufferedImage = loadImage(resourceName);
166165 texture.setWidth(bufferedImage.getWidth());
167166 texture.setHeight(bufferedImage.getHeight());
168
167
169168 if (bufferedImage.getColorModel().hasAlpha()) {
170 srcPixelFormat = GL11.GL_RGBA;
169 srcPixelFormat = GL_RGBA;
171170 } else {
172 srcPixelFormat = GL11.GL_RGB;
173 }
174
175 // convert that image into a byte buffer of texture data
176 ByteBuffer textureBuffer = convertImageData(bufferedImage,texture);
177
178 if (target == GL11.GL_TEXTURE_2D) {
179 GL11.glTexParameteri(target, GL11.GL_TEXTURE_MIN_FILTER, minFilter);
180 GL11.glTexParameteri(target, GL11.GL_TEXTURE_MAG_FILTER, magFilter);
181 }
182
171 srcPixelFormat = GL_RGB;
172 }
173
174 // convert that image into a byte buffer of texture data
175 ByteBuffer textureBuffer = convertImageData(bufferedImage,texture);
176
177 if (target == GL_TEXTURE_2D) {
178 glTexParameteri(target, GL_TEXTURE_MIN_FILTER, minFilter);
179 glTexParameteri(target, GL_TEXTURE_MAG_FILTER, magFilter);
180 }
181
183182 // produce a texture from the byte buffer
184 GL11.glTexImage2D(target,
185 0,
186 dstPixelFormat,
187 get2Fold(bufferedImage.getWidth()),
188 get2Fold(bufferedImage.getHeight()),
189 0,
190 srcPixelFormat,
191 GL11.GL_UNSIGNED_BYTE,
192 textureBuffer );
193
194 return texture;
195 }
196
183 glTexImage2D(target,
184 0,
185 dstPixelFormat,
186 get2Fold(bufferedImage.getWidth()),
187 get2Fold(bufferedImage.getHeight()),
188 0,
189 srcPixelFormat,
190 GL_UNSIGNED_BYTE,
191 textureBuffer );
192
193 return texture;
194 }
195
197196 /**
198197 * Get the closest greater power of 2 to the fold number
199 *
198 *
200199 * @param fold The target number
201200 * @return The power of 2
202201 */
203 private int get2Fold(int fold) {
202 private static int get2Fold(int fold) {
204203 int ret = 2;
205204 while (ret < fold) {
206205 ret *= 2;
207206 }
208207 return ret;
209 }
210
208 }
209
211210 /**
212211 * Convert the buffered image to a texture
213212 *
215214 * @param texture The texture to store the data into
216215 * @return A buffer containing the data
217216 */
218 private ByteBuffer convertImageData(BufferedImage bufferedImage,Texture texture) {
219 ByteBuffer imageBuffer = null;
217 private ByteBuffer convertImageData(BufferedImage bufferedImage,Texture texture) {
218 ByteBuffer imageBuffer;
220219 WritableRaster raster;
221220 BufferedImage texImage;
222
221
223222 int texWidth = 2;
224223 int texHeight = 2;
225
224
226225 // find the closest power of 2 for the width and height
227226 // of the produced texture
228227 while (texWidth < bufferedImage.getWidth()) {
231230 while (texHeight < bufferedImage.getHeight()) {
232231 texHeight *= 2;
233232 }
234
233
235234 texture.setTextureHeight(texHeight);
236235 texture.setTextureWidth(texWidth);
237
236
238237 // create a raster that can be used by OpenGL as a source
239238 // for a texture
240239 if (bufferedImage.getColorModel().hasAlpha()) {
244243 raster = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE,texWidth,texHeight,3,null);
245244 texImage = new BufferedImage(glColorModel,raster,false,new Hashtable());
246245 }
247
246
248247 // copy the source image into the produced image
249248 Graphics g = texImage.getGraphics();
250249 g.setColor(new Color(0f,0f,0f,0f));
251250 g.fillRect(0,0,texWidth,texHeight);
252251 g.drawImage(bufferedImage,0,0,null);
253
254 // build a byte buffer from the temporary image
252
253 // build a byte buffer from the temporary image
255254 // that be used by OpenGL to produce a texture.
256 byte[] data = ((DataBufferByte) texImage.getRaster().getDataBuffer()).getData();
257
258 imageBuffer = ByteBuffer.allocateDirect(data.length);
259 imageBuffer.order(ByteOrder.nativeOrder());
260 imageBuffer.put(data, 0, data.length);
255 byte[] data = ((DataBufferByte) texImage.getRaster().getDataBuffer()).getData();
256
257 imageBuffer = ByteBuffer.allocateDirect(data.length);
258 imageBuffer.order(ByteOrder.nativeOrder());
259 imageBuffer.put(data, 0, data.length);
261260 imageBuffer.flip();
262
263 return imageBuffer;
264 }
265
266 /**
261
262 return imageBuffer;
263 }
264
265 /**
267266 * Load a given resource as a buffered image
268 *
267 *
269268 * @param ref The location of the resource to load
270269 * @return The loaded buffered image
271270 * @throws IOException Indicates a failure to find a resource
272271 */
273 private BufferedImage loadImage(String ref) throws IOException {
272 private BufferedImage loadImage(String ref) throws IOException {
274273 URL url = TextureLoader.class.getClassLoader().getResource(ref);
275
274
276275 if (url == null) {
277276 throw new IOException("Cannot find: " + ref);
278277 }
279
280 BufferedImage bufferedImage = ImageIO.read(new BufferedInputStream(getClass().getClassLoader().getResourceAsStream(ref)));
281
278
279 // due to an issue with ImageIO and mixed signed code
280 // we are now using good oldfashioned ImageIcon to load
281 // images and the paint it on top of a new BufferedImage
282 Image img = new ImageIcon(url).getImage();
283 BufferedImage bufferedImage = new BufferedImage(img.getWidth(null), img.getHeight(null), BufferedImage.TYPE_INT_RGB);
284 Graphics g = bufferedImage.getGraphics();
285 g.drawImage(img, 0, 0, null);
286 g.dispose();
287
282288 return bufferedImage;
283 }
289 }
284290 }
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 */
3434 * A game controller of some sort that will provide input. The controller
3535 * presents buttons and axes. Buttons are either pressed or not pressed. Axis
3636 * provide analogue values.
37 *
37 *
3838 * @author Kevin Glass
3939 */
4040 public interface Controller {
4141 /**
4242 * Get the name assigned to this controller.
43 *
43 *
4444 * @return The name assigned to this controller
4545 */
46 public String getName();
46 String getName();
4747
4848 /**
4949 * Get the index of this controller in the collection
50 *
50 *
5151 * @return The index of this controller in the collection
5252 */
53 public int getIndex();
54
53 int getIndex();
54
5555 /**
5656 * Retrieve the number of buttons available on this controller
57 *
57 *
5858 * @return The number of butotns available on this controller
5959 */
60 public int getButtonCount();
61
62 /**
63 * Get the name of the specified button. Be warned, often this is
60 int getButtonCount();
61
62 /**
63 * Get the name of the specified button. Be warned, often this is
6464 * as exciting as "Button X"
65 *
65 *
6666 * @param index The index of the button whose name should be retrieved
6767 * @return The name of the button requested
6868 */
69 public String getButtonName(int index);
70
69 String getButtonName(int index);
70
7171 /**
7272 * Check if a button is currently pressed
73 *
73 *
7474 * @param index The button to check
7575 * @return True if the button is currently pressed
7676 */
77 public boolean isButtonPressed(int index);
78
77 boolean isButtonPressed(int index);
78
7979 /**
8080 * Poll the controller for new data. This will also update
8181 * events
8282 */
83 public void poll();
84
85 /**
83 void poll();
84
85 /**
8686 * Get the X-Axis value of the POV on this controller
87 *
87 *
8888 * @return The X-Axis value of the POV on this controller
8989 */
90 public float getPovX();
91
92 /**
90 float getPovX();
91
92 /**
9393 * Get the Y-Axis value of the POV on this controller
94 *
94 *
9595 * @return The Y-Axis value of the POV on this controller
9696 */
97 public float getPovY();
98
97 float getPovY();
98
9999 /**
100100 * Get the dead zone for a specified axis
101 *
101 *
102102 * @param index The index of the axis for which to retrieve the dead zone
103103 * @return The dead zone for the specified axis
104104 */
105 public float getDeadZone(int index);
106
105 float getDeadZone(int index);
106
107107 /**
108108 * Set the dead zone for the specified axis
109 *
109 *
110110 * @param index The index of hte axis for which to set the dead zone
111111 * @param zone The dead zone to use for the specified axis
112112 */
113 public void setDeadZone(int index,float zone);
114
115 /**
116 * Retrieve the number of axes available on this controller.
117 *
113 void setDeadZone(int index,float zone);
114
115 /**
116 * Retrieve the number of axes available on this controller.
117 *
118118 * @return The number of axes available on this controller.
119119 */
120 public int getAxisCount();
121
120 int getAxisCount();
121
122122 /**
123123 * Get the name that's given to the specified axis
124 *
124 *
125125 * @param index The index of the axis whose name should be retrieved
126126 * @return The name of the specified axis.
127127 */
128 public String getAxisName(int index);
129
128 String getAxisName(int index);
129
130130 /**
131131 * Retrieve the value thats currently available on a specified axis. The
132132 * value will always be between 1.0 and -1.0 and will calibrate as values
133133 * are passed read. It may be useful to get the player to wiggle the joystick
134 * from side to side to get the calibration right.
135 *
134 * from side to side to get the calibration right.
135 *
136136 * @param index The index of axis to be read
137137 * @return The value from the specified axis.
138138 */
139 public float getAxisValue(int index);
140
141 /**
142 * Get the value from the X axis if there is one. If no X axis is
143 * defined a zero value will be returned.
144 *
139 float getAxisValue(int index);
140
141 /**
142 * Get the value from the X axis if there is one. If no X axis is
143 * defined a zero value will be returned.
144 *
145145 * @return The value from the X axis
146146 */
147 public float getXAxisValue();
148
147 float getXAxisValue();
148
149149 /**
150150 * Get the dead zone for the X axis.
151 *
151 *
152152 * @return The dead zone for the X axis
153153 */
154 public float getXAxisDeadZone();
155
154 float getXAxisDeadZone();
155
156156 /**
157157 * Set the dead zone for the X axis
158 *
158 *
159159 * @param zone The dead zone to use for the X axis
160160 */
161 public void setXAxisDeadZone(float zone);
162
163 /**
164 * Get the value from the Y axis if there is one. If no Y axis is
165 * defined a zero value will be returned.
166 *
161 void setXAxisDeadZone(float zone);
162
163 /**
164 * Get the value from the Y axis if there is one. If no Y axis is
165 * defined a zero value will be returned.
166 *
167167 * @return The value from the Y axis
168168 */
169 public float getYAxisValue();
170
169 float getYAxisValue();
170
171171 /**
172172 * Get the dead zone for the Y axis.
173 *
173 *
174174 * @return The dead zone for the Y axis
175175 */
176 public float getYAxisDeadZone();
176 float getYAxisDeadZone();
177177
178178 /**
179179 * Set the dead zone for the Y axis
180 *
180 *
181181 * @param zone The dead zone to use for the Y axis
182182 */
183 public void setYAxisDeadZone(float zone);
184
185 /**
186 * Get the value from the Z axis if there is one. If no Z axis is
187 * defined a zero value will be returned.
188 *
183 void setYAxisDeadZone(float zone);
184
185 /**
186 * Get the value from the Z axis if there is one. If no Z axis is
187 * defined a zero value will be returned.
188 *
189189 * @return The value from the Z axis
190190 */
191 public float getZAxisValue();
192
191 float getZAxisValue();
192
193193 /**
194194 * Get the dead zone for the Z axis.
195 *
195 *
196196 * @return The dead zone for the Z axis
197197 */
198 public float getZAxisDeadZone();
198 float getZAxisDeadZone();
199199
200200 /**
201201 * Set the dead zone for the Z axis
202 *
202 *
203203 * @param zone The dead zone to use for the Z axis
204204 */
205 public void setZAxisDeadZone(float zone);
206
207 /**
208 * Get the value from the RX axis if there is one. If no RX axis is
209 * defined a zero value will be returned.
210 *
205 void setZAxisDeadZone(float zone);
206
207 /**
208 * Get the value from the RX axis if there is one. If no RX axis is
209 * defined a zero value will be returned.
210 *
211211 * @return The value from the RX axis
212212 */
213 public float getRXAxisValue();
214
213 float getRXAxisValue();
214
215215 /**
216216 * Get the dead zone for the RX axis.
217 *
217 *
218218 * @return The dead zone for the RX axis
219219 */
220 public float getRXAxisDeadZone();
220 float getRXAxisDeadZone();
221221
222222 /**
223223 * Set the dead zone for the RX axis
224 *
224 *
225225 * @param zone The dead zone to use for the RX axis
226226 */
227 public void setRXAxisDeadZone(float zone);
228
229 /**
230 * Get the value from the RY axis if there is one. If no RY axis is
231 * defined a zero value will be returned.
232 *
227 void setRXAxisDeadZone(float zone);
228
229 /**
230 * Get the value from the RY axis if there is one. If no RY axis is
231 * defined a zero value will be returned.
232 *
233233 * @return The value from the RY axis
234234 */
235 public float getRYAxisValue();
236
235 float getRYAxisValue();
236
237237 /**
238238 * Get the dead zone for the RY axis.
239 *
239 *
240240 * @return The dead zone for the RY axis
241241 */
242 public float getRYAxisDeadZone();
242 float getRYAxisDeadZone();
243243
244244 /**
245245 * Set the dead zone for the RY axis
246 *
246 *
247247 * @param zone The dead zone to use for the RY axis
248248 */
249 public void setRYAxisDeadZone(float zone);
250
251 /**
252 * Get the value from the RZ axis if there is one. If no RZ axis is
253 * defined a zero value will be returned.
254 *
249 void setRYAxisDeadZone(float zone);
250
251 /**
252 * Get the value from the RZ axis if there is one. If no RZ axis is
253 * defined a zero value will be returned.
254 *
255255 * @return The value from the RZ axis
256256 */
257 public float getRZAxisValue();
258
257 float getRZAxisValue();
258
259259 /**
260260 * Get the dead zone for the RZ axis.
261 *
261 *
262262 * @return The dead zone for the RZ axis
263263 */
264 public float getRZAxisDeadZone();
264 float getRZAxisDeadZone();
265265
266266 /**
267267 * Set the dead zone for the RZ axis
268 *
268 *
269269 * @param zone The dead zone to use for the RZ axis
270270 */
271 public void setRZAxisDeadZone(float zone);
271 void setRZAxisDeadZone(float zone);
272272 }
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 */
3232
3333 /**
3434 * An event occuring on a controller.
35 *
35 *
3636 * @author Kevin Glass
3737 */
3838 class ControllerEvent {
4444 public static final int POVX = 3;
4545 /** Indicates the event was caused by a pov Y */
4646 public static final int POVY = 4;
47
47
4848 /** The controller generating the event */
4949 private Controller source;
5050 /** The index of the input (axis or button) that generated the event */
5757 private boolean yaxis;
5858 /** The time stamp of this event */
5959 private long timeStamp;
60
60
6161 /**
6262 * Create a new event
63 *
63 *
6464 * @param source The source of the event
6565 * @param timeStamp The time stamp given for this event
6666 * @param type The type of control generating this event
6868 * @param xaxis True if this event was caused by the x-axis
6969 * @param yaxis True if this event was caused by the y-axis
7070 */
71 public ControllerEvent(Controller source,long timeStamp, int type,int index,boolean xaxis,boolean yaxis) {
71 ControllerEvent(Controller source,long timeStamp, int type,int index,boolean xaxis,boolean yaxis) {
7272 this.source = source;
7373 this.timeStamp = timeStamp;
7474 this.type = type;
7676 this.xaxis = xaxis;
7777 this.yaxis = yaxis;
7878 }
79
79
8080 /**
8181 * Get the time stamp given for this event. As with nanoTime()
8282 * this value means nothing other than giving ordering
83 *
83 *
8484 * @return The time stamp given for this event
8585 */
8686 public long getTimeStamp() {
8787 return timeStamp;
8888 }
89
89
9090 /**
9191 * Get the controller that generated this event
92 *
92 *
9393 * @return The controller that generated this event
9494 */
9595 public Controller getSource() {
9696 return source;
9797 }
98
98
9999 /**
100100 * Get the index of the control generating this event
101 *
101 *
102102 * @return The index of the control generating this event
103103 */
104104 public int getControlIndex() {
105105 return index;
106106 }
107
107
108108 /**
109109 * Check if this event was generated by a button
110 *
110 *
111111 * @return True if this event was generated by a button
112112 */
113113 public boolean isButton() {
116116
117117 /**
118118 * Check if this event was generated by a axis
119 *
119 *
120120 * @return True if this event was generated by a axis
121121 */
122122 public boolean isAxis() {
125125
126126 /**
127127 * Check if this event was generated by a pov
128 *
128 *
129129 * @return True if this event was generated by a pov
130130 */
131131 public boolean isPovY() {
132132 return type == POVY;
133133 }
134134 /**
135 *
135 *
136136 * Check if this event was generated by a pov
137 *
137 *
138138 * @return True if this event was generated by a pov
139139 */
140140 public boolean isPovX() {
141141 return type == POVX;
142142 }
143
143
144144 /**
145145 * Check if this event was caused by the X axis
146 *
146 *
147147 * @return True if this event was caused by the X axis
148148 */
149149 public boolean isXAxis() {
152152
153153 /**
154154 * Check if this event was caused by the Y axis
155 *
155 *
156156 * @return True if this event was caused by the Y axis
157157 */
158158 public boolean isYAxis() {
159159 return yaxis;
160160 }
161
161
162162 /*
163163 * @see java.lang.Object#toString()
164164 */
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 */
3838
3939 /**
4040 * The collection of controllers currently connected.
41 *
41 *
4242 * @author Kevin Glass
4343 */
4444 public class Controllers {
4545 /** The controllers available */
46 private static ArrayList controllers = new ArrayList();
46 private static ArrayList<JInputController> controllers = new ArrayList<JInputController>();
4747 /** The number of controllers */
4848 private static int controllerCount;
49
49
5050 /** The current list of events */
51 private static ArrayList events = new ArrayList();
51 private static ArrayList<ControllerEvent> events = new ArrayList<ControllerEvent>();
5252 /** The current event */
5353 private static ControllerEvent event;
54
54
5555 /** Whether controllers were created */
5656 private static boolean created;
57
57
5858 /**
5959 * Initialise the controllers collection
60 *
60 *
6161 * @throws LWJGLException Indicates a failure to initialise the controller library.
6262 */
6363 public static void create() throws LWJGLException {
6464 if (created)
6565 return;
66
66
6767 try {
6868 ControllerEnvironment env = ControllerEnvironment.getDefaultEnvironment();
69
69
7070 net.java.games.input.Controller[] found = env.getControllers();
71 ArrayList lollers = new ArrayList();
72 for (int i=0;i<found.length;i++) {
73 net.java.games.input.Controller c = found[i];
74
75 if ((!c.getType().equals(net.java.games.input.Controller.Type.KEYBOARD)) &&
76 (!c.getType().equals(net.java.games.input.Controller.Type.MOUSE))) {
71 ArrayList<net.java.games.input.Controller> lollers = new ArrayList<net.java.games.input.Controller>();
72 for ( net.java.games.input.Controller c : found ) {
73 if ( (!c.getType().equals(net.java.games.input.Controller.Type.KEYBOARD)) &&
74 (!c.getType().equals(net.java.games.input.Controller.Type.MOUSE)) ) {
7775 lollers.add(c);
7876 }
7977 }
80
81 int length = lollers.size();
82
83 for (int i=0;i<length;i++) {
84 net.java.games.input.Controller c = (net.java.games.input.Controller) lollers.get(i);
85
78
79 for ( net.java.games.input.Controller c : lollers ) {
8680 createController(c);
8781 }
88
82
8983 created = true;
9084 } catch (Throwable e) {
9185 throw new LWJGLException("Failed to initialise controllers",e);
9286 }
9387 }
94
88
9589 /**
9690 * Utility to create a controller based on its potential sub-controllers
97 *
91 *
9892 * @param c The controller to add
9993 */
10094 private static void createController(net.java.games.input.Controller c) {
101 net.java.games.input.Controller[] sub = c.getControllers();
102 if (sub.length == 0) {
95 net.java.games.input.Controller[] subControllers = c.getControllers();
96 if (subControllers.length == 0) {
10397 JInputController controller = new JInputController(controllerCount,c);
104
98
10599 controllers.add(controller);
106100 controllerCount++;
107101 } else {
108 for (int i=0;i<sub.length;i++) {
109 createController(sub[i]);
102 for ( net.java.games.input.Controller sub : subControllers ) {
103 createController(sub);
110104 }
111105 }
112106 }
113
107
114108 /**
115109 * Get a controller from the collection
116 *
110 *
117111 * @param index The index of the controller to retrieve
118112 * @return The controller requested
119113 */
120114 public static Controller getController(int index) {
121 return (Controller) controllers.get(index);
122 }
123
115 return controllers.get(index);
116 }
117
124118 /**
125119 * Retrieve a count of the number of controllers
126 *
120 *
127121 * @return The number of controllers available
128122 */
129123 public static int getControllerCount() {
130124 return controllers.size();
131125 }
132
126
133127 /**
134128 * Poll the controllers available. This will both update their state
135129 * and generate events that must be cleared.
139133 getController(i).poll();
140134 }
141135 }
142
136
143137 /**
144138 * Clear any events stored for the controllers in this set
145139 */
146140 public static void clearEvents() {
147141 events.clear();
148142 }
149
143
150144 /**
151145 * Move to the next event that has been stored.
152 *
146 *
153147 * @return True if there is still an event to process
154148 */
155149 public static boolean next() {
157151 event = null;
158152 return false;
159153 }
160
161 event = (ControllerEvent) events.remove(0);
162
154
155 event = events.remove(0);
156
163157 return event != null;
164158 }
165
159
166160 /**
167161 * @return True if Controllers has been created
168162 */
169163 public static boolean isCreated() {
170164 return created;
171 }
172
165 }
166
173167 /**
174168 * Destroys any resources used by the controllers
175169 */
184178 // for (int i=0;i<controllers.size();i++) {
185179 // //
186180 // }
187 //
181 //
188182 // // cleanup
189183 // event = null;
190184 // events.clear();
191185 // controllers.clear();
192186 // controllerCount = 0;
193187 }
194
188
195189 /**
196190 * Get the source of the current event
197 *
191 *
198192 * @return The source of the current event
199193 */
200194 public static Controller getEventSource() {
201195 return event.getSource();
202196 }
203
197
204198 /**
205199 * Get the index of the control that caused the current event
206 *
200 *
207201 * @return The index of the control that cause the current event
208202 */
209203 public static int getEventControlIndex() {
210204 return event.getControlIndex();
211205 }
212
206
213207 /**
214208 * Check if the current event was caused by a button
215 *
209 *
216210 * @return True if the current event was caused by a button
217211 */
218212 public static boolean isEventButton() {
221215
222216 /**
223217 * Check if the current event was caused by a axis
224 *
218 *
225219 * @return True if the current event was caused by a axis
226220 */
227221 public static boolean isEventAxis() {
228222 return event.isAxis();
229223 }
230
224
231225 /**
232226 * Check if the current event was caused by movement on the x-axis
233 *
227 *
234228 * @return True if the current event was cause by movement on the x-axis
235229 */
236230 public static boolean isEventXAxis() {
239233
240234 /**
241235 * Check if the current event was caused by movement on the y-axis
242 *
236 *
243237 * @return True if the current event was caused by movement on the y-axis
244238 */
245239 public static boolean isEventYAxis() {
246240 return event.isYAxis();
247241 }
248
242
249243 /**
250244 * Check if the current event was cause by the POV x-axis
251 *
245 *
252246 * @return True if the current event was caused by the POV x-axis
253247 */
254248 public static boolean isEventPovX() {
255249 return event.isPovX();
256250 }
257
251
258252 /**
259253 * Check if the current event was cause by the POV x-axis
260 *
254 *
261255 * @return True if the current event was caused by the POV x-axis
262256 */
263257 public static boolean isEventPovY() {
264258 return event.isPovY();
265259 }
266
260
267261 /**
268262 * Get the timestamp assigned to the current event
269 *
263 *
270264 * @return The timestamp assigned ot the current event
271265 */
272266 public static long getEventNanoseconds() {
273267 return event.getTimeStamp();
274268 }
275
269
276270 /**
277271 * Add an event to the stack of events that have been caused
278 *
272 *
279273 * @param event The event to add to the list
280274 */
281275 static void addEvent(ControllerEvent event) {
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 */
4444 * class can be used with Mouse.setCursor(), if available.
4545 *
4646 * @author elias_naur <elias_naur@users.sourceforge.net>
47 * @version $Revision: 2983 $
48 * $Id: Cursor.java 2983 2008-04-07 18:36:09Z matzon $
47 * @version $Revision: 3418 $
48 * $Id: Cursor.java 3418 2010-09-28 21:11:35Z spasi $
4949 */
5050
5151 public class Cursor {
6060
6161 /** First element to display */
6262 private final CursorElement[] cursors;
63
63
6464 /** Index into list of cursors */
65 private int index = 0;
65 private int index;
6666
6767 private boolean destroyed;
68
68
6969 /**
7070 * Constructs a new Cursor, with the given parameters. Mouse must have been created before you can create
7171 * Cursor objects. Cursor images are in ARGB format, but only one bit transparancy is guaranteed to be supported.
8080 * @param images A buffer containing the images. The origin is at the lower left corner, like OpenGL.
8181 * @param delays An int buffer of animation frame delays, if numImages is greater than 1, else null
8282 * @throws LWJGLException if the cursor could not be created for any reason
83 */
83 */
8484 public Cursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException {
8585 synchronized (OpenGLPackageAccess.global_lock) {
8686 if ((getCapabilities() & CURSOR_ONE_BIT_TRANSPARENCY) == 0)
9999
100100 Sys.initialize();
101101
102 // Hmm
103 yHotspot = height - 1 - yHotspot;
102 // Hmm
103 yHotspot = height - 1 - yHotspot;
104104
105105 // create cursor (or cursors if multiple images supplied)
106106 cursors = createCursors(width, height, xHotspot, yHotspot, numImages, images, delays);
161161 // create copy and flip images to match ogl
162162 IntBuffer images_copy = BufferUtils.createIntBuffer(images.remaining());
163163 flipImages(width, height, numImages, images, images_copy);
164
164
165165 // Win32 doesn't (afaik) allow for animation based cursors, except when they're
166166 // in the .ani format, which we don't support.
167167 // The cursor animation was therefor developed using java side time tracking.
168168 // unfortunately X flickers when changing cursor. We therefore check for either
169169 // Win32 or X and do accordingly. This hasn't been implemented on Mac, but we
170170 // might want to split it into a X/Win/Mac cursor if it gets too cluttered
171
171
172172 CursorElement[] cursors;
173173 switch (LWJGLUtil.getPlatform()) {
174174 case LWJGLUtil.PLATFORM_MACOSX:
177177 // create our cursor elements
178178 cursors = new CursorElement[numImages];
179179 for(int i=0; i<numImages; i++) {
180
180
181181 // iterate through the images, and make sure that the pixels are either 0xffxxxxxx or 0x00000000
182182 int size = width * height;
183183 for(int j=0; j<size; j++) {
187187 images_copy.put(index, 0);
188188 }
189189 }
190
190
191191 Object handle = Mouse.getImplementation().createCursor(width, height, xHotspot, yHotspot, 1, images_copy, null);
192192 long delay = (delays != null) ? delays.get(i) : 0;
193193 long timeout = System.currentTimeMillis();
207207 throw new RuntimeException("Unknown OS");
208208 }
209209 return cursors;
210 }
211
210 }
211
212212 /**
213213 * Flips the images so they're oriented according to opengl
214 *
214 *
215215 * @param width Width of image
216 * @param height Height of images
216 * @param height Height of images
217217 * @param numImages How many images to flip
218218 * @param images Source images
219219 * @param images_copy Destination images
227227
228228 /**
229229 * @param width Width of image
230 * @param height Height of images
230 * @param height Height of images
231231 * @param start_index index into source buffer to copy to
232232 * @param images Source images
233233 * @param images_copy Destination images
244244 images_copy.put(index2, temp_pixel);
245245 }
246246 }
247 }
248
247 }
248
249249 /**
250250 * Gets the native handle associated with the cursor object.
251251 */
253253 checkValid();
254254 return cursors[index].cursorHandle;
255255 }
256
256
257257 private void checkValid() {
258258 if (destroyed)
259259 throw new IllegalStateException("The cursor is destroyed");
260260 }
261
261
262262 /**
263263 * Destroy the native cursor. If the cursor is current,
264264 * the current native cursor is set to null (the default
275275 // ignore
276276 }
277277 }
278 for(int i=0; i<cursors.length; i++) {
279 Mouse.getImplementation().destroyCursor(cursors[i].cursorHandle);
278 for ( CursorElement cursor : cursors ) {
279 Mouse.getImplementation().destroyCursor(cursor.cursorHandle);
280280 }
281281 destroyed = true;
282282 }
299299 return cursors.length > 1 && cursors[index].timeout < System.currentTimeMillis();
300300 }
301301
302 /**
303 * Changes to the next cursor
302 /**
303 * Changes to the next cursor
304304 */
305305 protected void nextCursor() {
306306 checkValid();
307307 index = ++index % cursors.length;
308308 }
309
309
310310 /**
311311 * A single cursor element, used when animating
312312 */
313313 private static class CursorElement {
314314 /** Handle to cursor */
315315 final Object cursorHandle;
316
316
317317 /** How long a delay this element should have */
318318 final long delay;
319
319
320320 /** Absolute time this element times out */
321321 long timeout;
322322
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 */
3333 import java.util.ArrayList;
3434
3535 import net.java.games.input.Component;
36 import net.java.games.input.Component.Identifier.Axis;
37 import net.java.games.input.Component.Identifier.Button;
3638 import net.java.games.input.Event;
3739 import net.java.games.input.EventQueue;
3840
3941 /**
4042 * A wrapper round a JInput controller that attempts to make the interface
4143 * more useable.
42 *
44 *
4345 * @author Kevin Glass
4446 */
4547 class JInputController implements Controller {
4850 /** The index that has been assigned to this controller */
4951 private int index;
5052 /** The Buttons that have been detected on the JInput controller */
51 private ArrayList buttons = new ArrayList();
53 private ArrayList<Component> buttons = new ArrayList<Component>();
5254 /** The Axes that have been detected on the JInput controller */
53 private ArrayList axes = new ArrayList();
55 private ArrayList<Component> axes = new ArrayList<Component>();
5456 /** The POVs that have been detected on the JInput controller */
55 private ArrayList pov = new ArrayList();
57 private ArrayList<Component> pov = new ArrayList<Component>();
5658 /** The state of the buttons last check */
5759 private boolean[] buttonState;
5860 /** The values that were read from the pov last check */
7577 private int ryaxis = -1;
7678 /** The index of the RZ axis or -1 if no RZ axis is defined */
7779 private int rzaxis = -1;
78
80
7981 /**
8082 * Create a new controller that wraps round a JInput controller and hopefully
8183 * makes it easier to use.
82 *
84 *
8385 * @param index The index this controller has been assigned to
8486 * @param target The target JInput controller this class is wrapping
8587 */
86 public JInputController(int index,net.java.games.input.Controller target) {
88 JInputController(int index,net.java.games.input.Controller target) {
8789 this.target = target;
8890 this.index = index;
89
91
9092 Component[] sourceAxes = target.getComponents();
91
92 for (int i=0;i<sourceAxes.length;i++) {
93 if (sourceAxes[i].getIdentifier() instanceof Component.Identifier.Button) {
94 buttons.add(sourceAxes[i]);
95 } else if (sourceAxes[i].getIdentifier().equals(Component.Identifier.Axis.POV)) {
96 pov.add(sourceAxes[i]);
93
94 for ( Component sourceAxis : sourceAxes ) {
95 if ( sourceAxis.getIdentifier() instanceof Button ) {
96 buttons.add(sourceAxis);
97 } else if ( sourceAxis.getIdentifier().equals(Axis.POV) ) {
98 pov.add(sourceAxis);
9799 } else {
98 axes.add(sourceAxes[i]);
100 axes.add(sourceAxis);
99101 }
100102 }
101
103
102104 buttonState = new boolean[buttons.size()];
103105 povValues = new float[pov.size()];
104106 axesValue = new float[axes.size()];
105107 int buttonsCount = 0;
106108 int axesCount = 0;
107
109
108110 // initialise the state
109 for (int i=0;i<sourceAxes.length;i++) {
110 if (sourceAxes[i].getIdentifier() instanceof Component.Identifier.Button) {
111 buttonState[buttonsCount] = sourceAxes[i].getPollData() != 0;
111 for ( Component sourceAxis : sourceAxes ) {
112 if ( sourceAxis.getIdentifier() instanceof Button ) {
113 buttonState[buttonsCount] = sourceAxis.getPollData() != 0;
112114 buttonsCount++;
113 } else if (sourceAxes[i].getIdentifier().equals(Component.Identifier.Axis.POV)) {
115 } else if ( sourceAxis.getIdentifier().equals(Axis.POV) ) {
114116 // no account for POV yet
115117 // pov.add(sourceAxes[i]);
116118 } else {
117 axesValue[axesCount] = sourceAxes[i].getPollData();
118 if (sourceAxes[i].getIdentifier().equals(Component.Identifier.Axis.X)) {
119 axesValue[axesCount] = sourceAxis.getPollData();
120 if ( sourceAxis.getIdentifier().equals(Axis.X) ) {
119121 xaxis = axesCount;
120122 }
121 if (sourceAxes[i].getIdentifier().equals(Component.Identifier.Axis.Y)) {
123 if ( sourceAxis.getIdentifier().equals(Axis.Y) ) {
122124 yaxis = axesCount;
123125 }
124 if (sourceAxes[i].getIdentifier().equals(Component.Identifier.Axis.Z)) {
126 if ( sourceAxis.getIdentifier().equals(Axis.Z) ) {
125127 zaxis = axesCount;
126128 }
127 if (sourceAxes[i].getIdentifier().equals(Component.Identifier.Axis.RX)) {
129 if ( sourceAxis.getIdentifier().equals(Axis.RX) ) {
128130 rxaxis = axesCount;
129131 }
130 if (sourceAxes[i].getIdentifier().equals(Component.Identifier.Axis.RY)) {
132 if ( sourceAxis.getIdentifier().equals(Axis.RY) ) {
131133 ryaxis = axesCount;
132134 }
133 if (sourceAxes[i].getIdentifier().equals(Component.Identifier.Axis.RZ)) {
135 if ( sourceAxis.getIdentifier().equals(Axis.RZ) ) {
134136 rzaxis = axesCount;
135137 }
136
138
137139 axesCount++;
138140 }
139141 }
140
142
141143 axesMax = new float[axes.size()];
142144 deadZones = new float[axes.size()];
143
145
144146 for (int i=0;i<axesMax.length;i++) {
145147 axesMax[i] = 1.0f;
146148 deadZones[i] = 0.05f;
173175 * @see org.lwjgl.input.Controller#getButtonName(int)
174176 */
175177 public String getButtonName(int index) {
176 Component button = (Component) buttons.get(index);
177
178 return button.getName();
178 return buttons.get(index).getName();
179179 }
180180
181181 /*
190190 */
191191 public void poll() {
192192 target.poll();
193
193
194194 Event event = new Event();
195195 EventQueue queue = target.getEventQueue();
196
196
197197 while (queue.getNextEvent(event)) {
198198 // handle button event
199199 if (buttons.contains(event.getComponent())) {
204204 // fire button pressed event
205205 Controllers.addEvent(new ControllerEvent(this,event.getNanos(),ControllerEvent.BUTTON,buttonIndex,false,false));
206206 }
207
207
208208 // handle pov events
209209 if (pov.contains(event.getComponent())) {
210210 Component povComponent = event.getComponent();
220220 Controllers.addEvent(new ControllerEvent(this,event.getNanos(),ControllerEvent.POVY,0,false,false));
221221 }
222222 }
223
223
224224 // handle axis updates
225225 if (axes.contains(event.getComponent())) {
226226 Component axis = event.getComponent();
227227 int axisIndex = axes.indexOf(axis);
228228 float value = axis.getPollData();
229
229
230230 // fixed dead zone since most axis don't report it :(
231231 if (Math.abs(value) < deadZones[axisIndex]) {
232232 value = 0;
237237 if (Math.abs(value) > axesMax[axisIndex]) {
238238 axesMax[axisIndex] = Math.abs(value);
239239 }
240
240
241241 // normalize the value based on maximum value read in the past
242242 value /= axesMax[axisIndex];
243243 // fire event
259259 * @see org.lwjgl.input.Controller#getAxisName(int)
260260 */
261261 public String getAxisName(int index) {
262 Component axis = (Component) axes.get(index);
263
264 return axis.getName();
262 return axes.get(index).getName();
265263 }
266264
267265 /*
278276 if (xaxis == -1) {
279277 return 0;
280278 }
281
279
282280 return getAxisValue(xaxis);
283281 }
284282
289287 if (yaxis == -1) {
290288 return 0;
291289 }
292
290
293291 return getAxisValue(yaxis);
294292 }
295293
300298 if (xaxis == -1) {
301299 return 0;
302300 }
303
301
304302 return getDeadZone(xaxis);
305303 }
306304
311309 if (yaxis == -1) {
312310 return 0;
313311 }
314
312
315313 return getDeadZone(yaxis);
316314 }
317315
350348 if (zaxis == -1) {
351349 return 0;
352350 }
353
351
354352 return getAxisValue(zaxis);
355353 }
356354
361359 if (zaxis == -1) {
362360 return 0;
363361 }
364
362
365363 return getDeadZone(zaxis);
366364 }
367365
379377 if (rxaxis == -1) {
380378 return 0;
381379 }
382
380
383381 return getAxisValue(rxaxis);
384382 }
385383
390388 if (rxaxis == -1) {
391389 return 0;
392390 }
393
391
394392 return getDeadZone(rxaxis);
395393 }
396394
408406 if (ryaxis == -1) {
409407 return 0;
410408 }
411
409
412410 return getAxisValue(ryaxis);
413411 }
414412
419417 if (ryaxis == -1) {
420418 return 0;
421419 }
422
420
423421 return getDeadZone(ryaxis);
424422 }
425423
437435 if (rzaxis == -1) {
438436 return 0;
439437 }
440
438
441439 return getAxisValue(rzaxis);
442440 }
443441
448446 if (rzaxis == -1) {
449447 return 0;
450448 }
451
449
452450 return getDeadZone(rzaxis);
453451 }
454452
466464 if (pov.size() == 0) {
467465 return 0;
468466 }
469
467
470468 float value = povValues[0];
471
472 if ((value == Component.POV.DOWN_LEFT) ||
469
470 if ((value == Component.POV.DOWN_LEFT) ||
473471 (value == Component.POV.UP_LEFT) ||
474472 (value == Component.POV.LEFT)) {
475473 return -1;
476474 }
477 if ((value == Component.POV.DOWN_RIGHT) ||
475 if ((value == Component.POV.DOWN_RIGHT) ||
478476 (value == Component.POV.UP_RIGHT) ||
479477 (value == Component.POV.RIGHT)) {
480478 return 1;
481479 }
482
480
483481 return 0;
484482 }
485483
490488 if (pov.size() == 0) {
491489 return 0;
492490 }
493
491
494492 float value = povValues[0];
495
496 if ((value == Component.POV.DOWN_LEFT) ||
493
494 if ((value == Component.POV.DOWN_LEFT) ||
497495 (value == Component.POV.DOWN_RIGHT) ||
498496 (value == Component.POV.DOWN)) {
499497 return 1;
500498 }
501 if ((value == Component.POV.UP_LEFT) ||
499 if ((value == Component.POV.UP_LEFT) ||
502500 (value == Component.POV.UP_RIGHT) ||
503501 (value == Component.POV.UP)) {
504502 return -1;
505503 }
506
504
507505 return 0;
508506 }
509
510
507
508
511509 }
5050 * @author cix_foo <cix_foo@users.sourceforge.net>
5151 * @author elias_naur <elias_naur@users.sourceforge.net>
5252 * @author Brian Matzon <brian@matzon.dk>
53 * @version $Revision: 2983 $
54 * $Id: Keyboard.java 2983 2008-04-07 18:36:09Z matzon $
53 * @version $Revision: 3463 $
54 * $Id: Keyboard.java 3463 2010-12-15 18:48:56Z kappa1 $
5555 */
5656 public class Keyboard {
5757 /** Internal use - event size in bytes */
216216
217217 /** Key names */
218218 private static final String[] keyName = new String[255];
219 private static final Map keyMap = new HashMap(253);
219 private static final Map<String, Integer> keyMap = new HashMap<String, Integer>(253);
220220 private static int counter;
221221
222222 static {
223223 // Use reflection to find out key names
224 Field[] field = Keyboard.class.getFields();
224 Field[] fields = Keyboard.class.getFields();
225225 try {
226 for (int i = 0; i < field.length; i++) {
227 if (Modifier.isStatic(field[i].getModifiers())
228 && Modifier.isPublic(field[i].getModifiers())
229 && Modifier.isFinal(field[i].getModifiers())
230 && field[i].getType().equals(int.class)
231 && field[i].getName().startsWith("KEY_")) {
232
233 int key = field[i].getInt(null);
234 String name = field[i].getName().substring(4);
226 for ( Field field : fields ) {
227 if ( Modifier.isStatic(field.getModifiers())
228 && Modifier.isPublic(field.getModifiers())
229 && Modifier.isFinal(field.getModifiers())
230 && field.getType().equals(int.class)
231 && field.getName().startsWith("KEY_") ) {
232
233 int key = field.getInt(null);
234 String name = field.getName().substring(4);
235235 keyName[key] = name;
236 keyMap.put(name, new Integer(key));
237 counter ++;
236 keyMap.put(name, key);
237 counter++;
238238 }
239239
240240 }
354354 * Polls the keyboard for its current state. Access the polled values using the
355355 * <code>isKeyDown</code> method.
356356 * By using this method, it is possible to "miss" keyboard keys if you don't
357 * poll fast enough.
357 * poll fast enough.
358358 *
359359 * To use buffered values, you have to call <code>next</code> for each event you
360360 * want to read. You can query which key caused the event by using
425425 * @param keyName The key name
426426 */
427427 public static synchronized int getKeyIndex(String keyName) {
428 Integer ret = (Integer) keyMap.get(keyName);
428 Integer ret = keyMap.get(keyName);
429429 if (ret == null)
430430 return KEY_NONE;
431431 else
432 return ret.intValue();
432 return ret;
433433 }
434434
435435 /**
530530 * Please note that the key code returned is NOT valid against the
531531 * current keyboard layout. To get the actual character pressed call
532532 * getEventCharacter
533 *
533 *
534534 * @return The key from the current event
535535 */
536536 public static int getEventKey() {
540540 }
541541
542542 /**
543 * Gets the state of the tkey that generated the
543 * Gets the state of the key that generated the
544544 * current event
545545 *
546546 * @return True if key was down, or false if released
575575 }
576576 }
577577
578 private final static class KeyEvent {
578 private static final class KeyEvent {
579579 /** The current keyboard character being examined */
580580 private int character;
581581
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: 3337 $
62 * $Id: Mouse.java 3337 2010-04-29 17:37:18Z matzon $
61 * @version $Revision: 3418 $
62 * $Id: Mouse.java 3418 2010-09-28 21:11:35Z spasi $
6363 */
6464 public class Mouse {
6565 /** Internal use - event size in bytes */
102102 private static String[] buttonName;
103103
104104 /** hashmap of button names, for fast lookup */
105 private static final Map buttonMap = new HashMap(16);
105 private static final Map<String, Integer> buttonMap = new HashMap<String, Integer>(16);
106106
107107 /** Lazy initialization */
108108 private static boolean initialized;
134134 private static boolean isGrabbed;
135135
136136 private static InputImplementation implementation;
137
137
138138 /** Whether we need cursor animation emulation */
139 private static final boolean emulateCursorAnimation = LWJGLUtil.getPlatform() == LWJGLUtil.PLATFORM_WINDOWS ||
139 private static final boolean emulateCursorAnimation = LWJGLUtil.getPlatform() == LWJGLUtil.PLATFORM_WINDOWS ||
140140 LWJGLUtil.getPlatform() == LWJGLUtil.PLATFORM_MACOSX;
141141
142142 private static final boolean allowNegativeMouseCoords = getPrivilegedBoolean("org.lwjgl.input.Mouse.allowNegativeMouseCoords");
212212 }
213213 }
214214 }
215
215
216216 /**
217217 * Static initialization
218218 */
223223 buttonName = new String[16];
224224 for (int i = 0; i < 16; i++) {
225225 buttonName[i] = "BUTTON" + i;
226 buttonMap.put(buttonName[i], new Integer(i));
226 buttonMap.put(buttonName[i], i);
227227 }
228228
229229 initialized = true;
307307 * Polls the mouse for its current state. Access the polled values using the
308308 * get<value> methods.
309309 * By using this method, it is possible to "miss" mouse click events if you don't
310 * poll fast enough.
310 * poll fast enough.
311311 *
312312 * To use buffered values, you have to call <code>next</code> for each event you
313313 * want to read. You can query which button caused the event by using
400400 */
401401 public static int getButtonIndex(String buttonName) {
402402 synchronized (OpenGLPackageAccess.global_lock) {
403 Integer ret = (Integer) buttonMap.get(buttonName);
403 Integer ret = buttonMap.get(buttonName);
404404 if (ret == null)
405405 return -1;
406406 else
407 return ret.intValue();
407 return ret;
408408 }
409409 }
410410
625625 // store location mouse was grabbed
626626 grab_x = x;
627627 grab_y = y;
628 }
628 }
629629 else if (!grab && grabbed) {
630630 // move mouse back to location it was grabbed before ungrabbing
631631 if ((Cursor.getCapabilities() & Cursor.CURSOR_ONE_BIT_TRANSPARENCY) != 0)
632632 implementation.setCursorPosition(grab_x, grab_y);
633633 }
634
634
635635 implementation.grabMouse(grab);
636636 // Get latest values from native side
637637 poll();
662662
663663 /** Gets a boolean property as a privileged action. */
664664 static boolean getPrivilegedBoolean(final String property_name) {
665 Boolean value = (Boolean)AccessController.doPrivileged(new PrivilegedAction() {
666 public Object run() {
667 return new Boolean(Boolean.getBoolean(property_name));
665 Boolean value = AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
666 public Boolean run() {
667 return Boolean.getBoolean(property_name);
668668 }
669669 });
670 return value.booleanValue();
670 return value;
671671 }
672672
673673 /**
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 */
4444 * package through (privileged) reflection.
4545 */
4646 final class OpenGLPackageAccess {
47 final static Object global_lock;
47 static final Object global_lock;
4848
4949 static {
5050 try {
51 global_lock = AccessController.doPrivileged(new PrivilegedExceptionAction() {
51 global_lock = AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
5252 public Object run() throws Exception {
5353 Field lock_field = Class.forName("org.lwjgl.opengl.GlobalLock").getDeclaredField("lock");
5454 lock_field.setAccessible(true);
6565 * public
6666 */
6767 try {
68 return (InputImplementation)AccessController.doPrivileged(new PrivilegedExceptionAction() {
69 public Object run() throws Exception {
70 Method getImplementation_method = Display.class.getDeclaredMethod("getImplementation", null);
68 return AccessController.doPrivileged(new PrivilegedExceptionAction<InputImplementation>() {
69 public InputImplementation run() throws Exception {
70 Method getImplementation_method = Display.class.getDeclaredMethod("getImplementation");
7171 getImplementation_method.setAccessible(true);
72 return getImplementation_method.invoke(null, null);
72 return (InputImplementation)getImplementation_method.invoke(null);
7373 }
7474 });
7575 } catch (PrivilegedActionException e) {
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 */
4141 * </p>
4242 *
4343 * @author Brian Matzon <brian@matzon.dk>
44 * @version $Revision: 3348 $
45 * $Id: AL.java 3348 2010-05-24 21:54:37Z matzon $
44 * @version $Revision: 3418 $
45 * $Id: AL.java 3418 2010-09-28 21:11:35Z spasi $
4646 */
4747 public final class AL {
4848 /** ALCdevice instance. */
49 protected static ALCdevice device;
49 static ALCdevice device;
5050
5151 /** Current ALCcontext. */
52 protected static ALCcontext context;
52 static ALCcontext context;
5353
5454 /** Have we been created? */
5555 private static boolean created;
56
56
5757 static {
5858 Sys.initialize();
5959 }
6363
6464 /**
6565 * Native method to create AL instance
66 *
67 * @param oalPaths Array of strings containing paths to search for OpenAL library
66 *
67 * @param oalPath Path to search for OpenAL library
6868 */
6969 private static native void nCreate(String oalPath) throws LWJGLException;
70
70
7171 /**
7272 * Native method to create AL instance from the Mac OS X 10.4 OpenAL framework.
7373 * It is only defined in the Mac OS X native library.
74 *
75 * @param oalPaths Array of strings containing paths to search for OpenAL library
7674 */
7775 private static native void nCreateDefault() throws LWJGLException;
7876
8078 * Native method the destroy the AL
8179 */
8280 private static native void nDestroy();
83
81
8482 /**
8583 * @return true if AL has been created
8684 */
8785 public static boolean isCreated() {
8886 return created;
89 }
90
87 }
88
9189 /**
9290 * Creates an OpenAL instance. Using this constructor will cause OpenAL to
9391 * open the device using supplied device argument, and create a context using the context values
94 * supplied.
95 *
92 * supplied.
93 *
9694 * @param deviceArguments Arguments supplied to native device
9795 * @param contextFrequency Frequency for mixing output buffer, in units of Hz (Common values include 11025, 22050, and 44100).
9896 * @param contextRefresh Refresh intervalls, in units of Hz.
99 * @param contextSynchronized Flag, indicating a synchronous context.*
100 */
101 public static void create(String deviceArguments, int contextFrequency, int contextRefresh, boolean contextSynchronized)
97 * @param contextSynchronized Flag, indicating a synchronous context.*
98 */
99 public static void create(String deviceArguments, int contextFrequency, int contextRefresh, boolean contextSynchronized)
102100 throws LWJGLException {
103101 create(deviceArguments, contextFrequency, contextRefresh, contextSynchronized, true);
104102 }
105
103
106104 /**
107105 * @param openDevice Whether to automatically open the device
108106 * @see #create(String, int, int, boolean)
109107 */
110108 public static void create(String deviceArguments, int contextFrequency, int contextRefresh, boolean contextSynchronized, boolean openDevice)
111109 throws LWJGLException {
112
110
113111 if (created)
114112 throw new IllegalStateException("Only one OpenAL context may be instantiated at any one time.");
115113 String libname;
132130 }
133131 String[] oalPaths = LWJGLUtil.getLibraryPaths(libname, library_names, AL.class.getClassLoader());
134132 LWJGLUtil.log("Found " + oalPaths.length + " OpenAL paths");
135 for (int i = 0; i < oalPaths.length; i++) {
133 for ( String oalPath : oalPaths ) {
136134 try {
137 nCreate(oalPaths[i]);
135 nCreate(oalPath);
138136 created = true;
139137 init(deviceArguments, contextFrequency, contextRefresh, contextSynchronized, openDevice);
140138 break;
141139 } catch (LWJGLException e) {
142 LWJGLUtil.log("Failed to load " + oalPaths[i] + ": " + e.getMessage());
140 LWJGLUtil.log("Failed to load " + oalPath + ": " + e.getMessage());
143141 }
144142 }
145143 if (!created && LWJGLUtil.getPlatform() == LWJGLUtil.PLATFORM_MACOSX) {
156154 try {
157155 AL10.initNativeStubs();
158156 ALC10.initNativeStubs();
159
157
160158 if(openDevice) {
161159 device = ALC10.alcOpenDevice(deviceArguments);
162160 if (device == null) {
163161 throw new LWJGLException("Could not open ALC device");
164162 }
165
163
166164 if (contextFrequency == -1) {
167165 context = ALC10.alcCreateContext(device, null);
168166 } else {
169167 context = ALC10.alcCreateContext(device,
170 ALCcontext.createAttributeList(contextFrequency, contextRefresh,
168 ALCcontext.createAttributeList(contextFrequency, contextRefresh,
171169 contextSynchronized ? ALC10.ALC_TRUE : ALC10.ALC_FALSE));
172170 }
173171 ALC10.alcMakeContextCurrent(context);
176174 destroy();
177175 throw e;
178176 }
179
177
180178 ALC11.initialize();
181179
182180 // Load EFX10 native stubs if ALC_EXT_EFX is supported.
196194 * open the default device, and create a context using default values.
197195 * This method used to use default values that the OpenAL implementation
198196 * chose but this produces unexpected results on some systems; so now
199 * it defaults to 44100Hz mixing @ 60Hz refresh.
197 * it defaults to 44100Hz mixing @ 60Hz refresh.
200198 */
201199 public static void create() throws LWJGLException {
202200 create(null, 44100, 60, false);
227225 }
228226
229227 private static native void resetNativeStubs(Class clazz);
230
228
231229 /**
232230 * @return handle to the default AL context.
233231 */
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 */
3838 import org.lwjgl.LWJGLException;
3939
4040 /**
41 *
41 *
4242 * <p>
4343 * ALC introduces the notion of a Device. A Device can be, depending on the
4444 * implementation, a hardware device, or a daemon/OS service/actual server. This
4848 * implementation, which has to map the available backends to unique device
4949 * specifiers (represented as strings).
5050 * </p>
51 *
51 *
5252 * @author Brian Matzon <brian@matzon.dk>
5353 * @version $Revision: 2286 $
5454 * $Id: ALC.java 2286 2006-03-23 19:32:21 +0000 (to, 23 mar 2006) matzon $
5555 */
5656 public final class ALC10 {
57
57
5858 /** List of active contexts */
59 static HashMap contexts = new HashMap();
60
59 static final HashMap<Long, ALCcontext> contexts = new HashMap<Long, ALCcontext>();
60
6161 /** List of active devices */
62 static HashMap devices = new HashMap();
63
62 static final HashMap<Long, ALCdevice> devices = new HashMap<Long, ALCdevice>();
63
6464 /** Bad value */
6565 public static final int ALC_INVALID = 0;
6666
7979 /** Minor version query. */
8080 public static final int ALC_MINOR_VERSION = 0x1001;
8181
82 /**
82 /**
8383 * The size required for the zero-terminated attributes list, for the current context.
8484 **/
8585 public static final int ALC_ATTRIBUTES_SIZE = 0x1002;
115115 public static final int ALC_INVALID_CONTEXT = 0xA002;
116116
117117 /**
118 * A function was called at inappropriate time, or in an inappropriate way,
118 * A function was called at inappropriate time, or in an inappropriate way,
119119 * causing an illegal state. This can be an incompatible ALenum, object ID,
120120 * and/or function.
121121 */
128128 public static final int ALC_INVALID_VALUE = 0xA004;
129129
130130 /**
131 * A function could not be completed, because there is not enough
131 * A function could not be completed, because there is not enough
132132 * memory available.
133133 */
134134 public static final int ALC_OUT_OF_MEMORY = 0xA005;
135
135
136136 static native void initNativeStubs() throws LWJGLException;
137
137
138138 /**
139139 * The application can obtain certain strings from ALC.
140 *
140 *
141141 * <code>ALC_DEFAULT_DEVICE_SPECIFIER</code> - The specifer string for the default device
142 * <code>ALC_DEVICE_SPECIFIER</code> - The specifer string for the device
142 * <code>ALC_DEVICE_SPECIFIER</code> - The specifer string for the device
143143 * <code>ALC_EXTENSIONS</code> - The extensions string for diagnostics and printing.
144144 *
145145 * In addition, printable error message strings are provided for all valid error tokens,
146146 * including <code>ALC_NO_ERROR</code>,<code>ALC_INVALID_DEVICE</code>, <code>ALC_INVALID_CONTEXT</code>,
147147 * <code>ALC_INVALID_ENUM</code>, <code>ALC_INVALID_VALUE</code>.
148 *
148 *
149149 * @param pname Property to get
150150 * @return String property from device
151151 */
155155 Util.checkALCError(device);
156156 return result;
157157 }
158 native static String nalcGetString(long device, int pname);
158 static native String nalcGetString(long device, int pname);
159159
160160 /**
161161 * The application can query ALC for information using an integer query function.
163163 * device will generate an <code>ALC_INVALID_DEVICE</code> error. The application has to
164164 * specify the size of the destination buffer provided. A <code>null</code> destination or a zero
165165 * size parameter will cause ALC to ignore the query.
166 *
166 *
167167 * <code>ALC_MAJOR_VERSION</code> - Major version query.
168168 * <code>ALC_MINOR_VERSION</code> - Minor version query.
169 * <code>ALC_ATTRIBUTES_SIZE</code> - The size required for the zero-terminated attributes list,
170 * for the current context. <code>null</code> is an invalid device. <code>null</code> (no current context
169 * <code>ALC_ATTRIBUTES_SIZE</code> - The size required for the zero-terminated attributes list,
170 * for the current context. <code>null</code> is an invalid device. <code>null</code> (no current context
171171 * for the specified device) is legal.
172172 * <code>ALC_ALL_ATTRIBUTES</code> - Expects a destination of <code>ALC_CURRENT_ATTRIBUTES_SIZE</code>,
173173 * and provides the attribute list for the current context of the specified device.
182182 nalcGetIntegerv(getDevice(device), pname, integerdata.remaining(), integerdata, integerdata.position());
183183 Util.checkALCError(device);
184184 }
185 native static void nalcGetIntegerv(long device, int pname, int size, Buffer integerdata, int offset);
185 static native void nalcGetIntegerv(long device, int pname, int size, Buffer integerdata, int offset);
186186
187187 /**
188188 * The <code>alcOpenDevice</code> function allows the application (i.e. the client program) to
201201 if(device_address != 0) {
202202 ALCdevice device = new ALCdevice(device_address);
203203 synchronized (ALC10.devices) {
204 devices.put(new Long(device_address), device);
204 devices.put(device_address, device);
205205 }
206206 return device;
207207 }
208208 return null;
209209 }
210 native static long nalcOpenDevice(String devicename);
210 static native long nalcOpenDevice(String devicename);
211211
212212 /**
213213 * The <code>alcCloseDevice</code> function allows the application (i.e. the client program) to
214214 * disconnect from a device (i.e. the server).
215 *
215 *
216216 * If deviceHandle is <code>null</code> or invalid, an <code>ALC_INVALID_DEVICE</code> error will be
217217 * generated. Once closed, a deviceHandle is invalid.
218218 *
225225 devices.remove(new Long(device.device));
226226 }
227227 return result;
228
229 }
230 native static boolean nalcCloseDevice(long device);
228
229 }
230 static native boolean nalcCloseDevice(long device);
231231
232232 /**
233233 * A context is created using <code>alcCreateContext</code>. The device parameter has to be a valid
234234 * device. The attribute list can be <code>null</code>, or a zero terminated list of integer pairs
235235 * composed of valid ALC attribute tokens and requested values.
236 *
236 *
237237 * Context creation will fail if the application requests attributes that, by themselves,
238238 * can not be provided. Context creation will fail if the combination of specified
239239 * attributes can not be provided. Context creation will fail if a specified attribute, or
247247 public static ALCcontext alcCreateContext(ALCdevice device, IntBuffer attrList) {
248248 long context_address = nalcCreateContext(getDevice(device), attrList);
249249 Util.checkALCError(device);
250
250
251251 if(context_address != 0) {
252252 ALCcontext context = new ALCcontext(context_address);
253253 synchronized (ALC10.contexts) {
254 contexts.put(new Long(context_address), context);
254 contexts.put(context_address, context);
255255 device.addContext(context);
256256 }
257257 return context;
258258 }
259259 return null;
260260 }
261 native static long nalcCreateContext(long device, IntBuffer attrList);
261 static native long nalcCreateContext(long device, IntBuffer attrList);
262262
263263 /**
264264 * To make a Context current with respect to AL Operation (state changes by issueing
265265 * commands), <code>alcMakeContextCurrent</code> is used. The context parameter can be <code>null</code>
266266 * or a valid context pointer. The operation will apply to the device that the context
267267 * was created for.
268 *
268 *
269269 * For each OS process (usually this means for each application), only one context can
270270 * be current at any given time. All AL commands apply to the current context.
271271 * Commands that affect objects shared among contexts (e.g. buffers) have side effects
277277 public static int alcMakeContextCurrent(ALCcontext context) {
278278 return nalcMakeContextCurrent(getContext(context));
279279 }
280 native static int nalcMakeContextCurrent(long context);
280 static native int nalcMakeContextCurrent(long context);
281281
282282 /**
283283 * The current context is the only context accessible to state changes by AL commands
293293 public static void alcProcessContext(ALCcontext context) {
294294 nalcProcessContext(getContext(context));
295295 }
296 native static void nalcProcessContext(long context);
296 static native void nalcProcessContext(long context);
297297
298298 /**
299299 * The application can query for, and obtain an handle to, the current context for the
306306 long context_address = nalcGetCurrentContext();
307307 if(context_address != 0) {
308308 synchronized (ALC10.contexts) {
309 context = (ALCcontext) ALC10.contexts.get(new Long(context_address));
309 context = ALC10.contexts.get(context_address);
310310 }
311311 }
312312 return context;
313313 }
314 native static long nalcGetCurrentContext();
314 static native long nalcGetCurrentContext();
315315
316316 /**
317317 * The application can query for, and obtain an handle to, the device of a given context.
323323 long device_address = nalcGetContextsDevice(getContext(context));
324324 if (device_address != 0) {
325325 synchronized (ALC10.devices) {
326 device = (ALCdevice) ALC10.devices.get(new Long(device_address));
326 device = ALC10.devices.get(device_address);
327327 }
328328 }
329329 return device;
330 }
331 native static long nalcGetContextsDevice(long context);
330 }
331 static native long nalcGetContextsDevice(long context);
332332
333333 /**
334334 * The application can suspend any context from processing (including the current
335335 * one). To indicate that a context should be suspended from processing (i.e. that
336336 * internal execution state like offset increments is not supposed to be changed), the
337337 * application has to use <code>alcSuspendContext</code>.
338 *
338 *
339339 * Repeated calls to <code>alcSuspendContext</code> are legal, and do not affect a context that is
340340 * already marked as suspended. The default state of a context created by
341341 * <code>alcCreateContext</code> is that it is marked as suspended.
345345 public static void alcSuspendContext(ALCcontext context) {
346346 nalcSuspendContext(getContext(context));
347347 }
348 native static void nalcSuspendContext(long context);
348 static native void nalcSuspendContext(long context);
349349
350350 /**
351351 * The correct way to destroy a context is to first release it using <code>alcMakeCurrent</code> and
361361 context.setInvalid();
362362 }
363363 }
364 native static void nalcDestroyContext(long context);
364 static native void nalcDestroyContext(long context);
365365
366366 /**
367367 * ALC uses the same conventions and mechanisms as AL for error handling. In
368368 * particular, ALC does not use conventions derived from X11 (GLX) or Windows
369369 * (WGL). The <code>alcGetError</code> function can be used to query ALC errors.
370 *
370 *
371371 * Error conditions are specific to the device.
372 *
372 *
373373 * ALC_NO_ERROR - The device handle or specifier does name an accessible driver/server.
374374 * <code>ALC_INVALID_DEVICE</code> - The Context argument does not name a valid context.
375375 * <code>ALC_INVALID_CONTEXT</code> - The Context argument does not name a valid context.
381381 public static int alcGetError(ALCdevice device) {
382382 return nalcGetError(getDevice(device));
383383 }
384 native static int nalcGetError(long device);
384 static native int nalcGetError(long device);
385385
386386 /**
387387 * Verify that a given extension is available for the current context and the device it
397397 Util.checkALCError(device);
398398 return result;
399399 }
400 native static boolean nalcIsExtensionPresent(long device, String extName);
400 static native boolean nalcIsExtensionPresent(long device, String extName);
401401
402402 /**
403403 * Enumeration/token values are device independend, but tokens defined for
404404 * extensions might not be present for a given device. But only the tokens defined
405405 * by the AL core are guaranteed. Availability of extension tokens dependends on the ALC extension.
406 *
406 *
407407 * Specifying a <code>null</code> name parameter will cause an <code>ALC_INVALID_VALUE</code> error.
408408 *
409409 * @param enumName name of enum to find
414414 Util.checkALCError(device);
415415 return result;
416416 }
417 native static int nalcGetEnumValue(long device, String enumName);
418
417 static native int nalcGetEnumValue(long device, String enumName);
418
419419 static long getDevice(ALCdevice device) {
420420 if(device != null) {
421421 Util.checkALCValidDevice(device);
423423 }
424424 return 0L;
425425 }
426
426
427427 static long getContext(ALCcontext context) {
428428 if(context != null) {
429429 Util.checkALCValidContext(context);
430430 return context.context;
431431 }
432432 return 0L;
433 }
433 }
434434
435435 }
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 */
4040
4141 /**
4242 * <p>
43 * The ALC11 class implements features in OpenAL 1.1, specifically
43 * The ALC11 class implements features in OpenAL 1.1, specifically
4444 * ALC methods and properties.
4545 * </p>
46 *
46 *
4747 * @author Brian Matzon <brian@matzon.dk>
4848 * @see ALC10
4949 * @version $Revision: 2286 $
5050 * $Id: ALC.java 2286 2006-03-23 19:32:21 +0000 (to, 23 mar 2006) matzon $
5151 */
5252 public final class ALC11 {
53
53
5454 public static final int ALC_DEFAULT_ALL_DEVICES_SPECIFIER = 0x1012;
5555 public static final int ALC_ALL_DEVICES_SPECIFIER = 0x1013;
56
56
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
60
6161 public static final int ALC_MONO_SOURCES = 0x1010;
6262 public static final int ALC_STEREO_SOURCES = 0x1011;
63
63
6464 /**
6565 * The alcCaptureOpenDevice function allows the application to connect to a capture
6666 * device. To obtain a list of all available capture devices, use getCaptureDevices a list of all
6767 * capture devices will be returned. Retrieving ALC_CAPTURE_DEVICE_SPECIFIER with a valid capture device specified will result
6868 * in the name of that device being returned as a single string.
69 *
69 *
7070 * If the function returns null, then no sound driver/device has been found, or the
7171 * requested format could not be fulfilled.
7272 * The "deviceName" argument is a string that requests a certain device or
8181 * implementation will set up a buffer of at least the requested size.
8282 * Specifying a compressed or extension-supplied format may result in failure, even if the
8383 * extension is supplied for rendering.
84 *
84 *
8585 * <i>LWJGL SPECIFIC: the actual created device is managed internally in lwjgl</i>
86 *
86 *
8787 * @param devicename Name of device to open for capture
8888 * @param frequency Frequency of samples to capture
8989 * @param format Format of samples to capture
9595 if(device_address != 0) {
9696 ALCdevice device = new ALCdevice(device_address);
9797 synchronized (ALC10.devices) {
98 ALC10.devices.put(new Long(device_address), device);
98 ALC10.devices.put(device_address, device);
9999 }
100100 return device;
101101 }
102102 return null;
103103 }
104104 static native long nalcCaptureOpenDevice( String devicename, int frequency, int format, int buffersize);
105
105
106106 /**
107107 * The alcCaptureCloseDevice function allows the application to disconnect from a capture
108108 * device.
109 *
109 *
110110 * The return code will be true or false, indicating success or failure. If
111111 * the device is null or invalid, an ALC_INVALID_DEVICE error will be generated.
112112 * Once closed, a capture device is invalid.
125125 /**
126126 * Once a capture device has been opened via alcCaptureOpenDevice, it is made to start
127127 * recording audio via the alcCaptureStart entry point:
128 *
128 *
129129 * Once started, the device will record audio to an internal ring buffer, the size of which was
130130 * specified when opening the device.
131131 * The application may query the capture device to discover how much data is currently
136136 nalcCaptureStart(ALC10.getDevice(device));
137137 }
138138 static native void nalcCaptureStart(long device);
139
139
140140 /**
141141 * If the application doesn't need to capture more audio for an amount of time, they can halt
142142 * the device without closing it via the alcCaptureStop entry point.
152152 /**
153153 * When the application feels there are enough samples available to process, it can obtain
154154 * them from the AL via the alcCaptureSamples entry point.
155 *
155 *
156156 * The "buffer" argument specifies an application-allocated buffer that can contain at least
157157 * "samples" sample frames. The implementation may defer conversion and resampling until
158158 * this point. Requesting more sample frames than are currently available is an error.
159 *
159 *
160160 * @param buffer Buffer to store samples in
161161 * @param samples Number of samples to request
162162 */
164164 nalcCaptureSamples(ALC10.getDevice(device), buffer, buffer.position(), samples);
165165 }
166166 static native void nalcCaptureSamples(long device, ByteBuffer buffer, int position, int samples );
167
167
168168 static native void initNativeStubs() throws LWJGLException;
169
169
170170 /**
171171 * Initializes ALC11, including any extensions
172172 * @return true if initialization was successfull
177177 ALC10.alcGetInteger(AL.getDevice(), ALC10.ALC_MAJOR_VERSION, ib);
178178 ib.position(1);
179179 ALC10.alcGetInteger(AL.getDevice(), ALC10.ALC_MINOR_VERSION, ib);
180
180
181181 int major = ib.get(0);
182182 int minor = ib.get(1);
183
184 // checking for version 1.x+
183
184 // checking for version 1.x+
185185 if(major >= 1) {
186
186
187187 // checking for version 1.1+
188188 if(major > 1 || minor >= 1) {
189189 ALC11.initNativeStubs();
190190 AL11.initNativeStubs();
191 }
191 }
192192 }
193193 } catch (LWJGLException le) {
194194 LWJGLUtil.log("failed to initialize ALC11: " + le);
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 */
3636
3737 /**
3838 * The ALCcontext class represents a context opened in OpenAL space.
39 *
39 *
4040 * All operations of the AL core API affect a current AL context. Within the scope of AL,
4141 * the ALC is implied - it is not visible as a handle or function parameter. Only one AL
4242 * Context per process can be current at a time. Applications maintaining multiple AL
4545 * AL and ALC are threadsafe.
4646 *
4747 * @author Brian Matzon <brian@matzon.dk>
48 * @version $Revision: 2983 $
49 * $Id: ALCcontext.java 2983 2008-04-07 18:36:09Z matzon $
48 * @version $Revision: 3418 $
49 * $Id: ALCcontext.java 3418 2010-09-28 21:11:35Z spasi $
5050 */
5151 public final class ALCcontext {
5252
5353 /** Address of actual context */
5454 final long context;
55
55
5656 /** Whether this context is valid */
57 private boolean valid = false;
58
59 /**
60 * Creates a new instance of ALCcontext
61 *
57 private boolean valid;
58
59 /**
60 * Creates a new instance of ALCcontext
61 *
6262 * @param context address of actual context
6363 */
6464 ALCcontext(long context) {
9696
9797 return attribList;
9898 }
99
99
100100 /**
101101 * Marks this context as invalid
102102 *
103103 */
104104 void setInvalid() {
105105 valid = false;
106 }
107
106 }
107
108108 /**
109109 * @return true if this context is still valid
110110 */
111111 public boolean isValid() {
112112 return valid;
113 }
113 }
114114 }
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 */
3535
3636 /**
3737 * The ALCdevice class represents a device opened in OpenAL space.
38 *
38 *
3939 * ALC introduces the notion of a Device. A Device can be, depending on the
4040 * implementation, a hardware device, or a daemon/OS service/actual server. This
4141 * mechanism also permits different drivers (and hardware) to coexist within the same
4444 * which has to map the available backends to unique device specifiers.
4545 *
4646 * @author Brian Matzon <brian@matzon.dk>
47 * @version $Revision: 2983 $
48 * $Id: ALCdevice.java 2983 2008-04-07 18:36:09Z matzon $
47 * @version $Revision: 3418 $
48 * $Id: ALCdevice.java 3418 2010-09-28 21:11:35Z spasi $
4949 */
5050 public final class ALCdevice {
51
51
5252 /** Address of actual device */
5353 final long device;
54
54
5555 /** Whether this device is valid */
56 private boolean valid = false;
57
56 private boolean valid;
57
5858 /** List of contexts belonging to the device */
59 private HashMap contexts = new HashMap();
60
61 /**
62 * Creates a new instance of ALCdevice
59 private final HashMap<Long, ALCcontext> contexts = new HashMap<Long, ALCcontext>();
60
61 /**
62 * Creates a new instance of ALCdevice
6363 *
6464 * @param device address of actual device
6565 */
6767 this.device = device;
6868 this.valid = true;
6969 }
70
70
7171 /*
7272 * @see java.lang.Object#equals(java.lang.Object)
7373 */
7777 }
7878 return super.equals(device);
7979 }
80
80
8181 /**
8282 * Adds a context to the device
83 *
83 *
8484 * @param context context to add to the list of contexts for this device
8585 */
8686 void addContext(ALCcontext context) {
8787 synchronized (contexts) {
88 contexts.put(new Long(context.context), context);
88 contexts.put(context.context, context);
8989 }
9090 }
91
91
9292 /**
9393 * Remove context associated with device
94 *
94 *
9595 * @param context Context to disassociate with device
9696 */
9797 void removeContext(ALCcontext context) {
9898 synchronized (contexts) {
99 contexts.remove(new Long(context.context));
100 }
101 }
99 contexts.remove(context.context);
100 }
101 }
102102
103103 /**
104104 * Marks this device and all of its contexts invalid
106106 void setInvalid() {
107107 valid = false;
108108 synchronized (contexts) {
109 for(Iterator i = contexts.values().iterator(); i.hasNext();) {
110 ALCcontext context = (ALCcontext) i.next();
109 for ( ALCcontext context : contexts.values() )
111110 context.setInvalid();
112 }
113111 }
114112 contexts.clear();
115 }
116
113 }
114
117115 /**
118116 * @return true if this device is still valid
119117 */
0 /*
0 /*
11 * Copyright (c) 2002-2010 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 package org.lwjgl.openal;
32
33 import static org.lwjgl.openal.AL10.*;
34 import static org.lwjgl.openal.EFX10.*;
3235
3336 /**
3437 * Utility class for the OpenAL extension ALC_EXT_EFX. Provides functions to check for the extension
6164 if (!AL.isCreated()) {
6265 throw new OpenALException("OpenAL has not been created.");
6366 }
64 return ALC10.alcIsExtensionPresent(AL.getDevice(), EFX10.ALC_EXT_EFX_NAME);
67 return ALC10.alcIsExtensionPresent(AL.getDevice(), ALC_EXT_EFX_NAME);
6568 }
6669
6770 /**
7780 public static boolean isEffectSupported(final int effectType) {
7881 // Make sure type is a real effect.
7982 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:
83 case AL_EFFECT_NULL:
84 case AL_EFFECT_EAXREVERB:
85 case AL_EFFECT_REVERB:
86 case AL_EFFECT_CHORUS:
87 case AL_EFFECT_DISTORTION:
88 case AL_EFFECT_ECHO:
89 case AL_EFFECT_FLANGER:
90 case AL_EFFECT_FREQUENCY_SHIFTER:
91 case AL_EFFECT_VOCAL_MORPHER:
92 case AL_EFFECT_PITCH_SHIFTER:
93 case AL_EFFECT_RING_MODULATOR:
94 case AL_EFFECT_AUTOWAH:
95 case AL_EFFECT_COMPRESSOR:
96 case AL_EFFECT_EQUALIZER:
9497 break;
9598 default:
9699 throw new IllegalArgumentException("Unknown or invalid effect type: " + effectType);
112115 public static boolean isFilterSupported(final int filterType) {
113116 // Make sure type is a real filter.
114117 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:
118 case AL_FILTER_NULL:
119 case AL_FILTER_LOWPASS:
120 case AL_FILTER_HIGHPASS:
121 case AL_FILTER_BANDPASS:
119122 break;
120123 default:
121124 throw new IllegalArgumentException("Unknown or invalid filter type: " + filterType);
147150 if (isEfxSupported()) {
148151
149152 // Try to create object in order to check AL's response.
150 AL10.alGetError();
153 alGetError();
151154 int genError;
152155 int testObject = 0;
153156 try {
154157 switch (objectType) { // Create object based on type
155158 case EFFECT:
156 testObject = EFX10.alGenEffects();
159 testObject = alGenEffects();
157160 break;
158161 case FILTER:
159 testObject = EFX10.alGenFilters();
162 testObject = alGenFilters();
160163 break;
161164 default:
162165 throw new IllegalArgumentException("Invalid objectType: " + objectType);
163166 }
164 genError = AL10.alGetError();
167 genError = alGetError();
165168 } catch (final OpenALException debugBuildException) {
166169 // Hack because OpenALException hides the original error code (short of parsing the
167170 // error message String which would break if it gets changed).
168171 if (debugBuildException.getMessage().contains("AL_OUT_OF_MEMORY")) {
169 genError = AL10.AL_OUT_OF_MEMORY;
172 genError = AL_OUT_OF_MEMORY;
170173 } else {
171 genError = AL10.AL_INVALID_OPERATION;
174 genError = AL_INVALID_OPERATION;
172175 }
173176 }
174177
175 if (genError == AL10.AL_NO_ERROR) {
178 if (genError == AL_NO_ERROR) {
176179 // Successfully created, now try to set type.
177 AL10.alGetError();
180 alGetError();
178181 int setError;
179182 try {
180183 switch (objectType) { // Set based on object type
181184 case EFFECT:
182 EFX10.alEffecti(testObject, EFX10.AL_EFFECT_TYPE, typeValue);
185 alEffecti(testObject, AL_EFFECT_TYPE, typeValue);
183186 break;
184187 case FILTER:
185 EFX10.alFilteri(testObject, EFX10.AL_FILTER_TYPE, typeValue);
188 alFilteri(testObject, AL_FILTER_TYPE, typeValue);
186189 break;
187190 default:
188191 throw new IllegalArgumentException("Invalid objectType: " + objectType);
189192 }
190 setError = AL10.alGetError();
193 setError = alGetError();
191194 } catch (final OpenALException debugBuildException) {
192195 // Hack because OpenALException hides the original error code (short of parsing
193196 // 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) {
197 setError = AL_INVALID_VALUE;
198 }
199
200 if (setError == AL_NO_ERROR) {
198201 supported = true;
199202 }
200203
202205 try {
203206 switch (objectType) { // Set based on object type
204207 case EFFECT:
205 EFX10.alDeleteEffects(testObject);
208 alDeleteEffects(testObject);
206209 break;
207210 case FILTER:
208 EFX10.alDeleteFilters(testObject);
211 alDeleteFilters(testObject);
209212 break;
210213 default:
211214 throw new IllegalArgumentException("Invalid objectType: " + objectType);
214217 // Don't care about cleanup errors.
215218 }
216219
217 } else if (genError == AL10.AL_OUT_OF_MEMORY) {
220 } else if (genError == AL_OUT_OF_MEMORY) {
218221 throw new OpenALException(genError);
219222 }
220223 }
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.opencl;
32
33 import org.lwjgl.BufferUtils;
34 import org.lwjgl.LWJGLUtil;
35 import org.lwjgl.PointerBuffer;
36 import org.lwjgl.opencl.FastLongMap.Entry;
37
38 import java.nio.*;
39 import java.util.HashSet;
40 import java.util.Set;
41 import java.util.StringTokenizer;
42
43 import static org.lwjgl.opencl.APPLEGLSharing.*;
44 import static org.lwjgl.opencl.CL10.*;
45 import static org.lwjgl.opencl.EXTDeviceFission.*;
46 import static org.lwjgl.opencl.KHRGLSharing.*;
47
48 /**
49 * Utility class for OpenCL API calls.
50 *
51 * @author spasi
52 */
53 final class APIUtil {
54
55 private static final int INITIAL_BUFFER_SIZE = 256;
56 private static final int INITIAL_LENGTHS_SIZE = 4;
57
58 private static final int BUFFERS_SIZE = 32;
59
60 private static final ThreadLocal<char[]> arrayTL = new ThreadLocal<char[]>() {
61 protected char[] initialValue() { return new char[INITIAL_BUFFER_SIZE]; }
62 };
63
64 private static final ThreadLocal<ByteBuffer> bufferByteTL = new ThreadLocal<ByteBuffer>() {
65 protected ByteBuffer initialValue() { return BufferUtils.createByteBuffer(INITIAL_BUFFER_SIZE); }
66 };
67
68 private static final ThreadLocal<PointerBuffer> bufferPointerTL = new ThreadLocal<PointerBuffer>() {
69 protected PointerBuffer initialValue() { return BufferUtils.createPointerBuffer(INITIAL_BUFFER_SIZE); }
70 };
71
72 private static final ThreadLocal<PointerBuffer> lengthsTL = new ThreadLocal<PointerBuffer>() {
73 protected PointerBuffer initialValue() { return BufferUtils.createPointerBuffer(INITIAL_LENGTHS_SIZE); }
74 };
75
76 private static final ThreadLocal<Buffers> buffersTL = new ThreadLocal<Buffers>() {
77 protected Buffers initialValue() { return new Buffers(); }
78 };
79
80 private APIUtil() {
81 }
82
83 private static char[] getArray(final int size) {
84 char[] array = arrayTL.get();
85
86 if ( array.length < size ) {
87 int sizeNew = array.length << 1;
88 while ( sizeNew < size )
89 sizeNew <<= 1;
90
91 array = new char[size];
92 arrayTL.set(array);
93 }
94
95 return array;
96 }
97
98 static ByteBuffer getBufferByte(final int size) {
99 ByteBuffer buffer = bufferByteTL.get();
100
101 if ( buffer.capacity() < size ) {
102 int sizeNew = buffer.capacity() << 1;
103 while ( sizeNew < size )
104 sizeNew <<= 1;
105
106 buffer = BufferUtils.createByteBuffer(size);
107 bufferByteTL.set(buffer);
108 } else
109 buffer.clear();
110
111 return buffer;
112 }
113
114 private static ByteBuffer getBufferByteOffset(final int size) {
115 ByteBuffer buffer = bufferByteTL.get();
116
117 if ( buffer.capacity() < size ) {
118 int sizeNew = buffer.capacity() << 1;
119 while ( sizeNew < size )
120 sizeNew <<= 1;
121
122 final ByteBuffer bufferNew = BufferUtils.createByteBuffer(size);
123 bufferNew.put(buffer);
124 bufferByteTL.set(buffer = bufferNew);
125 } else {
126 buffer.position(buffer.limit());
127 buffer.limit(buffer.capacity());
128 }
129
130 return buffer;
131 }
132
133 static PointerBuffer getBufferPointer(final int size) {
134 PointerBuffer buffer = bufferPointerTL.get();
135
136 if ( buffer.capacity() < size ) {
137 int sizeNew = buffer.capacity() << 1;
138 while ( sizeNew < size )
139 sizeNew <<= 1;
140
141 buffer = BufferUtils.createPointerBuffer(size);
142 bufferPointerTL.set(buffer);
143 } else
144 buffer.clear();
145
146 return buffer;
147 }
148
149 static ShortBuffer getBufferShort() { return buffersTL.get().shorts; }
150
151 static IntBuffer getBufferInt() { return buffersTL.get().ints; }
152
153 static IntBuffer getBufferIntDebug() { return buffersTL.get().intsDebug; }
154
155 static LongBuffer getBufferLong() { return buffersTL.get().longs; }
156
157 static FloatBuffer getBufferFloat() { return buffersTL.get().floats; }
158
159 static DoubleBuffer getBufferDouble() { return buffersTL.get().doubles; }
160
161 static PointerBuffer getBufferPointer() { return buffersTL.get().pointers; }
162
163 static PointerBuffer getLengths() {
164 return getLengths(1);
165 }
166
167 static PointerBuffer getLengths(final int size) {
168 PointerBuffer lengths = lengthsTL.get();
169
170 if ( lengths.capacity() < size ) {
171 int sizeNew = lengths.capacity();
172 while ( sizeNew < size )
173 sizeNew <<= 1;
174
175 lengths = BufferUtils.createPointerBuffer(size);
176 lengthsTL.set(lengths);
177 } else
178 lengths.clear();
179
180 return lengths;
181 }
182
183 /**
184 * Simple ASCII encoding.
185 *
186 * @param buffer The target buffer
187 * @param string The source string
188 */
189 private static ByteBuffer encode(final ByteBuffer buffer, final CharSequence string) {
190 for ( int i = 0; i < string.length(); i++ ) {
191 final char c = string.charAt(i);
192 if ( LWJGLUtil.DEBUG && 0x80 <= c ) // Silently ignore and map to 0x1A.
193 buffer.put((byte)0x1A);
194 else
195 buffer.put((byte)c);
196 }
197
198 return buffer;
199 }
200
201 /**
202 * Reads a byte string from the specified buffer.
203 *
204 * @param buffer
205 *
206 * @return the buffer as a String.
207 */
208 static String getString(final ByteBuffer buffer) {
209 final int length = buffer.remaining();
210 final char[] charArray = getArray(length);
211
212 for ( int i = buffer.position(); i < buffer.limit(); i++ )
213 charArray[i - buffer.position()] = (char)buffer.get(i);
214
215 return new String(charArray, 0, length);
216 }
217
218 /**
219 * Returns a buffer containing the specified string as bytes.
220 *
221 * @param string
222 *
223 * @return the String as a ByteBuffer
224 */
225 static ByteBuffer getBuffer(final CharSequence string) {
226 final ByteBuffer buffer = encode(getBufferByte(string.length()), string);
227 buffer.flip();
228 return buffer;
229 }
230
231 /**
232 * Returns a buffer containing the specified string as bytes, starting at the specified offset.
233 *
234 * @param string
235 *
236 * @return the String as a ByteBuffer
237 */
238 static ByteBuffer getBuffer(final CharSequence string, final int offset) {
239 final ByteBuffer buffer = encode(getBufferByteOffset(offset + string.length()), string);
240 buffer.flip();
241 return buffer;
242 }
243
244 /**
245 * Returns a buffer containing the specified string as bytes, including null-termination.
246 *
247 * @param string
248 *
249 * @return the String as a ByteBuffer
250 */
251 static ByteBuffer getBufferNT(final CharSequence string) {
252 final ByteBuffer buffer = encode(getBufferByte(string.length() + 1), string);
253 buffer.put((byte)0);
254 buffer.flip();
255 return buffer;
256 }
257
258 static int getTotalLength(final CharSequence[] strings) {
259 int length = 0;
260 for ( CharSequence string : strings )
261 length += string.length();
262
263 return length;
264 }
265
266 /**
267 * Returns a buffer containing the specified strings as bytes.
268 *
269 * @param strings
270 *
271 * @return the Strings as a ByteBuffer
272 */
273 static ByteBuffer getBuffer(final CharSequence[] strings) {
274 final ByteBuffer buffer = getBufferByte(getTotalLength(strings));
275
276 for ( CharSequence string : strings )
277 encode(buffer, string);
278
279 buffer.flip();
280 return buffer;
281 }
282
283 /**
284 * Returns a buffer containing the specified strings as bytes, including null-termination.
285 *
286 * @param strings
287 *
288 * @return the Strings as a ByteBuffer
289 */
290 static ByteBuffer getBufferNT(final CharSequence[] strings) {
291 final ByteBuffer buffer = getBufferByte(getTotalLength(strings) + strings.length);
292
293 for ( CharSequence string : strings ) {
294 encode(buffer, string);
295 buffer.put((byte)0);
296 }
297
298 buffer.flip();
299 return buffer;
300 }
301
302 /**
303 * Returns a buffer containing the lengths of the specified strings.
304 *
305 * @param strings
306 *
307 * @return the String lengths in a PointerBuffer
308 */
309 static PointerBuffer getLengths(final CharSequence[] strings) {
310 PointerBuffer buffer = getLengths(strings.length);
311
312 for ( CharSequence string : strings )
313 buffer.put(string.length());
314
315 buffer.flip();
316 return buffer;
317 }
318
319 /**
320 * Returns a buffer containing the lengths of the specified buffers.
321 *
322 * @param buffers the buffer array
323 *
324 * @return the buffer lengths in a PointerBuffer
325 */
326 static PointerBuffer getLengths(final ByteBuffer[] buffers) {
327 PointerBuffer lengths = getLengths(buffers.length);
328
329 for ( ByteBuffer buffer : buffers )
330 lengths.put(buffer.remaining());
331
332 lengths.flip();
333 return lengths;
334 }
335
336 static int getSize(final PointerBuffer lengths) {
337 long size = 0;
338 for ( int i = lengths.position(); i < lengths.limit(); i++ )
339 size += lengths.get(i);
340
341 return (int)size;
342 }
343
344 private static class Buffers {
345
346 final ShortBuffer shorts;
347 final IntBuffer ints;
348 final IntBuffer intsDebug;
349 final LongBuffer longs;
350
351 final FloatBuffer floats;
352 final DoubleBuffer doubles;
353
354 final PointerBuffer pointers;
355
356 Buffers() {
357 shorts = BufferUtils.createShortBuffer(BUFFERS_SIZE);
358 ints = BufferUtils.createIntBuffer(BUFFERS_SIZE);
359 intsDebug = BufferUtils.createIntBuffer(1);
360 longs = BufferUtils.createLongBuffer(BUFFERS_SIZE);
361
362 floats = BufferUtils.createFloatBuffer(BUFFERS_SIZE);
363 doubles = BufferUtils.createDoubleBuffer(BUFFERS_SIZE);
364
365 pointers = BufferUtils.createPointerBuffer(BUFFERS_SIZE);
366 }
367
368 }
369
370 /* ------------------------------------------------------------------------
371 ---------------------------------------------------------------------------
372 OPENCL API UTILITIES BELOW
373 ---------------------------------------------------------------------------
374 ------------------------------------------------------------------------ */
375
376 static Set<String> getExtensions(final String extensionList) {
377 final Set<String> extensions = new HashSet<String>();
378
379 if ( extensionList != null ) {
380 final StringTokenizer tokenizer = new StringTokenizer(extensionList);
381 while ( tokenizer.hasMoreTokens() )
382 extensions.add(tokenizer.nextToken());
383 }
384
385 return extensions;
386 }
387
388 static boolean isDevicesParam(final int param_name) {
389 switch ( param_name ) {
390 case CL_CONTEXT_DEVICES:
391 case CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR:
392 case CL_DEVICES_FOR_GL_CONTEXT_KHR:
393 case CL_CGL_DEVICE_FOR_CURRENT_VIRTUAL_SCREEN_APPLE:
394 case CL_CGL_DEVICES_FOR_SUPPORTED_VIRTUAL_SCREENS_APPLE:
395 return true;
396 }
397
398 return false;
399 }
400
401 static CLPlatform getCLPlatform(final PointerBuffer properties) {
402 long platformID = 0;
403
404 final int keys = properties.remaining() / 2;
405 for ( int k = 0; k < keys; k++ ) {
406 final long key = properties.get(k << 1);
407 if ( key == 0 )
408 break;
409
410 if ( key == CL_CONTEXT_PLATFORM ) {
411 platformID = properties.get((k << 1) + 1);
412 break;
413 }
414 }
415
416 if ( platformID == 0 )
417 throw new IllegalArgumentException("Could not find CL_CONTEXT_PLATFORM in cl_context_properties.");
418
419 final CLPlatform platform = CLPlatform.getCLPlatform(platformID);
420 if ( platform == null )
421 throw new IllegalStateException("Could not find a valid CLPlatform. Make sure clGetPlatformIDs has been used before.");
422
423 return platform;
424 }
425
426 static ByteBuffer getNativeKernelArgs(final long user_func_ref, final CLMem[] clMems, final long[] sizes) {
427 final ByteBuffer args = getBufferByte(8 + 4 + (clMems == null ? 0 : clMems.length * (4 + PointerBuffer.getPointerSize())));
428
429 args.putLong(0, user_func_ref);
430 if ( clMems == null )
431 args.putInt(8, 0);
432 else {
433 args.putInt(8, clMems.length);
434 int byteIndex = 12;
435 for ( int i = 0; i < clMems.length; i++ ) {
436 if ( LWJGLUtil.DEBUG && !clMems[i].isValid() )
437 throw new IllegalArgumentException("An invalid CLMem object was specified.");
438 args.putInt(byteIndex, (int)sizes[i]); // CLMem size
439 byteIndex += (4 + PointerBuffer.getPointerSize()); // Skip size and make room for the pointer
440 }
441 }
442
443 return args;
444 }
445
446 // ------------------------------------------------------------------------------------
447
448 /**
449 * Releases all sub-devices created from the specified CLDevice.
450 *
451 * @param device the CLDevice to clear
452 */
453 static void releaseObjects(final CLDevice device) {
454 // Release objects only if we're about to hit 0.
455 if ( device.getReferenceCount() > 1 )
456 return;
457
458 releaseObjects(device.getSubCLDeviceRegistry(), DESTRUCTOR_CLSubDevice);
459 }
460
461 /**
462 * Releases all objects contained in the specified CLContext.
463 *
464 * @param context the CLContext to clear
465 */
466 static void releaseObjects(final CLContext context) {
467 // Release objects only if we're about to hit 0.
468 if ( context.getReferenceCount() > 1 )
469 return;
470
471 releaseObjects(context.getCLEventRegistry(), DESTRUCTOR_CLEvent);
472 releaseObjects(context.getCLProgramRegistry(), DESTRUCTOR_CLProgram);
473 releaseObjects(context.getCLSamplerRegistry(), DESTRUCTOR_CLSampler);
474 releaseObjects(context.getCLMemRegistry(), DESTRUCTOR_CLMem);
475 releaseObjects(context.getCLCommandQueueRegistry(), DESTRUCTOR_CLCommandQueue);
476 }
477
478 /**
479 * Releases all objects contained in the specified CLProgram.
480 *
481 * @param program the CLProgram to clear
482 */
483 static void releaseObjects(final CLProgram program) {
484 // Release objects only if we're about to hit 0.
485 if ( program.getReferenceCount() > 1 )
486 return;
487
488 releaseObjects(program.getCLKernelRegistry(), DESTRUCTOR_CLKernel);
489 }
490
491 /**
492 * Releases all objects contained in the specified CLCommandQueue.
493 *
494 * @param queue the CLCommandQueue to clear
495 */
496 static void releaseObjects(final CLCommandQueue queue) {
497 // Release objects only if we're about to hit 0.
498 if ( queue.getReferenceCount() > 1 )
499 return;
500
501 releaseObjects(queue.getCLEventRegistry(), DESTRUCTOR_CLEvent);
502 }
503
504 private static <T extends CLObjectChild> void releaseObjects(final CLObjectRegistry<T> registry, final ObjectDestructor<T> destructor) {
505 if ( registry.isEmpty() )
506 return;
507
508 for ( Entry<T> entry : registry.getAll() ) {
509 final T object = entry.value;
510 while ( object.isValid() )
511 destructor.release(object);
512 }
513 }
514
515 private static final ObjectDestructor<CLDevice> DESTRUCTOR_CLSubDevice = new ObjectDestructor<CLDevice>() {
516 public void release(final CLDevice object) { clReleaseDeviceEXT(object); }
517 };
518 private static final ObjectDestructor<CLMem> DESTRUCTOR_CLMem = new ObjectDestructor<CLMem>() {
519 public void release(final CLMem object) { clReleaseMemObject(object); }
520 };
521 private static final ObjectDestructor<CLCommandQueue> DESTRUCTOR_CLCommandQueue = new ObjectDestructor<CLCommandQueue>() {
522 public void release(final CLCommandQueue object) { clReleaseCommandQueue(object); }
523 };
524 private static final ObjectDestructor<CLSampler> DESTRUCTOR_CLSampler = new ObjectDestructor<CLSampler>() {
525 public void release(final CLSampler object) { clReleaseSampler(object); }
526 };
527 private static final ObjectDestructor<CLProgram> DESTRUCTOR_CLProgram = new ObjectDestructor<CLProgram>() {
528 public void release(final CLProgram object) { clReleaseProgram(object); }
529 };
530 private static final ObjectDestructor<CLKernel> DESTRUCTOR_CLKernel = new ObjectDestructor<CLKernel>() {
531 public void release(final CLKernel object) { clReleaseKernel(object); }
532 };
533 private static final ObjectDestructor<CLEvent> DESTRUCTOR_CLEvent = new ObjectDestructor<CLEvent>() {
534 public void release(final CLEvent object) { clReleaseEvent(object); }
535 };
536
537 private interface ObjectDestructor<T extends CLObjectChild> {
538
539 void release(T object);
540
541 }
542
543 }
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.opencl;
32
33 import java.nio.ByteBuffer;
34
35 /**
36 * Utility class that provides CLContextCallback implementations that use
37 * the APPLE_ContextLoggingFunctions callback functions.
38 * <p/>
39 * TODO: Test this class
40 *
41 * @author Spasi
42 */
43 public final class APPLEContextLoggingUtil {
44
45 /** Sends all log messages to the Apple System Logger. */
46 public static final CLContextCallback SYSTEM_LOG_CALLBACK;
47
48 /** Sends all log messages to the file descriptor stdout. */
49 public static final CLContextCallback STD_OUT_CALLBACK;
50
51 /** Sends all log messages to the file descriptor stderr. */
52 public static final CLContextCallback STD_ERR_CALLBACK;
53
54 static {
55 if ( CLCapabilities.CL_APPLE_ContextLoggingFunctions ) {
56 SYSTEM_LOG_CALLBACK = new CLContextCallback(CallbackUtil.getLogMessageToSystemLogAPPLE()) {
57 protected void handleMessage(final String errinfo, final ByteBuffer private_info) { throw new UnsupportedOperationException(); }
58 };
59
60 STD_OUT_CALLBACK = new CLContextCallback(CallbackUtil.getLogMessageToStdoutAPPLE()) {
61 protected void handleMessage(final String errinfo, final ByteBuffer private_info) { throw new UnsupportedOperationException(); }
62 };
63
64 STD_ERR_CALLBACK = new CLContextCallback(CallbackUtil.getLogMessageToStderrAPPLE()) {
65 protected void handleMessage(final String errinfo, final ByteBuffer private_info) { throw new UnsupportedOperationException(); }
66 };
67 } else {
68 SYSTEM_LOG_CALLBACK = null;
69 STD_OUT_CALLBACK = null;
70 STD_ERR_CALLBACK = null;
71 }
72 }
73
74 private APPLEContextLoggingUtil() {}
75
76 }
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.opencl;
32
33 import org.lwjgl.LWJGLException;
34 import org.lwjgl.LWJGLUtil;
35 import org.lwjgl.Sys;
36
37 import java.nio.ByteBuffer;
38
39 /**
40 * LWJGL users must use this class to initialize OpenCL
41 * before using any other class in the org.lwjgl.opencl package.
42 *
43 * @author Spasi
44 */
45 public final class CL {
46
47 private static boolean created;
48
49 static {
50 Sys.initialize();
51 }
52
53 private CL() {
54 }
55
56 /**
57 * Native method to create CL instance
58 *
59 * @param oclPaths Array of strings containing paths to search for OpenCL library
60 */
61 private static native void nCreate(String oclPaths) throws LWJGLException;
62
63 /**
64 * Native method to create CL instance from the Mac OS X 10.4 OpenCL framework.
65 * It is only defined in the Mac OS X native library.
66 */
67 private static native void nCreateDefault() throws LWJGLException;
68
69 /** Native method the destroy the CL */
70 private static native void nDestroy();
71
72 /** @return true if CL has been created */
73 public static boolean isCreated() {
74 return created;
75 }
76
77 public static void create() throws LWJGLException {
78 if ( created )
79 return;
80 //throw new IllegalStateException("OpenCL has already been created.");
81
82 final String libname;
83 final String[] library_names;
84 switch ( LWJGLUtil.getPlatform() ) {
85 case LWJGLUtil.PLATFORM_WINDOWS:
86 libname = "OpenCL";
87 library_names = new String[] { "OpenCL.dll" };
88 break;
89 case LWJGLUtil.PLATFORM_LINUX:
90 libname = "OpenCL";
91 library_names = new String[] { "libOpenCL64.so", "libOpenCL.so" }; // TODO: Fix this
92 break;
93 case LWJGLUtil.PLATFORM_MACOSX:
94 libname = "OpenCL";
95 library_names = new String[] { "OpenCL.dylib" }; // TODO: Fix this
96 break;
97 default:
98 throw new LWJGLException("Unknown platform: " + LWJGLUtil.getPlatform());
99 }
100
101 final String[] oclPaths = LWJGLUtil.getLibraryPaths(libname, library_names, CL.class.getClassLoader());
102 LWJGLUtil.log("Found " + oclPaths.length + " OpenCL paths");
103 for ( String oclPath : oclPaths ) {
104 try {
105 nCreate(oclPath);
106 created = true;
107 break;
108 } catch (LWJGLException e) {
109 LWJGLUtil.log("Failed to load " + oclPath + ": " + e.getMessage());
110 }
111 }
112
113 if ( !created && LWJGLUtil.getPlatform() == LWJGLUtil.PLATFORM_MACOSX ) {
114 // Try to load OpenCL from the framework instead
115 nCreateDefault();
116 created = true;
117 }
118
119 if ( !created )
120 throw new LWJGLException("Could not locate OpenCL library.");
121
122 if ( !CLCapabilities.OpenCL10 )
123 throw new RuntimeException("OpenCL 1.0 not supported.");
124 }
125
126 public static void destroy() {
127 }
128
129 /**
130 * Helper method to get a pointer to a named function with aliases in the OpenCL library.
131 *
132 * @param aliases the function name aliases.
133 *
134 * @return the function pointer address
135 */
136 static long getFunctionAddress(String[] aliases) {
137 for ( String aliase : aliases ) {
138 long address = getFunctionAddress(aliase);
139 if ( address != 0 )
140 return address;
141 }
142 return 0;
143 }
144
145 static native long getFunctionAddress(String name);
146
147 static native ByteBuffer getHostBuffer(final long address, final int size);
148
149 private static native void resetNativeStubs(Class clazz);
150
151 }
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.opencl;
32
33 /**
34 * Instances of this class can be used to receive OpenCL program build notifications.
35 *
36 * @author Spasi
37 */
38 public abstract class CLBuildProgramCallback extends CLCallback {
39
40 protected CLBuildProgramCallback() {
41 super(CallbackUtil.getBuildProgramCallback());
42 }
43
44 /**
45 * Called from native code.
46 *
47 * @param program_address the CLProgram object pointer
48 */
49 private void handleMessage(long program_address) {
50 handleMessage(CLContext.getCLProgramGlobal(program_address));
51 }
52
53 /**
54 * The callback method.
55 *
56 * @param program the CLProgram object that was built
57 */
58 protected abstract void handleMessage(CLProgram program);
59
60 }
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.opencl;
32
33 import org.lwjgl.PointerWrapperAbstract;
34
35 /**
36 * Base class for OpenCL callback objects.
37 *
38 * @author Spasi
39 */
40 abstract class CLCallback extends PointerWrapperAbstract {
41
42 private final boolean custom;
43
44 protected CLCallback(final long pointer) {
45 this(pointer, false);
46 }
47
48 protected CLCallback(final long pointer, final boolean custom) {
49 super(pointer);
50
51 this.custom = custom;
52 }
53
54 final boolean isCustom() {
55 return custom;
56 }
57
58 }
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.opencl;
32
33 import org.lwjgl.LWJGLUtil;
34 import org.lwjgl.PointerBuffer;
35
36 import java.nio.ByteBuffer;
37
38 import static org.lwjgl.opencl.CL10.*;
39 import static org.lwjgl.opencl.CL11.*;
40
41 /**
42 * Utility class that provides runtime checks for OpenCL method calls.
43 * TODO: Revisit this when Java 7.0 is released, there will be new Buffer API with 64bit indices/sizes.
44 *
45 * @author Spasi
46 */
47 final class CLChecks {
48
49 private CLChecks() {
50 }
51
52 /**
53 * Calculates the number of bytes in the specified cl_mem buffer rectangle region.
54 *
55 * @param origin the host origin
56 * @param region the rectangle region
57 * @param row_pitch the host row pitch
58 * @param slice_pitch the host slice pitch
59 *
60 * @return the region size in bytes
61 */
62 static int calculateBufferRectSize(final PointerBuffer origin, final PointerBuffer region, long row_pitch, long slice_pitch) {
63 if ( !LWJGLUtil.CHECKS )
64 return 0;
65
66 final long x = origin.get(0);
67 final long y = origin.get(1);
68 final long z = origin.get(2);
69
70 if ( LWJGLUtil.DEBUG && (x < 0 || y < 0 || z < 0) )
71 throw new IllegalArgumentException("Invalid cl_mem host origin: " + x + ", " + y + ", " + z);
72
73 final long w = region.get(0);
74 final long h = region.get(1);
75 final long d = region.get(2);
76
77 if ( LWJGLUtil.DEBUG && (w < 1 || h < 1 || d < 1) )
78 throw new IllegalArgumentException("Invalid cl_mem rectangle region dimensions: " + w + " x " + h + " x " + d);
79
80 if ( row_pitch == 0 )
81 row_pitch = w;
82 else if ( LWJGLUtil.DEBUG && row_pitch < w )
83 throw new IllegalArgumentException("Invalid host row pitch specified: " + row_pitch);
84
85 if ( slice_pitch == 0 )
86 slice_pitch = row_pitch * h;
87 else if ( LWJGLUtil.DEBUG && slice_pitch < (row_pitch * h) )
88 throw new IllegalArgumentException("Invalid host slice pitch specified: " + slice_pitch);
89
90 return (int)((z * slice_pitch + y * row_pitch + x) + (w * h * d));
91 }
92
93 /**
94 * Calculates the number of bytes in the specified cl_mem image region.
95 * This implementation assumes 1 byte per element, because we cannot the
96 * image type.
97 *
98 * @param region the image region
99 * @param row_pitch the row pitch
100 * @param slice_pitch the slice pitch
101 *
102 * @return the region size in bytes
103 */
104 static int calculateImageSize(final PointerBuffer region, long row_pitch, long slice_pitch) {
105 if ( !LWJGLUtil.CHECKS )
106 return 0;
107
108 final long w = region.get(0);
109 final long h = region.get(1);
110 final long d = region.get(2);
111
112 if ( LWJGLUtil.DEBUG && (w < 1 || h < 1 || d < 1) )
113 throw new IllegalArgumentException("Invalid cl_mem image region dimensions: " + w + " x " + h + " x " + d);
114
115 if ( row_pitch == 0 )
116 row_pitch = w;
117 else if ( LWJGLUtil.DEBUG && row_pitch < w )
118 throw new IllegalArgumentException("Invalid row pitch specified: " + row_pitch);
119
120 if ( slice_pitch == 0 )
121 slice_pitch = row_pitch * h;
122 else if ( LWJGLUtil.DEBUG && slice_pitch < (row_pitch * h) )
123 throw new IllegalArgumentException("Invalid slice pitch specified: " + slice_pitch);
124
125 return (int)(slice_pitch * d);
126
127 }
128
129 /**
130 * Calculates the number of bytes in the specified 2D image.
131 *
132 * @param format the cl_image_format struct
133 * @param w the image width
134 * @param h the image height
135 * @param row_pitch the image row pitch
136 *
137 * @return the 2D image size in bytes
138 */
139 static int calculateImage2DSize(final ByteBuffer format, final long w, final long h, long row_pitch) {
140 if ( !LWJGLUtil.CHECKS )
141 return 0;
142
143 if ( LWJGLUtil.DEBUG && (w < 1 || h < 1) )
144 throw new IllegalArgumentException("Invalid 2D image dimensions: " + w + " x " + h);
145
146 final int elementSize = getElementSize(format);
147
148 if ( row_pitch == 0 )
149 row_pitch = w * elementSize;
150 else if ( LWJGLUtil.DEBUG && ((row_pitch < w * elementSize) || (row_pitch % elementSize != 0)) )
151 throw new IllegalArgumentException("Invalid image_row_pitch specified: " + row_pitch);
152
153 return (int)(row_pitch * h);
154 }
155
156 /**
157 * Calculates the number of bytes in the specified 3D image.
158 *
159 * @param format the cl_image_format struct
160 * @param w the image width
161 * @param h the image height
162 * @param d the image depth
163 * @param row_pitch the image row pitch
164 * @param slice_pitch the image slice pitch
165 *
166 * @return the 3D image size in bytes
167 */
168 static int calculateImage3DSize(final ByteBuffer format, final long w, final long h, final long d, long row_pitch, long slice_pitch) {
169 if ( !LWJGLUtil.CHECKS )
170 return 0;
171
172 if ( LWJGLUtil.DEBUG && (w < 1 || h < 1 || d < 2) )
173 throw new IllegalArgumentException("Invalid 3D image dimensions: " + w + " x " + h + " x " + d);
174
175 final int elementSize = getElementSize(format);
176
177 if ( row_pitch == 0 )
178 row_pitch = w * elementSize;
179 else if ( LWJGLUtil.DEBUG && ((row_pitch < w * elementSize) || (row_pitch % elementSize != 0)) )
180 throw new IllegalArgumentException("Invalid image_row_pitch specified: " + row_pitch);
181
182 if ( slice_pitch == 0 )
183 slice_pitch = row_pitch * h;
184 else if ( LWJGLUtil.DEBUG && ((row_pitch < row_pitch * h) || (slice_pitch % row_pitch != 0)) )
185 throw new IllegalArgumentException("Invalid image_slice_pitch specified: " + row_pitch);
186
187 return (int)(slice_pitch * d);
188 }
189
190 /**
191 * Returns the number of bytes per element for the specified image format.
192 *
193 * @param format a cl_image_format struct.
194 *
195 * @return the number of bytes per image element
196 */
197 private static int getElementSize(final ByteBuffer format) {
198 final int channelOrder = format.getInt(format.position() + 0);
199 final int channelType = format.getInt(format.position() + 4);
200
201 return getChannelCount(channelOrder) * getChannelSize(channelType);
202 }
203
204 /**
205 * Returns the number of channels in the specified cl_channel_order.
206 *
207 * @param channelOrder the cl_channel_order
208 *
209 * @return the number of channels
210 */
211 private static int getChannelCount(final int channelOrder) {
212 switch ( channelOrder ) {
213 case CL_R:
214 case CL_A:
215 case CL_INTENSITY:
216 case CL_LUMINANCE:
217 case CL_Rx:
218 return 1;
219 case CL_RG:
220 case CL_RA:
221 case CL_RGx:
222 return 2;
223 case CL_RGB:
224 case CL_RGBx:
225 return 3;
226 case CL_RGBA:
227 case CL_BGRA:
228 case CL_ARGB:
229 return 4;
230 default:
231 throw new IllegalArgumentException("Invalid cl_channel_order specified: " + LWJGLUtil.toHexString(channelOrder));
232 }
233 }
234
235 /**
236 * Returns the number of bytes in the specified cl_channel_type.
237 *
238 * @param channelType the cl_channel_type
239 *
240 * @return the number of bytes
241 */
242 private static int getChannelSize(final int channelType) {
243 switch ( channelType ) {
244 case CL_SNORM_INT8:
245 case CL_UNORM_INT8:
246 case CL_SIGNED_INT8:
247 case CL_UNSIGNED_INT8:
248 return 1;
249 case CL_SNORM_INT16:
250 case CL_UNORM_INT16:
251 case CL_UNORM_SHORT_565:
252 case CL_UNORM_SHORT_555:
253 case CL_SIGNED_INT16:
254 case CL_UNSIGNED_INT16:
255 case CL_HALF_FLOAT:
256 return 2;
257 case CL_UNORM_INT_101010:
258 case CL_SIGNED_INT32:
259 case CL_UNSIGNED_INT32:
260 case CL_FLOAT:
261 return 4;
262 default:
263 throw new IllegalArgumentException("Invalid cl_channel_type specified: " + LWJGLUtil.toHexString(channelType));
264 }
265 }
266
267 }
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.opencl;
32
33 import org.lwjgl.PointerBuffer;
34
35 /**
36 * This class is a wrapper around a cl_command_queue pointer.
37 *
38 * @author Spasi
39 */
40 public final class CLCommandQueue extends CLObjectChild<CLContext> {
41
42 private static final InfoUtil<CLCommandQueue> util = CLPlatform.getInfoUtilInstance(CLCommandQueue.class, "CL_COMMAND_QUEUE_UTIL");
43
44 private final CLDevice device;
45
46 private final CLObjectRegistry<CLEvent> clEvents;
47
48 CLCommandQueue(final long pointer, final CLContext context, final CLDevice device) {
49 super(pointer, context);
50 if ( isValid() ) {
51 this.device = device;
52 this.clEvents = new CLObjectRegistryGlobal<CLEvent>(CLContext.clEventsGlobal);
53 context.getCLCommandQueueRegistry().registerObject(this);
54 } else {
55 this.device = null;
56 this.clEvents = null;
57 }
58 }
59
60 public CLDevice getCLDevice() {
61 return device;
62 }
63
64 /**
65 * Returns a CLEvent associated with this command-queue.
66 *
67 * @param id the event object id
68 *
69 * @return the CLEvent object
70 */
71 public CLEvent getCLEvent(final long id) {
72 return clEvents.getObject(id);
73 }
74
75 // ---------------[ UTILITY METHODS ]---------------
76
77 /**
78 * Returns the integer value of the specified parameter.
79 *
80 * @param param_name the parameter
81 *
82 * @return the parameter value
83 */
84 public int getInfoInt(int param_name) {
85 return util.getInfoInt(this, param_name);
86 }
87
88 // -------[ IMPLEMENTATION STUFF BELOW ]-------
89
90 CLObjectRegistry<CLEvent> getCLEventRegistry() { return clEvents; }
91
92 /**
93 * Called from OpenCL methods that generate CLEvents.
94 *
95 * @param event a buffer containing a CLEvent pointer.
96 */
97 void registerCLEvent(final PointerBuffer event) {
98 if ( event != null )
99 new CLEvent(event.get(event.position()), this);
100 }
101
102 int release() {
103 try {
104 return super.release();
105 } finally {
106 if ( !isValid() )
107 getParent().getCLCommandQueueRegistry().unregisterObject(this);
108 }
109 }
110
111 }
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.opencl;
32
33 import org.lwjgl.LWJGLException;
34 import org.lwjgl.opencl.api.CLImageFormat;
35 import org.lwjgl.opencl.api.Filter;
36 import org.lwjgl.opengl.Drawable;
37
38 import java.nio.IntBuffer;
39 import java.util.List;
40
41 /**
42 * This class is a wrapper around a cl_context pointer.
43 *
44 * @author Spasi
45 */
46 public final class CLContext extends CLObjectChild<CLPlatform> {
47
48 private static final CLContextUtil util = (CLContextUtil)CLPlatform.getInfoUtilInstance(CLContext.class, "CL_CONTEXT_UTIL");
49
50 private final CLObjectRegistry<CLCommandQueue> clCommandQueues;
51 private final CLObjectRegistry<CLMem> clMems;
52 private final CLObjectRegistry<CLSampler> clSamplers;
53 private final CLObjectRegistry<CLProgram> clPrograms;
54 private final CLObjectRegistry<CLEvent> clEvents;
55
56 /** Global registry for build callbacks. */
57 static final FastLongMap<CLProgram> clProgramsGlobal = new FastLongMap<CLProgram>();
58
59 /** Global registry for event callbacks. */
60 static final FastLongMap<CLEvent> clEventsGlobal = new FastLongMap<CLEvent>();
61
62 CLContext(final long pointer, final CLPlatform platform) {
63 super(pointer, platform);
64
65 // We do not need to register the context with the platform,
66 // there is no API that returns cl_context, except clCreateContext.
67
68 if ( isValid() ) {
69 clCommandQueues = new CLObjectRegistry<CLCommandQueue>();
70 clMems = new CLObjectRegistry<CLMem>();
71 clSamplers = new CLObjectRegistry<CLSampler>();
72 clPrograms = new CLObjectRegistryGlobal<CLProgram>(clProgramsGlobal);
73 clEvents = new CLObjectRegistryGlobal<CLEvent>(clEventsGlobal);
74 } else {
75 clCommandQueues = null;
76 clMems = null;
77 clSamplers = null;
78 clPrograms = null;
79 clEvents = null;
80 }
81 }
82
83 /**
84 * Returns a CLCommandQueue associated with this context.
85 *
86 * @param id the command queue object id
87 *
88 * @return the CLCommandQueue object
89 */
90 public CLCommandQueue getCLCommandQueue(final long id) { return clCommandQueues.getObject(id); }
91
92 /**
93 * Returns a CLMem associated with this context.
94 *
95 * @param id the memory object id
96 *
97 * @return the CLMem object
98 */
99 public CLMem getCLMem(final long id) { return clMems.getObject(id); }
100
101 /**
102 * Returns a CLSampler associated with this context.
103 *
104 * @param id the sampler object id
105 *
106 * @return the CLSampler object
107 */
108 public CLSampler getCLSampler(final long id) { return clSamplers.getObject(id); }
109
110 /**
111 * Returns a CLProgram associated with this context.
112 *
113 * @param id the program object id
114 *
115 * @return the CLProgram object
116 */
117 public CLProgram getCLProgram(final long id) { return clPrograms.getObject(id); }
118
119 /**
120 * Returns a user CLEvent associated with this context.
121 *
122 * @param id the event object id
123 *
124 * @return the CLEvent object
125 */
126 public CLEvent getCLEvent(final long id) { return clEvents.getObject(id); }
127
128 // ---------------[ UTILITY METHODS ]---------------
129
130 /**
131 * Creates a new CLContext.
132 *
133 * @param platform the platform to use
134 * @param devices the devices to use
135 * @param errcode_ret the error code result
136 *
137 * @return the new CLContext
138 *
139 * @throws LWJGLException if an exception occurs while creating the context
140 */
141 public static CLContext create(final CLPlatform platform, final List<CLDevice> devices, final IntBuffer errcode_ret) throws LWJGLException {
142 return create(platform, devices, null, null, errcode_ret);
143 }
144
145 /**
146 * Creates a new CLContext.
147 *
148 * @param platform the platform to use
149 * @param devices the devices to use
150 * @param pfn_notify the context callback function
151 * @param errcode_ret the error code result
152 *
153 * @return the new CLContext
154 *
155 * @throws LWJGLException if an exception occurs while creating the context
156 */
157 public static CLContext create(final CLPlatform platform, final List<CLDevice> devices, final CLContextCallback pfn_notify, final IntBuffer errcode_ret) throws LWJGLException {
158 return create(platform, devices, pfn_notify, null, errcode_ret);
159 }
160
161 /**
162 * Creates a new CLContext.
163 *
164 * @param platform the platform to use
165 * @param devices the devices to use
166 * @param share_drawable the OpenGL drawable to share objects with
167 * @param errcode_ret the error code result
168 *
169 * @return the new CLContext
170 *
171 * @throws LWJGLException if an exception occurs while creating the context
172 */
173 public static CLContext create(final CLPlatform platform, final List<CLDevice> devices, final CLContextCallback pfn_notify, final Drawable share_drawable, final IntBuffer errcode_ret) throws LWJGLException {
174 return util.create(platform, devices, pfn_notify, share_drawable, errcode_ret);
175 }
176
177 /**
178 * Creates a new CLContext.
179 *
180 * @param platform the platform to use
181 * @param device_type the device type to use
182 * @param errcode_ret the error code result
183 *
184 * @return the new CLContext
185 *
186 * @throws LWJGLException if an exception occurs while creating the context
187 */
188 public static CLContext createFromType(final CLPlatform platform, final long device_type, final IntBuffer errcode_ret) throws LWJGLException {
189 return util.createFromType(platform, device_type, null, null, errcode_ret);
190 }
191
192 /**
193 * Creates a new CLContext.
194 *
195 * @param platform the platform to use
196 * @param device_type the device type to use
197 * @param pfn_notify the context callback function
198 * @param errcode_ret the error code result
199 *
200 * @return the new CLContext
201 *
202 * @throws LWJGLException if an exception occurs while creating the context
203 */
204 public static CLContext createFromType(final CLPlatform platform, final long device_type, final CLContextCallback pfn_notify, final IntBuffer errcode_ret) throws LWJGLException {
205 return util.createFromType(platform, device_type, pfn_notify, null, errcode_ret);
206 }
207
208 /**
209 * Creates a new CLContext.
210 *
211 * @param platform the platform to use
212 * @param device_type the device type to use
213 * @param share_drawable the OpenGL drawable to share objects with
214 * @param errcode_ret the error code result
215 *
216 * @return the new CLContext
217 *
218 * @throws LWJGLException if an exception occurs while creating the context
219 */
220 public static CLContext createFromType(final CLPlatform platform, final long device_type, final CLContextCallback pfn_notify, final Drawable share_drawable, final IntBuffer errcode_ret) throws LWJGLException {
221 return util.createFromType(platform, device_type, pfn_notify, share_drawable, errcode_ret);
222 }
223
224 /**
225 * Returns the integer value of the specified parameter.
226 *
227 * @param param_name the parameter
228 *
229 * @return the parameter value
230 */
231 public int getInfoInt(int param_name) {
232 return util.getInfoInt(this, param_name);
233 }
234
235 /**
236 * Returns the list of devices in context.
237 *
238 * @return the list of devices
239 */
240 public List<CLDevice> getInfoDevices() {
241 return util.getInfoDevices(this);
242 }
243
244 public List<CLImageFormat> getSupportedImageFormats(final long flags, final int image_type) {
245 return getSupportedImageFormats(flags, image_type, null);
246 }
247
248 public List<CLImageFormat> getSupportedImageFormats(final long flags, final int image_type, final Filter<CLImageFormat> filter) {
249 return util.getSupportedImageFormats(this, flags, image_type, filter);
250 }
251
252 /** CLContext utility methods interface. */
253 interface CLContextUtil extends InfoUtil<CLContext> {
254
255 List<CLDevice> getInfoDevices(CLContext context);
256
257 CLContext create(CLPlatform platform, List<CLDevice> devices, CLContextCallback pfn_notify, Drawable share_drawable, IntBuffer errcode_ret) throws LWJGLException;
258
259 CLContext createFromType(CLPlatform platform, long device_type, CLContextCallback pfn_notify, Drawable share_drawable, IntBuffer errcode_ret) throws LWJGLException;
260
261 List<CLImageFormat> getSupportedImageFormats(CLContext context, final long flags, final int image_type, Filter<CLImageFormat> filter);
262
263 }
264
265 // -------[ IMPLEMENTATION STUFF BELOW ]-------
266
267 CLObjectRegistry<CLCommandQueue> getCLCommandQueueRegistry() { return clCommandQueues; }
268
269 CLObjectRegistry<CLMem> getCLMemRegistry() { return clMems; }
270
271 CLObjectRegistry<CLSampler> getCLSamplerRegistry() { return clSamplers; }
272
273 CLObjectRegistry<CLProgram> getCLProgramRegistry() { return clPrograms; }
274
275 CLObjectRegistry<CLEvent> getCLEventRegistry() { return clEvents; }
276
277 static CLProgram getCLProgramGlobal(final long id) { return clProgramsGlobal.get(id); }
278
279 static CLEvent getCLEventGlobal(final long id) { return clEventsGlobal.get(id); }
280
281 }
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.opencl;
32
33 import org.lwjgl.PointerWrapperAbstract;
34
35 import java.nio.ByteBuffer;
36
37 /**
38 * Instances of this class can be used to receive OpenCL context error notifications.
39 *
40 * @author Spasi
41 */
42 public abstract class CLContextCallback extends PointerWrapperAbstract {
43
44 private final boolean custom;
45
46 protected CLContextCallback() {
47 super(CallbackUtil.getContextCallback());
48 custom = false;
49 }
50
51 /**
52 * This constructor allows non-LWJGL implementations.
53 *
54 * @param pointer
55 */
56 protected CLContextCallback(final long pointer) {
57 super(pointer);
58
59 if ( pointer == 0 )
60 throw new RuntimeException("Invalid callback function pointer specified.");
61
62 custom = true;
63 }
64
65 final boolean isCustom() {
66 return custom;
67 }
68
69 /**
70 * The callback method.
71 *
72 * @param errinfo the error description
73 * @param private_info optional error data (may be null)
74 */
75 protected abstract void handleMessage(String errinfo, ByteBuffer private_info);
76
77 }
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.opencl;
32
33 import org.lwjgl.PointerBuffer;
34
35 /**
36 * This class is a wrapper around a cl_device_id pointer.
37 *
38 * @author Spasi
39 */
40 public final class CLDevice extends CLObjectChild<CLDevice> {
41
42 private static final InfoUtil<CLDevice> util = CLPlatform.getInfoUtilInstance(CLDevice.class, "CL_DEVICE_UTIL");
43
44 private final CLPlatform platform;
45 private final CLObjectRegistry<CLDevice> subCLDevices;
46
47 private Object caps;
48
49 CLDevice(final long pointer, final CLPlatform platform) {
50 this(pointer, null, platform);
51 }
52
53 /**
54 * EXT_device_fission constructor.
55 *
56 * @param pointer the sub-device pointer
57 * @param parent the parent CLDevice
58 */
59 CLDevice(final long pointer, final CLDevice parent) {
60 this(pointer, parent, parent.getPlatform());
61 }
62
63 CLDevice(final long pointer, final CLDevice parent, final CLPlatform platform) {
64 super(pointer, parent);
65
66 if ( isValid() ) {
67 this.platform = platform;
68 platform.getCLDeviceRegistry().registerObject(this);
69
70 this.subCLDevices = new CLObjectRegistry<CLDevice>();
71 if ( parent != null )
72 parent.subCLDevices.registerObject(this);
73 } else {
74 this.platform = null;
75 this.subCLDevices = null;
76 }
77 }
78
79 public CLPlatform getPlatform() {
80 return platform;
81 }
82
83 /**
84 * Returns a sub-device of this device.
85 *
86 * @param id the sub-device object id
87 *
88 * @return the CLDevice object
89 */
90 public CLDevice getSubCLDevice(final long id) { return subCLDevices.getObject(id); }
91
92 // ---------------[ UTILITY METHODS ]---------------
93
94 /**
95 * Returns the value of the specified String parameter.
96 *
97 * @param param_name the parameter
98 *
99 * @return the parameter value
100 */
101 public String getInfoString(int param_name) {
102 return util.getInfoString(this, param_name);
103 }
104
105 /**
106 * Returns the integer value of the specified parameter.
107 *
108 * @param param_name the parameter
109 *
110 * @return the parameter value
111 */
112 public int getInfoInt(int param_name) {
113 return util.getInfoInt(this, param_name);
114 }
115
116 /**
117 * Returns the boolean value of the specified parameter.
118 *
119 * @param param_name the parameter
120 *
121 * @return the parameter value
122 */
123 public boolean getInfoBoolean(int param_name) {
124 return util.getInfoInt(this, param_name) != 0;
125 }
126
127 /**
128 * Returns the size_t value of the specified parameter.
129 *
130 * @param param_name the parameter
131 *
132 * @return the parameter value
133 */
134 public long getInfoSize(int param_name) {
135 return util.getInfoSize(this, param_name);
136 }
137
138 /**
139 * Returns an array of size_t values of the specified parameter.
140 *
141 * @param param_name the parameter
142 *
143 * @return the parameter values
144 */
145 public long[] getInfoSizeArray(int param_name) {
146 return util.getInfoSizeArray(this, param_name);
147 }
148
149 /**
150 * Returns the long value of the specified parameter. Can be used
151 * for both cl_ulong and cl_bitfield parameters.
152 *
153 * @param param_name the parameter
154 *
155 * @return the parameter value
156 */
157 public long getInfoLong(int param_name) {
158 return util.getInfoLong(this, param_name);
159 }
160
161 // -------[ IMPLEMENTATION STUFF BELOW ]-------
162
163 void setCapabilities(final Object caps) {
164 this.caps = caps;
165 }
166
167 Object getCapabilities() {
168 return caps;
169 }
170
171 int retain() {
172 if ( getParent() == null )
173 return getReferenceCount(); // NO-OP, root devices cannot be retained
174
175 return super.retain();
176 }
177
178 int release() {
179 if ( getParent() == null )
180 return getReferenceCount(); // NO-OP, root devices cannot be released
181
182 try {
183 return super.release();
184 } finally {
185 if ( !isValid() )
186 getParent().subCLDevices.unregisterObject(this);
187 }
188 }
189
190 CLObjectRegistry<CLDevice> getSubCLDeviceRegistry() { return subCLDevices; }
191
192 /**
193 * Called from clCreateSubDevicesEXT to register new sub-devices.
194 *
195 * @param devices a buffer containing CLDevice pointers.
196 */
197 void registerSubCLDevices(final PointerBuffer devices) {
198 for ( int i = devices.position(); i < devices.limit(); i++ ) {
199 final long pointer = devices.get(i);
200 if ( pointer != 0 )
201 new CLDevice(pointer, this);
202 }
203 }
204
205 }
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.opencl;
32
33 /**
34 * This class is a wrapper around a cl_mem pointer.
35 *
36 * @author Spasi
37 */
38 public final class CLEvent extends CLObjectChild<CLContext> {
39
40 private static final CLEventUtil util = (CLEventUtil)CLPlatform.getInfoUtilInstance(CLEvent.class, "CL_EVENT_UTIL");
41
42 private final CLCommandQueue queue;
43
44 CLEvent(final long pointer, final CLContext context) {
45 this(pointer, context, null);
46 }
47
48 CLEvent(final long pointer, final CLCommandQueue queue) {
49 this(pointer, queue.getParent(), queue);
50 }
51
52 CLEvent(final long pointer, final CLContext context, final CLCommandQueue queue) {
53 super(pointer, context);
54 if ( isValid() ) {
55 this.queue = queue;
56 if ( queue == null )
57 context.getCLEventRegistry().registerObject(this);
58 else
59 queue.getCLEventRegistry().registerObject(this);
60 } else
61 this.queue = null;
62 }
63
64 /**
65 * Returns the command-queue associated with this event. For
66 * user events this method returns null.
67 *
68 * @return the command-queue or null if this is a user event
69 */
70 public CLCommandQueue getCLCommandQueue() {
71 return queue;
72 }
73
74 // ---------------[ UTILITY METHODS ]---------------
75
76 /**
77 * Returns the integer value of the specified parameter.
78 *
79 * @param param_name the parameter
80 *
81 * @return the parameter value
82 */
83 public int getInfoInt(final int param_name) {
84 return util.getInfoInt(this, param_name);
85 }
86
87 // clGetEventProfilingInfo methods
88
89 /**
90 * Returns the long value of the specified parameter. Can be used
91 * for both cl_ulong and cl_bitfield parameters.
92 *
93 * @param param_name the parameter
94 *
95 * @return the parameter value
96 */
97 public long getProfilingInfoLong(int param_name) {
98 return util.getProfilingInfoLong(this, param_name);
99 }
100
101 /** CLEvent utility methods interface. */
102 interface CLEventUtil extends InfoUtil<CLEvent> {
103
104 long getProfilingInfoLong(CLEvent event, int param_name);
105
106 }
107
108 // -------[ IMPLEMENTATION STUFF BELOW ]-------
109
110 int release() {
111 try {
112 return super.release();
113 } finally {
114 if ( !isValid() ) {
115 if ( queue == null )
116 getParent().getCLEventRegistry().unregisterObject(this);
117 else
118 queue.getCLEventRegistry().unregisterObject(this);
119 }
120 }
121 }
122
123 }
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.opencl;
32
33 /**
34 * Instances of this class can be used to receive OpenCL memory object destruction notifications.
35 *
36 * @author Spasi
37 */
38 public abstract class CLEventCallback extends CLCallback {
39
40 protected CLEventCallback() {
41 super(CallbackUtil.getEventCallback());
42 }
43
44 /**
45 * Called from native code.
46 *
47 * @param event_address the CLEvent object pointer
48 */
49 private void handleMessage(long event_address, int event_command_exec_status) {
50 handleMessage(CLContext.getCLEventGlobal(event_address), event_command_exec_status);
51 }
52
53 /**
54 * The callback method.
55 *
56 * @param event the CLEvent object
57 */
58 protected abstract void handleMessage(CLEvent event, int event_command_exec_status);
59
60 }
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.opencl;
32
33 import org.lwjgl.PointerWrapperAbstract;
34
35 /**
36 * This class is a wrapper around an OpenCL extension function pointer.
37 *
38 * @author Spasi
39 */
40 final class CLFunctionAddress extends PointerWrapperAbstract {
41
42 CLFunctionAddress(final long pointer) {
43 super(pointer);
44 }
45
46 }
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.opencl;
32
33 /**
34 * This class is a wrapper around a cl_kernel pointer.
35 *
36 * @author Spasi
37 */
38 public final class CLKernel extends CLObjectChild<CLProgram> {
39
40 private static final CLKernelUtil util = (CLKernelUtil)CLPlatform.getInfoUtilInstance(CLKernel.class, "CL_KERNEL_UTIL");
41
42 CLKernel(final long pointer, final CLProgram program) {
43 super(pointer, program);
44 if ( isValid() )
45 program.getCLKernelRegistry().registerObject(this);
46 }
47
48 // ---------------[ UTILITY METHODS ]---------------
49
50 // clSetKernelArg methods
51
52 /**
53 * Sets a kernel argument at the specified index to the specified
54 * byte value.
55 *
56 * @param index the argument index
57 * @param value the argument value
58 *
59 * @return this CLKernel object
60 */
61 public CLKernel setArg(final int index, final byte value) {
62 util.setArg(this, index, value);
63 return this;
64 }
65
66 /**
67 * Sets a kernel argument at the specified index to the specified
68 * byte value.
69 *
70 * @param index the argument index
71 * @param value the argument value
72 *
73 * @return this CLKernel object
74 */
75 public CLKernel setArg(final int index, final short value) {
76 util.setArg(this, index, value);
77 return this;
78 }
79
80 /**
81 * Sets a kernel argument at the specified index to the specified
82 * int value.
83 *
84 * @param index the argument index
85 * @param value the argument value
86 *
87 * @return this CLKernel object
88 */
89 public CLKernel setArg(final int index, final int value) {
90 util.setArg(this, index, value);
91 return this;
92 }
93
94 /**
95 * Sets a kernel argument at the specified index to the specified
96 * long value.
97 *
98 * @param index the argument index
99 * @param value the argument value
100 *
101 * @return this CLKernel object
102 */
103 public CLKernel setArg(final int index, final long value) {
104 util.setArg(this, index, value);
105 return this;
106 }
107
108 /**
109 * Sets a kernel argument at the specified index to the specified
110 * float value.
111 *
112 * @param index the argument index
113 * @param value the argument value
114 *
115 * @return this CLKernel object
116 */
117 public CLKernel setArg(final int index, final float value) {
118 util.setArg(this, index, value);
119 return this;
120 }
121
122 /**
123 * Sets a kernel argument at the specified index to the specified
124 * double value.
125 *
126 * @param index the argument index
127 * @param value the argument value
128 *
129 * @return this CLKernel object
130 */
131 public CLKernel setArg(final int index, final double value) {
132 util.setArg(this, index, value);
133 return this;
134 }
135
136 /**
137 * Sets a kernel argument at the specified index to the specified
138 * pointer value.
139 *
140 * @param index the argument index
141 * @param value the argument value
142 *
143 * @return this CLKernel object
144 */
145 public CLKernel setArg(final int index, final CLObject value) {
146 util.setArg(this, index, value);
147 return this;
148 }
149
150 /**
151 * Sets the size of a __local kernel argument at the specified index.
152 *
153 * @param index the argument index
154 * @param size the argument size
155 *
156 * @return this CLKernel object
157 */
158 public CLKernel setArgSize(final int index, final long size) {
159 util.setArgSize(this, index, size);
160 return this;
161 }
162
163 // clGetKernelInfo methods
164
165 /**
166 * Returns the String value of the specified parameter.
167 *
168 * @param param_name the parameter
169 *
170 * @return the parameter value
171 */
172 public String getInfoString(final int param_name) {
173 return util.getInfoString(this, param_name);
174 }
175
176 /**
177 * Returns the integer value of the specified parameter.
178 *
179 * @param param_name the parameter
180 *
181 * @return the parameter value
182 */
183 public int getInfoInt(final int param_name) {
184 return util.getInfoInt(this, param_name);
185 }
186
187 // clGetKernelWorkGroupInfo methods
188
189 /**
190 * Returns the size_t value of the specified parameter.
191 *
192 * @param param_name the parameter
193 *
194 * @return the parameter value
195 */
196 public long getWorkGroupInfoSize(final CLDevice device, int param_name) {
197 return util.getWorkGroupInfoSize(this, device, param_name);
198 }
199
200 /**
201 * Returns an array of size_t values of the specified parameter.
202 *
203 * @param param_name the parameter
204 *
205 * @return the parameter values
206 */
207 public long[] getWorkGroupInfoSizeArray(final CLDevice device, int param_name) {
208 return util.getWorkGroupInfoSizeArray(this, device, param_name);
209 }
210
211 /**
212 * Returns the long value of the specified parameter. Can be used
213 * for both cl_ulong and cl_bitfield parameters.
214 *
215 * @param param_name the parameter
216 *
217 * @return the parameter value
218 */
219 public long getWorkGroupInfoLong(final CLDevice device, int param_name) {
220 return util.getWorkGroupInfoLong(this, device, param_name);
221 }
222
223 /** CLKernel utility methods interface. */
224 interface CLKernelUtil extends InfoUtil<CLKernel> {
225
226 void setArg(CLKernel kernel, int index, byte value);
227
228 void setArg(CLKernel kernel, int index, short value);
229
230 void setArg(CLKernel kernel, int index, int value);
231
232 void setArg(CLKernel kernel, int index, long value);
233
234 void setArg(CLKernel kernel, int index, float value);
235
236 void setArg(CLKernel kernel, int index, double value);
237
238 void setArg(CLKernel kernel, int index, CLObject pointer);
239
240 void setArgSize(CLKernel kernel, int index, long size);
241
242 long getWorkGroupInfoSize(CLKernel kernel, CLDevice device, int param_name);
243
244 long[] getWorkGroupInfoSizeArray(CLKernel kernel, CLDevice device, int param_name);
245
246 long getWorkGroupInfoLong(CLKernel kernel, CLDevice device, int param_name);
247
248 }
249
250 // -------[ IMPLEMENTATION STUFF BELOW ]-------
251
252 int release() {
253 try {
254 return super.release();
255 } finally {
256 if ( !isValid() )
257 getParent().getCLKernelRegistry().unregisterObject(this);
258 }
259 }
260
261 }
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.opencl;
32
33 import org.lwjgl.opencl.api.CLBufferRegion;
34 import org.lwjgl.opencl.api.CLImageFormat;
35
36 import java.nio.Buffer;
37 import java.nio.ByteBuffer;
38 import java.nio.IntBuffer;
39
40 /**
41 * This class is a wrapper around a cl_mem pointer.
42 *
43 * @author Spasi
44 */
45 public final class CLMem extends CLObjectChild<CLContext> {
46
47 private static final CLMemUtil util = (CLMemUtil)CLPlatform.getInfoUtilInstance(CLMem.class, "CL_MEM_UTIL");
48
49 CLMem(final long pointer, final CLContext context) {
50 super(pointer, context);
51 if ( isValid() )
52 context.getCLMemRegistry().registerObject(this);
53 }
54
55 // ---------------[ UTILITY METHODS ]---------------
56
57 /**
58 * Creates a new 2D image object.
59 *
60 * @param context the context on which to create the image object
61 * @param flags the memory object flags
62 * @param image_format the image format
63 * @param image_width the image width
64 * @param image_height the image height
65 * @param image_row_pitch the image row pitch
66 * @param host_ptr the host buffer from which to read image data (optional)
67 * @param errcode_ret the error code result
68 *
69 * @return the new CLMem object
70 */
71 public static CLMem createImage2D(final CLContext context, final long flags, final CLImageFormat image_format,
72 final long image_width, final long image_height, final long image_row_pitch,
73 final Buffer host_ptr, final IntBuffer errcode_ret) {
74 return util.createImage2D(context, flags, image_format, image_width, image_height, image_row_pitch, host_ptr, errcode_ret);
75 }
76
77 /**
78 * Creates a new 3D image object.
79 *
80 * @param context the context on which to create the image object
81 * @param flags the memory object flags
82 * @param image_format the image format
83 * @param image_width the image width
84 * @param image_height the image height
85 * @param image_depth the image depth
86 * @param image_row_pitch the image row pitch
87 * @param image_slice_pitch the image slice pitch
88 * @param host_ptr the host buffer from which to read image data (optional)
89 * @param errcode_ret the error code result
90 *
91 * @return the new CLMem object
92 */
93 public static CLMem createImage3D(final CLContext context, final long flags, final CLImageFormat image_format,
94 final long image_width, final long image_height, final long image_depth, final long image_row_pitch, final long image_slice_pitch,
95 final Buffer host_ptr, final IntBuffer errcode_ret) {
96 return util.createImage3D(context, flags, image_format, image_width, image_height, image_depth, image_row_pitch, image_slice_pitch, host_ptr, errcode_ret);
97 }
98
99 public CLMem createSubBuffer(final long flags, final int buffer_create_type, final CLBufferRegion buffer_create_info, final IntBuffer errcode_ret) {
100 return util.createSubBuffer(this, flags, buffer_create_type, buffer_create_info, errcode_ret);
101 }
102
103 /**
104 * Returns the integer value of the specified parameter.
105 *
106 * @param param_name the parameter
107 *
108 * @return the parameter value
109 */
110 public int getInfoInt(int param_name) {
111 return util.getInfoInt(this, param_name);
112 }
113
114 /**
115 * Returns the size_t value of the specified parameter.
116 *
117 * @param param_name the parameter
118 *
119 * @return the parameter value
120 */
121 public long getInfoSize(int param_name) {
122 return util.getInfoSize(this, param_name);
123 }
124
125 /**
126 * Returns the long value of the specified parameter. Can be used
127 * for both cl_ulong and cl_bitfield parameters.
128 *
129 * @param param_name the parameter
130 *
131 * @return the parameter value
132 */
133 public long getInfoLong(int param_name) {
134 return util.getInfoLong(this, param_name);
135 }
136
137 /**
138 * Returns a direct ByteBuffer instance that points to the host
139 * memory that backs this CLMem object. Applicable only to CLMem
140 * objects that were created with the CL_MEM_USE_HOST_PTR flag.
141 *
142 * @return the host memory ByteBuffer
143 */
144 public ByteBuffer getInfoHostBuffer() {
145 return util.getInfoHostBuffer(this);
146 }
147
148 // clGetImageInfo methods
149
150 /**
151 * Returns the size_t value of the specified parameter. Applicable to image objects only.
152 *
153 * @param param_name the parameter
154 *
155 * @return the parameter value
156 */
157 public long getImageInfoSize(int param_name) {
158 return util.getImageInfoSize(this, param_name);
159 }
160
161 /**
162 * Returns the image format. Applicable to image objects only.
163 *
164 * @return the parameter value
165 */
166 public CLImageFormat getImageFormat() {
167 return util.getImageInfoFormat(this);
168 }
169
170 /**
171 * Returns the image channel order. Applicable to image objects only.
172 *
173 * @return the parameter value
174 */
175 public int getImageChannelOrder() {
176 return util.getImageInfoFormat(this, 0);
177 }
178
179 /**
180 * Returns the image channel type. Applicable to image objects only.
181 *
182 * @return the parameter value
183 */
184 public int getImageChannelType() {
185 return util.getImageInfoFormat(this, 1);
186 }
187
188 // clGetGLObjectInfo methods
189
190 /**
191 * Returns the GL object type. Applicable to CLMem objects
192 * that have been created GL objects only.
193 *
194 * @return the parameter value
195 */
196 public int getGLObjectType() {
197 return util.getGLObjectType(this);
198 }
199
200 /**
201 * Returns the GL object name. Applicable to CLMem objects
202 * that have been created GL objects only.
203 *
204 * @return the parameter value
205 */
206 public int getGLObjectName() {
207 return util.getGLObjectName(this);
208 }
209
210 // clGetGLTextureInfo methods
211
212 /**
213 * Returns the int value of the specified parameter. Applicable to CLMem objects
214 * that have been created by GL textures only.
215 *
216 * @param param_name the parameter
217 *
218 * @return the parameter value
219 */
220 public int getGLTextureInfoInt(int param_name) {
221 return util.getGLTextureInfoInt(this, param_name);
222 }
223
224 /** CLMem utility methods interface. */
225 interface CLMemUtil extends InfoUtil<CLMem> {
226
227 CLMem createImage2D(CLContext context, long flags, CLImageFormat image_format, long image_width, long image_height, long image_row_pitch, Buffer host_ptr, IntBuffer errcode_ret);
228
229 CLMem createImage3D(CLContext context, long flags, CLImageFormat image_format, long image_width, long image_height, long image_depth, long image_row_pitch, long image_slice_pitch, Buffer host_ptr, IntBuffer errcode_ret);
230
231 CLMem createSubBuffer(CLMem mem, long flags, int buffer_create_type, CLBufferRegion buffer_create_info, IntBuffer errcode_ret);
232
233 ByteBuffer getInfoHostBuffer(CLMem mem);
234
235 long getImageInfoSize(CLMem mem, int param_name);
236
237 CLImageFormat getImageInfoFormat(CLMem mem);
238
239 int getImageInfoFormat(CLMem mem, int index);
240
241 int getGLObjectType(CLMem mem);
242
243 int getGLObjectName(CLMem mem);
244
245 int getGLTextureInfoInt(CLMem mem, int param_name);
246
247 }
248
249 // -------[ IMPLEMENTATION STUFF BELOW ]-------
250
251 /**
252 * Sub-buffer factory. clCreateSubBuffer may return an existing CLMem.
253 *
254 * @param pointer the sub-buffer id
255 * @param context the context in which the sub-buffer was created
256 *
257 * @return the CLMem that represents the sub-buffer
258 */
259 static CLMem create(final long pointer, final CLContext context) {
260 CLMem clMem = context.getCLMemRegistry().getObject(pointer);
261 if ( clMem == null )
262 clMem = new CLMem(pointer, context);
263 else
264 clMem.retain();
265
266 return clMem;
267 }
268
269 int release() {
270 try {
271 return super.release();
272 } finally {
273 if ( !isValid() )
274 getParent().getCLMemRegistry().unregisterObject(this);
275 }
276 }
277
278 }
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.opencl;
32
33 /**
34 * Instances of this class can be used to receive OpenCL memory object destruction notifications.
35 *
36 * @author Spasi
37 */
38 public abstract class CLMemObjectDestructorCallback extends CLCallback {
39
40 protected CLMemObjectDestructorCallback() {
41 super(CallbackUtil.getMemObjectDestructorCallback());
42 }
43
44 /**
45 * The callback method.
46 *
47 * @param memobj id of the CLMem object that was destroyed
48 */
49 protected abstract void handleMessage(long memobj);
50
51 }
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.opencl;
32
33 import java.nio.ByteBuffer;
34
35 /**
36 * Instances of this class can be used to execute native kernels. clEnqueueNativeKernel will build
37 * the its arguments automatically, in a way that allows <code>execute</code> to receive an array
38 * of ByteBuffers, pointing to cl_mem objects in global memory. The ByteBuffer objects should not
39 * be used outside the handleMessage method.
40 *
41 * @author Spasi
42 * @see CL10#clEnqueueNativeKernel
43 * @see #execute(java.nio.ByteBuffer[])
44 */
45 public abstract class CLNativeKernel extends CLCallback {
46
47 protected CLNativeKernel() {
48 super(CallbackUtil.getNativeKernelCallback());
49 }
50
51 /**
52 * Implement this method to execute an action on cl_mem objects in global memory.
53 *
54 * @param memobjs an array of ByteBuffers pointing to cl_mem global memory.
55 */
56 protected abstract void execute(ByteBuffer[] memobjs);
57
58 }
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.opencl;
32
33 import org.lwjgl.PointerWrapperAbstract;
34
35 /**
36 * Base class for all OpenCL objects.
37 *
38 * @author Spasi
39 */
40 abstract class CLObject extends PointerWrapperAbstract {
41
42 protected CLObject(final long pointer) {
43 super(pointer);
44 }
45
46 final long getPointerUnsafe() {
47 return pointer;
48 }
49
50 }
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.opencl;
32
33 import org.lwjgl.LWJGLUtil;
34
35 /**
36 * Base class for all CLObjects that are associated with a parent CLObject.
37 *
38 * @author Spasi
39 */
40 abstract class CLObjectChild<P extends CLObject> extends CLObjectRetainable {
41
42 private final P parent;
43
44 protected CLObjectChild(final long pointer, final P parent) {
45 super(pointer);
46
47 if ( LWJGLUtil.DEBUG && parent != null && !parent.isValid() )
48 throw new IllegalStateException("The parent specified is not a valid CL object.");
49
50 this.parent = parent;
51 }
52
53 public P getParent() {
54 return parent;
55 }
56
57 }
0 package org.lwjgl.opencl;
1
2 import org.lwjgl.LWJGLUtil;
3
4 /**
5 * A CLObjectChild container.
6 *
7 * @author Spasi
8 */
9 class CLObjectRegistry<T extends CLObjectChild> {
10
11 private FastLongMap<T> registry;
12
13 CLObjectRegistry() {
14 }
15
16 final boolean isEmpty() {
17 return registry == null || registry.isEmpty();
18 }
19
20 final T getObject(final long id) {
21 return registry == null ? null : registry.get(id);
22 }
23
24 final boolean hasObject(final long id) {
25 return registry != null && registry.containsKey(id);
26 }
27
28 final Iterable<FastLongMap.Entry<T>> getAll() {
29 return registry;
30 }
31
32 void registerObject(final T object) {
33 final FastLongMap<T> map = getMap();
34 final Long key = object.getPointer();
35
36 if ( LWJGLUtil.DEBUG && map.containsKey(key) )
37 throw new IllegalStateException("Duplicate object found: " + object.getClass() + " - " + key);
38
39 getMap().put(object.getPointer(), object);
40 }
41
42 void unregisterObject(final T object) {
43 getMap().remove(object.getPointerUnsafe());
44 }
45
46 private FastLongMap<T> getMap() {
47 if ( registry == null )
48 registry = new FastLongMap<T>();
49
50 return registry;
51 }
52
53 }
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.opencl;
32
33 /**
34 * A CLObject registry that also registers/unregisters objects to/from a global registry.
35 *
36 * @author Spasi
37 */
38 final class CLObjectRegistryGlobal<T extends CLObjectChild> extends CLObjectRegistry<T> {
39
40 private final FastLongMap<T> globalRegistry;
41
42 CLObjectRegistryGlobal(final FastLongMap<T> globalRegistry) {
43 this.globalRegistry = globalRegistry;
44 }
45
46 void registerObject(final T object) {
47 super.registerObject(object);
48 globalRegistry.put(object.getPointer(), object);
49 }
50
51 void unregisterObject(final T object) {
52 super.unregisterObject(object);
53 globalRegistry.remove(object.getPointerUnsafe());
54 }
55
56 }
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.opencl;
32
33 /**
34 * Base class for all retainable OpenCL objects.
35 *
36 * @author Spasi
37 */
38 abstract class CLObjectRetainable extends CLObject {
39
40 private int refCount;
41
42 protected CLObjectRetainable(final long pointer) {
43 super(pointer);
44
45 if ( super.isValid() )
46 this.refCount = 1;
47 }
48
49 public final int getReferenceCount() {
50 return refCount;
51 }
52
53 public final boolean isValid() {
54 return refCount > 0;
55 }
56
57 int retain() {
58 checkValid();
59 //System.out.println(getClass().getSimpleName() + " REF COUNT: " + pointer + " - " + (refCount + 1));
60 return ++refCount;
61 }
62
63 int release() {
64 checkValid();
65 //System.out.println(getClass().getSimpleName() + " REF COUNT: " + pointer + " - " + (refCount - 1));
66 return --refCount;
67 }
68
69 }
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.opencl;
32
33 import org.lwjgl.PointerBuffer;
34 import org.lwjgl.opencl.api.Filter;
35
36 import java.nio.ByteBuffer;
37 import java.nio.IntBuffer;
38 import java.util.List;
39
40 import static java.lang.Math.*;
41
42 /**
43 * This class is a wrapper around a cl_platform_id pointer.
44 *
45 * @author Spasi
46 */
47 public final class CLPlatform extends CLObject {
48
49 private static final CLPlatformUtil util = (CLPlatformUtil)getInfoUtilInstance(CLPlatform.class, "CL_PLATFORM_UTIL");
50
51 private static final FastLongMap<CLPlatform> clPlatforms = new FastLongMap<CLPlatform>();
52
53 private final CLObjectRegistry<CLDevice> clDevices;
54
55 /** Global registry for build callbacks. */
56 static final FastLongMap<CLDevice> clDevicesGlobal = new FastLongMap<CLDevice>();
57
58 private Object caps;
59
60 CLPlatform(final long pointer) {
61 super(pointer);
62
63 if ( isValid() ) {
64 clPlatforms.put(pointer, this);
65 clDevices = new CLObjectRegistryGlobal<CLDevice>(clDevicesGlobal);
66 } else
67 clDevices = null;
68 }
69
70 /**
71 * Returns a CLPlatform with the specified id.
72 *
73 * @param id the platform object id
74 *
75 * @return the CLPlatform object
76 */
77 public static CLPlatform getCLPlatform(final long id) { return clPlatforms.get(id); }
78
79 /**
80 * Returns a CLDevice that is available on this platform.
81 *
82 * @param id the device object id
83 *
84 * @return the CLDevice object
85 */
86 public CLDevice getCLDevice(final long id) { return clDevices.getObject(id); }
87
88 // ---------------[ UTILITY METHODS ]---------------
89
90 @SuppressWarnings("unchecked")
91 static <T extends CLObject> InfoUtil<T> getInfoUtilInstance(final Class<T> clazz, final String fieldName) {
92 InfoUtil<T> instance = null;
93 try {
94 final Class<?> infoUtil = Class.forName("org.lwjgl.opencl.InfoUtilFactory");
95 instance = (InfoUtil<T>)infoUtil.getDeclaredField(fieldName).get(null);
96 } catch (Exception e) {
97 // Ignore
98 }
99 return instance;
100 }
101
102 /**
103 * Returns a list of all the available platforms.
104 *
105 * @return the available platforms
106 */
107 public static List<CLPlatform> getPlatforms() {
108 return getPlatforms(null);
109 }
110
111 /**
112 * Returns a list of the available platforms, filtered by the specified filter.
113 *
114 * @param filter the platform filter
115 *
116 * @return the available platforms
117 */
118 public static List<CLPlatform> getPlatforms(final Filter<CLPlatform> filter) {
119 return util.getPlatforms(filter);
120 }
121
122 /**
123 * Returns the String value of the specified parameter.
124 *
125 * @param param_name the parameter
126 *
127 * @return the parameter value
128 */
129 public String getInfoString(int param_name) {
130 return util.getInfoString(this, param_name);
131 }
132
133 /**
134 * Returns a list of the available devices on this platform that
135 * match the specified type.
136 *
137 * @param device_type the device type
138 *
139 * @return the available devices
140 */
141 public List<CLDevice> getDevices(final int device_type) {
142 return getDevices(device_type, null);
143 }
144
145 /**
146 * Returns a list of the available devices on this platform that
147 * match the specified type, filtered by the specified filter.
148 *
149 * @param device_type the device type
150 * @param filter the device filter
151 *
152 * @return the available devices
153 */
154 public List<CLDevice> getDevices(final int device_type, final Filter<CLDevice> filter) {
155 return util.getDevices(this, device_type, filter);
156 }
157
158 /** CLPlatform utility methods interface. */
159 interface CLPlatformUtil extends InfoUtil<CLPlatform> {
160
161 List<CLPlatform> getPlatforms(Filter<CLPlatform> filter);
162
163 List<CLDevice> getDevices(CLPlatform platform, int device_type, final Filter<CLDevice> filter);
164
165 }
166
167 // -------[ IMPLEMENTATION STUFF BELOW ]-------
168
169 void setCapabilities(final Object caps) {
170 this.caps = caps;
171 }
172
173 Object getCapabilities() {
174 return caps;
175 }
176
177 /**
178 * Called from clGetPlatformIDs to register new platforms.
179 *
180 * @param platforms a buffer containing CLPlatform pointers.
181 */
182 static void registerCLPlatforms(final PointerBuffer platforms, final IntBuffer num_platforms) {
183 if ( platforms == null )
184 return;
185
186 final int pos = platforms.position();
187 final int count = min(num_platforms.get(0), platforms.remaining()); // We can't depend on .remaining()
188 for ( int i = 0; i < count; i++ ) {
189 final long id = platforms.get(pos + i);
190 if ( !clPlatforms.containsKey(id) )
191 new CLPlatform(id);
192 }
193 }
194
195 CLObjectRegistry<CLDevice> getCLDeviceRegistry() { return clDevices; }
196
197 static CLDevice getCLDeviceGlobal(final long id) { return clDevicesGlobal.get(id); }
198
199 /**
200 * Called from <code>clGetDeviceIDs</code> to register new devices.
201 *
202 * @param devices a buffer containing CLDevice pointers.
203 */
204 void registerCLDevices(final PointerBuffer devices, final IntBuffer num_devices) {
205 final int pos = devices.position();
206 final int count = min(num_devices.get(num_devices.position()), devices.remaining()); // We can't depend on .remaining()
207 for ( int i = 0; i < count; i++ ) {
208 final long id = devices.get(pos + i);
209 if ( !clDevices.hasObject(id) )
210 new CLDevice(id, this);
211 }
212 }
213
214 /**
215 * Called from <code>clGetContextInfo</code> to register new devices.
216 *
217 * @param devices a buffer containing CLDevice pointers.
218 */
219 void registerCLDevices(final ByteBuffer devices, final PointerBuffer num_devices) {
220 final int pos = devices.position();
221 final int count = min((int)num_devices.get(num_devices.position()), devices.remaining()) / PointerBuffer.getPointerSize(); // We can't depend on .remaining()
222 for ( int i = 0; i < count; i++ ) {
223 final int offset = pos + (i * PointerBuffer.getPointerSize());
224 final long id = PointerBuffer.is64Bit() ? devices.getLong(offset) : devices.getInt(offset);
225 if ( !clDevices.hasObject(id) )
226 new CLDevice(id, this);
227 }
228 }
229
230 }
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.opencl;
32
33 import org.lwjgl.PointerBuffer;
34
35 import java.nio.ByteBuffer;
36
37 /**
38 * This class is a wrapper around a cl_program pointer.
39 *
40 * @author Spasi
41 */
42 public final class CLProgram extends CLObjectChild<CLContext> {
43
44 private static final CLProgramUtil util = (CLProgramUtil)CLPlatform.getInfoUtilInstance(CLProgram.class, "CL_PROGRAM_UTIL");
45
46 private final CLObjectRegistry<CLKernel> clKernels;
47
48 CLProgram(final long pointer, final CLContext context) {
49 super(pointer, context);
50
51 if ( isValid() ) {
52 context.getCLProgramRegistry().registerObject(this);
53 clKernels = new CLObjectRegistry<CLKernel>();
54 } else
55 clKernels = null;
56 }
57
58 /**
59 * Returns a CLKernel associated with this program.
60 *
61 * @param id the kernel id
62 *
63 * @return the CLKernel object
64 */
65 public CLKernel getCLKernel(final long id) {
66 return clKernels.getObject(id);
67 }
68
69 // ---------------[ UTILITY METHODS ]---------------
70
71 /**
72 * Creates kernel objects for all kernels functions in this program.
73 *
74 * @return a CLKernel array
75 */
76 public CLKernel[] createKernelsInProgram() {
77 return util.createKernelsInProgram(this);
78 }
79
80 /**
81 * Returns the String value of the specified parameter.
82 *
83 * @param param_name the parameter
84 *
85 * @return the parameter value
86 */
87 public String getInfoString(final int param_name) {
88 return util.getInfoString(this, param_name);
89 }
90
91 /**
92 * Returns the integer value of the specified parameter.
93 *
94 * @param param_name the parameter
95 *
96 * @return the parameter value
97 */
98 public int getInfoInt(final int param_name) {
99 return util.getInfoInt(this, param_name);
100 }
101
102 /**
103 * Returns an array of size_t values of the specified parameter.
104 *
105 * @param param_name the parameter
106 *
107 * @return the parameter values
108 */
109 public long[] getInfoSizeArray(final int param_name) {
110 return util.getInfoSizeArray(this, param_name);
111 }
112
113 /**
114 * Returns an array of CLDevices associated with this program.
115 *
116 * @return the array of devices
117 */
118 public CLDevice[] getInfoDevices() {
119 return util.getInfoDevices(this);
120 }
121
122 /**
123 * Returns the program binaries for all devices associated with program,
124 * written sequentially in the target ByteBuffer. If the <code>target</code>
125 * parameter is null, a new ByteBuffer will be allocated. If not, the
126 * target ByteBuffer must be big enough to hold the program binaries, as
127 * returned by CL_PROGRAM_BINARY_SIZES.
128 *
129 * @param target the target ByteBuffer array.
130 *
131 * @return the array of devices
132 */
133 public ByteBuffer getInfoBinaries(final ByteBuffer target) {
134 return util.getInfoBinaries(this, target);
135 }
136
137 /**
138 * Returns the program binaries for all devices associated with program,
139 * as a ByteBuffer array. If the <code>target</code> parameter is null,
140 * a new ByteBuffer array will be allocated. If not, the target ByteBuffers
141 * must be big enough to hold the program binaries, as returned by
142 * CL_PROGRAM_BINARY_SIZES.
143 *
144 * @param target the target ByteBuffer array.
145 *
146 * @return the array of devices
147 */
148 public ByteBuffer[] getInfoBinaries(final ByteBuffer[] target) {
149 return util.getInfoBinaries(this, target);
150 }
151
152 // clGetProgramBuildInfo methods
153
154 /**
155 * Returns the String value of the specified parameter.
156 *
157 * @param param_name the parameter
158 *
159 * @return the parameter value
160 */
161 public String getBuildInfoString(final CLDevice device, final int param_name) {
162 return util.getBuildInfoString(this, device, param_name);
163 }
164
165 /**
166 * Returns the integer value of the specified parameter.
167 *
168 * @param param_name the parameter
169 *
170 * @return the parameter value
171 */
172 public int getBuildInfoInt(final CLDevice device, final int param_name) {
173 return util.getBuildInfoInt(this, device, param_name);
174 }
175
176 /** CLProgram utility methods interface. */
177 interface CLProgramUtil extends InfoUtil<CLProgram> {
178
179 CLKernel[] createKernelsInProgram(CLProgram program);
180
181 CLDevice[] getInfoDevices(CLProgram program);
182
183 ByteBuffer getInfoBinaries(CLProgram program, ByteBuffer target);
184
185 ByteBuffer[] getInfoBinaries(CLProgram program, ByteBuffer[] target);
186
187 String getBuildInfoString(CLProgram program, final CLDevice device, int param_name);
188
189 int getBuildInfoInt(CLProgram program, final CLDevice device, int param_name);
190
191 }
192
193 // -------[ IMPLEMENTATION STUFF BELOW ]-------
194
195 CLObjectRegistry<CLKernel> getCLKernelRegistry() { return clKernels; }
196
197 /**
198 * Called from clCreateKernelsInProgram to register new CLKernels.
199 *
200 * @param kernels a buffer containing CLKernel pointers.
201 */
202 void registerCLKernels(final PointerBuffer kernels) {
203 for ( int i = kernels.position(); i < kernels.limit(); i++ ) {
204 final long pointer = kernels.get(i);
205 if ( pointer != 0 )
206 new CLKernel(pointer, this);
207 }
208 }
209
210 int release() {
211 try {
212 return super.release();
213 } finally {
214 if ( !isValid() )
215 getParent().getCLProgramRegistry().unregisterObject(this);
216 }
217 }
218
219 }
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.opencl;
32
33 /**
34 * This class is a wrapper around a cl_sampler pointer.
35 *
36 * @author Spasi
37 */
38 public final class CLSampler extends CLObjectChild<CLContext> {
39
40 private static final InfoUtil<CLSampler> util = CLPlatform.getInfoUtilInstance(CLSampler.class, "CL_SAMPLER_UTIL");
41
42 CLSampler(final long pointer, final CLContext context) {
43 super(pointer, context);
44 if ( isValid() )
45 context.getCLSamplerRegistry().registerObject(this);
46 }
47
48 // ---------------[ UTILITY METHODS ]---------------
49
50 /**
51 * Returns the integer value of the specified parameter.
52 *
53 * @param param_name the parameter
54 *
55 * @return the parameter value
56 */
57 public int getInfoInt(int param_name) {
58 return util.getInfoInt(this, param_name);
59 }
60
61 /**
62 * Returns the long value of the specified parameter. Can be used
63 * for both cl_ulong and cl_bitfield parameters.
64 *
65 * @param param_name the parameter
66 *
67 * @return the parameter value
68 */
69 public long getInfoLong(int param_name) {
70 return util.getInfoLong(this, param_name);
71 }
72
73 // -------[ IMPLEMENTATION STUFF BELOW ]-------
74
75 int release() {
76 try {
77 return super.release();
78 } finally {
79 if ( !isValid() )
80 getParent().getCLSamplerRegistry().unregisterObject(this);
81 }
82 }
83
84 }
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.opencl;
32
33 import java.util.HashMap;
34 import java.util.Map;
35
36 /**
37 * Utility class that handles OpenCL API callbacks.
38 *
39 * @author Spasi
40 */
41 final class CallbackUtil {
42
43 private static final Map<CLContext, Long> contextUserData = new HashMap<CLContext, Long>();
44
45 private CallbackUtil() {}
46
47 /**
48 * Creates a new global reference to the specified Object.
49 *
50 * @param obj the Object
51 *
52 * @return the GlobalRef memory address or 0 if the Object is null.
53 */
54 static long createGlobalRef(final Object obj) {
55 return obj == null ? 0 : ncreateGlobalRef(obj);
56 }
57
58 /**
59 * Creates a new global reference to the specified Object.
60 *
61 * @param obj the Object
62 *
63 * @return the GlobalRef memory address.
64 */
65 private static native long ncreateGlobalRef(Object obj);
66
67 /**
68 * Deletes a global reference.
69 *
70 * @param ref the GlobalRef memory address.
71 */
72 private static native void deleteGlobalRef(long ref);
73
74 /**
75 * Deletes the global reference represented by user_data if an OpenCL error occured.
76 *
77 * @param errcode the error code
78 * @param user_data the GlobalRef memory address
79 */
80 static void checkCallback(final int errcode, final long user_data) {
81 if ( errcode != 0x0 && user_data != 0 )
82 deleteGlobalRef(user_data);
83 }
84
85 /* [ Context callback functionality ]
86 This is a little weird, so here's an explanation of what's happening for future reference:
87 Before making the clCreateContext call we create a global reference to the CLContextCallback object (using JNI's NewGlobalRef function).
88 We pass that global reference to the user_data parameter of clCreateContext. If clCreateContext returns anything but CL_SUCCESS, we
89 immediately destroy the global reference to avoid the memory leak. If the new context was created successfully, we associate the context
90 with the global reference in the contextUserData HashMap. On a future call to clReleaseContext, we clear that association and destroy the
91 global reference (if the reference count is 0).
92 */
93
94 /**
95 * Returns the memory address of the native function we pass to clCreateContext(FromType).
96 *
97 * @return the callback function address
98 */
99 static native long getContextCallback();
100
101 /**
102 * Associates the specified CLContext with the specified global reference. If the context
103 * is invalid, the global reference is deleted. NO-OP if user_data is 0.
104 *
105 * @param context the CLContext to register
106 * @param user_data the global reference pointer
107 */
108 static void registerCallback(final CLContext context, final long user_data) {
109 if ( context.getPointerUnsafe() == 0 ) {
110 if ( user_data != 0 )
111 deleteGlobalRef(user_data);
112 return;
113 }
114
115 if ( user_data != 0 )
116 contextUserData.put(context, user_data);
117 }
118
119 /**
120 * Decrements the specified context's reference count, clears its association
121 * with a CLContextCallback object if it exists and deletes the corresponding
122 * global reference.
123 *
124 * @param context the CLContext to unregister
125 */
126 static void unregisterCallback(final CLContext context) {
127 if ( context.release() > 0 )
128 return;
129
130 final Long user_data = contextUserData.remove(context);
131
132 if ( user_data != null )
133 deleteGlobalRef(user_data);
134 }
135
136 /* [ Other callback functionality ]
137 The other callbacks are simpler. We create the GlobalRef before passing the callback,
138 we delete it when we receive the callback call.
139 */
140
141 /**
142 * Returns the memory address of the native function we pass to clSetMemObjectDestructorCallback.
143 *
144 * @return the callback function address
145 */
146 static native long getMemObjectDestructorCallback();
147
148 /**
149 * Returns the memory address of the native function we pass to clBuildProgram.
150 *
151 * @return the callback function address
152 */
153 static native long getBuildProgramCallback();
154
155 /**
156 * Returns the memory address of the native function we pass to clEnqueueNativeKernel.
157 *
158 * @return the callback function address
159 */
160 static native long getNativeKernelCallback();
161
162 /**
163 * Returns the memory address of the native function we pass to clSetEventCallback.
164 *
165 * @return the callback function address
166 */
167 static native long getEventCallback();
168
169 /**
170 * Returns the memory address of the native function we pass to clCreateContext(FromType),
171 * when <code>APPLEContextLoggingUtil.SYSTEM_LOG_CALLBACK</code> is used.
172 *
173 * @return the callback function address
174 *
175 * @see APPLEContextLoggingUtil#SYSTEM_LOG_CALLBACK
176 */
177 static native long getLogMessageToSystemLogAPPLE();
178
179 /**
180 * Returns the memory address of the native function we pass to clCreateContext(FromType),
181 * when <code>APPLEContextLoggingUtil.STD_OUT_CALLBACK</code> is used.
182 *
183 * @return the callback function address
184 *
185 * @see APPLEContextLoggingUtil#STD_OUT_CALLBACK
186 */
187 static native long getLogMessageToStdoutAPPLE();
188
189 /**
190 * Returns the memory address of the native function we pass to clCreateContext(FromType),
191 * when <code>APPLEContextLoggingUtil.STD_ERR_CALLBACK</code> is used.
192 *
193 * @return the callback function address
194 *
195 * @see APPLEContextLoggingUtil#STD_ERR_CALLBACK
196 */
197 static native long getLogMessageToStderrAPPLE();
198
199 }
0 /*
1 * Copyright 2002-2004 The Apache Software Foundation.
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
4 * License. You may obtain a copy of the License at
5 *
6 * http://www.apache.org/licenses/LICENSE-2.0
7 *
8 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS"
9 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language
10 * governing permissions and limitations under the License.
11 */
12 package org.lwjgl.opencl;
13
14 import java.util.Iterator;
15
16 /**
17 * A hash map using primitive longs as keys rather than objects.
18 *
19 * @author Justin Couch
20 * @author Alex Chaffee (alex@apache.org)
21 * @author Stephen Colebourne
22 * @author Nathan Sweet
23 */
24 final class FastLongMap<V> implements Iterable<FastLongMap.Entry<V>> {
25
26 private Entry[] table;
27 private int size, mask, capacity, threshold;
28
29 /** Same as: FastLongMap(16, 0.75f); */
30 FastLongMap() {
31 this(16, 0.75f);
32 }
33
34 /** Same as: FastLongMap(initialCapacity, 0.75f); */
35 FastLongMap(int initialCapacity) {
36 this(initialCapacity, 0.75f);
37 }
38
39 FastLongMap(int initialCapacity, float loadFactor) {
40 if ( initialCapacity > 1 << 30 ) throw new IllegalArgumentException("initialCapacity is too large.");
41 if ( initialCapacity < 0 ) throw new IllegalArgumentException("initialCapacity must be greater than zero.");
42 if ( loadFactor <= 0 ) throw new IllegalArgumentException("initialCapacity must be greater than zero.");
43 capacity = 1;
44 while ( capacity < initialCapacity )
45 capacity <<= 1;
46 this.threshold = (int)(capacity * loadFactor);
47 this.table = new Entry[capacity];
48 this.mask = capacity - 1;
49 }
50
51 private int index(final long key) {
52 return index(key, mask);
53 }
54
55 private static int index(final long key, final int mask) {
56 final int hash = (int)(key ^ (key >>> 32));
57 return hash & mask;
58 }
59
60 public V put(long key, V value) {
61 final Entry<V>[] table = this.table;
62 int index = index(key);
63
64 // Check if key already exists.
65 for ( Entry<V> e = table[index]; e != null; e = e.next ) {
66 if ( e.key != key ) continue;
67 V oldValue = e.value;
68 e.value = value;
69 return oldValue;
70 }
71
72 table[index] = new Entry<V>(key, value, table[index]);
73
74 if ( size++ >= threshold )
75 rehash(table);
76
77 return null;
78 }
79
80 private void rehash(final Entry<V>[] table) {
81 final int newCapacity = 2 * capacity;
82 final int newMask = newCapacity - 1;
83
84 final Entry<V>[] newTable = new Entry[newCapacity];
85
86 for ( int i = 0, index; i < table.length; i++ ) {
87 Entry<V> e = table[i];
88 if ( e == null ) continue;
89 do {
90 final Entry<V> next = e.next;
91 index = index(e.key, newMask);
92 e.next = newTable[index];
93 newTable[index] = e;
94 e = next;
95 } while ( e != null );
96 }
97
98 this.table = newTable;
99 capacity = newCapacity;
100 mask = newMask;
101 threshold *= 2;
102 }
103
104 public V get(long key) {
105 final int index = index(key);
106 for ( Entry<V> e = table[index]; e != null; e = e.next )
107 if ( e.key == key ) return e.value;
108 return null;
109 }
110
111 public boolean containsValue(Object value) {
112 final Entry<V>[] table = this.table;
113 for ( int i = table.length - 1; i >= 0; i-- )
114 for ( Entry<V> e = table[i]; e != null; e = e.next )
115 if ( e.value.equals(value) ) return true;
116 return false;
117 }
118
119 public boolean containsKey(long key) {
120 final int index = index(key);
121 for ( Entry<V> e = table[index]; e != null; e = e.next )
122 if ( e.key == key ) return true;
123 return false;
124 }
125
126 public V remove(long key) {
127 final int index = index(key);
128
129 Entry<V> prev = table[index];
130 Entry<V> e = prev;
131 while ( e != null ) {
132 Entry<V> next = e.next;
133 if ( e.key == key ) {
134 size--;
135 if ( prev == e )
136 table[index] = next;
137 else
138 prev.next = next;
139 return e.value;
140 }
141 prev = e;
142 e = next;
143 }
144 return null;
145 }
146
147 public int size() {
148 return size;
149 }
150
151 public boolean isEmpty() {
152 return size == 0;
153 }
154
155 public void clear() {
156 final Entry<V>[] table = this.table;
157 for ( int index = table.length - 1; index >= 0; index-- )
158 table[index] = null;
159 size = 0;
160 }
161
162 public EntryIterator iterator() {
163 return new EntryIterator();
164 }
165
166 public class EntryIterator implements Iterator<Entry<V>> {
167
168 private int nextIndex;
169 private Entry<V> current;
170
171 EntryIterator() {
172 reset();
173 }
174
175 public void reset() {
176 current = null;
177 // Find first bucket.
178 final Entry<V>[] table = FastLongMap.this.table;
179 int i;
180 for ( i = table.length - 1; i >= 0; i-- )
181 if ( table[i] != null ) break;
182 nextIndex = i;
183 }
184
185 public boolean hasNext() {
186 if ( nextIndex >= 0 ) return true;
187 Entry e = current;
188 return e != null && e.next != null;
189 }
190
191 public Entry<V> next() {
192 // Next entry in current bucket.
193 Entry<V> e = current;
194 if ( e != null ) {
195 e = e.next;
196 if ( e != null ) {
197 current = e;
198 return e;
199 }
200 }
201 // Use the bucket at nextIndex and find the next nextIndex.
202 final Entry<V>[] table = FastLongMap.this.table;
203 int i = nextIndex;
204 e = current = table[i];
205 while ( --i >= 0 )
206 if ( table[i] != null ) break;
207 nextIndex = i;
208 return e;
209 }
210
211 public void remove() {
212 FastLongMap.this.remove(current.key);
213 }
214 }
215
216 static final class Entry<T> {
217
218 final long key;
219 T value;
220 Entry<T> next;
221
222 Entry(long key, T value, Entry<T> next) {
223 this.key = key;
224 this.value = value;
225 this.next = next;
226 }
227
228 public long getKey() {
229 return key;
230 }
231
232 public T getValue() {
233 return value;
234 }
235
236 }
237
238 }
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.opencl;
32
33 /**
34 * Base interface for information utility classes.
35 *
36 * @author Spasi
37 */
38 interface InfoUtil<T extends CLObject> {
39
40 int getInfoInt(final T object, final int param_name);
41
42 long getInfoSize(final T object, final int param_name);
43
44 long[] getInfoSizeArray(final T object, final int param_name);
45
46 long getInfoLong(final T object, final int param_name);
47
48 String getInfoString(final T object, final int param_name);
49
50 }
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.opencl;
32
33 import org.lwjgl.LWJGLUtil;
34 import org.lwjgl.PointerBuffer;
35
36 import java.nio.ByteBuffer;
37
38 import static org.lwjgl.opencl.CL10.*;
39
40 /**
41 * Base implementation of information utility classes.
42 *
43 * @author Spasi
44 */
45 abstract class InfoUtilAbstract<T extends CLObject> implements InfoUtil<T> {
46
47 protected InfoUtilAbstract() {
48 }
49
50 protected abstract int getInfo(T object, int param_name, ByteBuffer param_value, PointerBuffer param_value_size_ret);
51
52 // Optional
53
54 protected int getInfoSizeArraySize(final T object, final int param_name) {
55 throw new UnsupportedOperationException();
56 }
57
58 protected PointerBuffer getSizesBuffer(final T object, final int param_name) {
59 final int size = getInfoSizeArraySize(object, param_name);
60
61 final PointerBuffer buffer = APIUtil.getBufferPointer(size);
62 buffer.limit(size);
63
64 getInfo(object, param_name, buffer.getBuffer(), null);
65
66 return buffer;
67 }
68
69 public int getInfoInt(final T object, final int param_name) {
70 object.checkValid();
71
72 final ByteBuffer buffer = APIUtil.getBufferByte(4);
73 getInfo(object, param_name, buffer, null);
74
75 return buffer.getInt(0);
76 }
77
78 public long getInfoSize(final T object, final int param_name) {
79 object.checkValid();
80
81 final PointerBuffer buffer = APIUtil.getBufferPointer();
82 getInfo(object, param_name, buffer.getBuffer(), null);
83
84 return buffer.get(0);
85 }
86
87 public long[] getInfoSizeArray(final T object, final int param_name) {
88 object.checkValid();
89
90 final int size = getInfoSizeArraySize(object, param_name);
91 final PointerBuffer buffer = APIUtil.getBufferPointer(size);
92
93 getInfo(object, param_name, buffer.getBuffer(), null);
94
95 final long[] array = new long[size];
96 for ( int i = 0; i < size; i++ )
97 array[i] = buffer.get(i);
98
99 return array;
100 }
101
102 public long getInfoLong(final T object, final int param_name) {
103 object.checkValid();
104
105 final ByteBuffer buffer = APIUtil.getBufferByte(8);
106 getInfo(object, param_name, buffer, null);
107
108 return buffer.getLong(0);
109 }
110
111 public String getInfoString(final T object, final int param_name) {
112 object.checkValid();
113
114 final int bytes = getSizeRet(object, param_name);
115 if ( bytes <= 1 )
116 return null;
117
118 final ByteBuffer buffer = APIUtil.getBufferByte(bytes);
119 getInfo(object, param_name, buffer, null);
120
121 buffer.limit(bytes - 1); // Exclude null-termination
122 return APIUtil.getString(buffer);
123 }
124
125 protected final int getSizeRet(final T object, final int param_name) {
126 final PointerBuffer bytes = APIUtil.getBufferPointer();
127 final int errcode = getInfo(object, param_name, null, bytes);
128 if ( errcode != CL_SUCCESS )
129 throw new IllegalArgumentException("Invalid parameter specified: " + LWJGLUtil.toHexString(param_name));
130
131 return (int)bytes.get(0);
132 }
133
134 }
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.opencl;
32
33 import org.lwjgl.*;
34 import org.lwjgl.opencl.api.CLBufferRegion;
35 import org.lwjgl.opencl.api.CLImageFormat;
36 import org.lwjgl.opencl.api.Filter;
37 import org.lwjgl.opengl.Drawable;
38
39 import java.nio.Buffer;
40 import java.nio.ByteBuffer;
41 import java.nio.IntBuffer;
42 import java.util.ArrayList;
43 import java.util.List;
44
45 import static org.lwjgl.opencl.CL10.*;
46 import static org.lwjgl.opencl.CL10GL.*;
47 import static org.lwjgl.opencl.CL11.*;
48
49 /**
50 * This class contains concrete InfoUtil implementations for our CLObject
51 * class. The public CLObject classes are grabbing these via reflection,
52 * so that they can be compiled for the generator.
53 *
54 * @author Spasi
55 */
56 final class InfoUtilFactory {
57
58 private InfoUtilFactory() {}
59
60 static final InfoUtil<CLCommandQueue> CL_COMMAND_QUEUE_UTIL = new InfoUtilAbstract<CLCommandQueue>() {
61 protected int getInfo(final CLCommandQueue object, final int param_name, final ByteBuffer param_value, final PointerBuffer param_value_size_ret) {
62 return clGetCommandQueueInfo(object, param_name, param_value, null);
63 }
64 };
65
66 static final CLContext.CLContextUtil CL_CONTEXT_UTIL = new CLContextUtil();
67 private static final class CLContextUtil extends InfoUtilAbstract<CLContext> implements CLContext.CLContextUtil {
68
69 protected int getInfo(final CLContext context, final int param_name, final ByteBuffer param_value, final PointerBuffer param_value_size_ret) {
70 return clGetContextInfo(context, param_name, param_value, param_value_size_ret);
71 }
72
73 public List<CLDevice> getInfoDevices(final CLContext context) {
74 context.checkValid();
75
76 final int num_devices;
77
78 if ( CLCapabilities.getPlatformCapabilities(context.getParent()).OpenCL11 )
79 num_devices = getInfoInt(context, CL_CONTEXT_NUM_DEVICES);
80 else {
81 final PointerBuffer size_ret = APIUtil.getBufferPointer();
82 clGetContextInfo(context, CL_CONTEXT_DEVICES, null, size_ret);
83 num_devices = (int)(size_ret.get(0) / PointerBuffer.getPointerSize());
84 }
85
86 final PointerBuffer deviceIDs = APIUtil.getBufferPointer(num_devices);
87 clGetContextInfo(context, CL_CONTEXT_DEVICES, deviceIDs.getBuffer(), null);
88
89 final List<CLDevice> devices = new ArrayList<CLDevice>(num_devices);
90 for ( int i = 0; i < num_devices; i++ )
91 devices.add(context.getParent().getCLDevice(deviceIDs.get(i)));
92
93 return devices.size() == 0 ? null : devices;
94
95 }
96
97 /** Custom clCreateContext implementation (reuses APIUtil.getBufferPointer) */
98 public CLContext create(final CLPlatform platform, final List<CLDevice> devices, final CLContextCallback pfn_notify, final Drawable share_drawable, IntBuffer errcode_ret) throws LWJGLException {
99 final int propertyCount = 2 + (share_drawable == null ? 0 : 4) + 1;
100
101 final PointerBuffer properties = APIUtil.getBufferPointer(propertyCount + devices.size());
102 properties.put(CL_CONTEXT_PLATFORM).put(platform);
103 if ( share_drawable != null )
104 share_drawable.setCLSharingProperties(properties);
105 properties.put(0);
106
107 properties.position(propertyCount); // Make sure we're at the right offset, setCLSharingProperties might not use all 4 positions.
108 for ( CLDevice device : devices )
109 properties.put(device);
110
111 final long function_pointer = CLCapabilities.clCreateContext;
112 BufferChecks.checkFunctionAddress(function_pointer);
113 if ( errcode_ret != null )
114 BufferChecks.checkBuffer(errcode_ret, 1);
115 else if ( LWJGLUtil.DEBUG )
116 errcode_ret = APIUtil.getBufferInt();
117 final long user_data = pfn_notify == null || pfn_notify.isCustom() ? 0 : CallbackUtil.createGlobalRef(pfn_notify);
118 CLContext __result = null;
119 try {
120 __result = new CLContext(nclCreateContext(properties.getBuffer(), 0, devices.size(), properties.getBuffer(), propertyCount * PointerBuffer.getPointerSize(), pfn_notify == null ? 0 : pfn_notify.getPointer(), user_data, errcode_ret, errcode_ret != null ? errcode_ret.position() : 0, function_pointer), platform);
121 if ( LWJGLUtil.DEBUG )
122 Util.checkCLError(errcode_ret.get(0));
123 return __result;
124 } finally {
125 CallbackUtil.registerCallback(__result, user_data);
126 }
127 }
128
129 public CLContext createFromType(final CLPlatform platform, final long device_type, final CLContextCallback pfn_notify, final Drawable share_drawable, final IntBuffer errcode_ret) throws LWJGLException {
130 final int propertyCount = 2 + (share_drawable == null ? 0 : 4) + 1;
131
132 final PointerBuffer properties = APIUtil.getBufferPointer(propertyCount);
133 properties.put(CL_CONTEXT_PLATFORM).put(platform);
134 if ( share_drawable != null )
135 share_drawable.setCLSharingProperties(properties);
136 properties.put(0);
137 properties.flip();
138
139 return clCreateContextFromType(properties, device_type, pfn_notify, errcode_ret);
140 }
141
142 public List<CLImageFormat> getSupportedImageFormats(final CLContext context, final long flags, final int image_type, final Filter<CLImageFormat> filter) {
143 final IntBuffer numBuffer = APIUtil.getBufferInt();
144 clGetSupportedImageFormats(context, flags, image_type, null, numBuffer);
145
146 final int num_image_formats = numBuffer.get(0);
147 if ( num_image_formats == 0 )
148 return null;
149
150 final ByteBuffer formatBuffer = BufferUtils.createByteBuffer(num_image_formats * CLImageFormat.STRUCT_SIZE);
151 clGetSupportedImageFormats(context, flags, image_type, formatBuffer, null);
152
153 final List<CLImageFormat> formats = new ArrayList<CLImageFormat>(num_image_formats);
154 for ( int i = 0; i < num_image_formats; i++ ) {
155 final int offset = num_image_formats * CLImageFormat.STRUCT_SIZE;
156 final CLImageFormat format = new CLImageFormat(
157 formatBuffer.getInt(offset),
158 formatBuffer.getInt(offset + 4)
159 );
160 if ( filter == null || filter.accept(format) )
161 formats.add(format);
162 }
163
164 return formats.size() == 0 ? null : formats;
165 }
166
167 }
168
169 static final InfoUtil<CLDevice> CL_DEVICE_UTIL = new CLDeviceUtil();
170 private static final class CLDeviceUtil extends InfoUtilAbstract<CLDevice> {
171
172 protected int getInfo(final CLDevice device, final int param_name, final ByteBuffer param_value, final PointerBuffer param_value_size_ret) {
173 return clGetDeviceInfo(device, param_name, param_value, param_value_size_ret);
174 }
175
176 protected int getInfoSizeArraySize(final CLDevice device, final int param_name) {
177 switch ( param_name ) {
178 case CL_DEVICE_MAX_WORK_ITEM_SIZES:
179 return getInfoInt(device, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS);
180 default:
181 throw new IllegalArgumentException("Unsupported parameter: " + LWJGLUtil.toHexString(param_name));
182 }
183 }
184
185 }
186
187 static final CLEvent.CLEventUtil CL_EVENT_UTIL = new CLEventUtil();
188 private static final class CLEventUtil extends InfoUtilAbstract<CLEvent> implements CLEvent.CLEventUtil {
189
190 protected int getInfo(final CLEvent event, final int param_name, final ByteBuffer param_value, final PointerBuffer param_value_size_ret) {
191 return clGetEventInfo(event, param_name, param_value, param_value_size_ret);
192 }
193
194 public long getProfilingInfoLong(final CLEvent event, final int param_name) {
195 event.checkValid();
196
197 final ByteBuffer buffer = APIUtil.getBufferByte(8);
198 clGetEventProfilingInfo(event, param_name, buffer, null);
199
200 return buffer.getLong(0);
201 }
202
203 }
204
205 static final CLKernel.CLKernelUtil CL_KERNEL_UTIL = new CLKernelUtil();
206 private static final class CLKernelUtil extends InfoUtilAbstract<CLKernel> implements CLKernel.CLKernelUtil {
207
208 public void setArg(final CLKernel kernel, final int index, final byte value) {
209 clSetKernelArg(kernel, index, 1, APIUtil.getBufferByte(1).put(0, value));
210 }
211
212 public void setArg(final CLKernel kernel, final int index, final short value) {
213 clSetKernelArg(kernel, index, 2, APIUtil.getBufferShort().put(0, value));
214 }
215
216 public void setArg(final CLKernel kernel, final int index, final int value) {
217 clSetKernelArg(kernel, index, 4, APIUtil.getBufferInt().put(0, value));
218 }
219
220 public void setArg(final CLKernel kernel, final int index, final long value) {
221 clSetKernelArg(kernel, index, 8, APIUtil.getBufferLong().put(0, value));
222 }
223
224 public void setArg(final CLKernel kernel, final int index, final float value) {
225 clSetKernelArg(kernel, index, 4, APIUtil.getBufferFloat().put(0, value));
226 }
227
228 public void setArg(final CLKernel kernel, final int index, final double value) {
229 clSetKernelArg(kernel, index, 8, APIUtil.getBufferDouble().put(0, value));
230 }
231
232 public void setArg(final CLKernel kernel, final int index, final CLObject value) {
233 clSetKernelArg(kernel, index, value);
234 }
235
236 public void setArgSize(final CLKernel kernel, final int index, final long size) {
237 clSetKernelArg(kernel, index, size);
238 }
239
240 protected int getInfo(final CLKernel kernel, final int param_name, final ByteBuffer param_value, final PointerBuffer param_value_size_ret) {
241 return clGetKernelInfo(kernel, param_name, param_value, param_value_size_ret);
242 }
243
244 public long getWorkGroupInfoSize(final CLKernel kernel, final CLDevice device, final int param_name) {
245 device.checkValid();
246
247 final PointerBuffer buffer = APIUtil.getBufferPointer();
248 clGetKernelWorkGroupInfo(kernel, device, param_name, buffer.getBuffer(), null);
249
250 return buffer.get(0);
251 }
252
253 public long[] getWorkGroupInfoSizeArray(final CLKernel kernel, final CLDevice device, final int param_name) {
254 device.checkValid();
255
256 final int size;
257 switch ( param_name ) {
258 case CL_KERNEL_WORK_GROUP_SIZE:
259 size = 3;
260 break;
261 default:
262 throw new IllegalArgumentException("Unsupported parameter: " + LWJGLUtil.toHexString(param_name));
263 }
264
265 final PointerBuffer buffer = APIUtil.getBufferPointer(size);
266
267 clGetKernelWorkGroupInfo(kernel, device, param_name, buffer.getBuffer(), null);
268
269 final long[] array = new long[size];
270 for ( int i = 0; i < size; i++ )
271 array[i] = buffer.get(i);
272
273 return array;
274 }
275
276 public long getWorkGroupInfoLong(final CLKernel kernel, final CLDevice device, final int param_name) {
277 device.checkValid();
278
279 final ByteBuffer buffer = APIUtil.getBufferByte(8);
280 clGetKernelWorkGroupInfo(kernel, device, param_name, buffer, null);
281
282 return buffer.getLong(0);
283 }
284
285 }
286
287 static final CLMem.CLMemUtil CL_MEM_UTIL = new CLMemUtil();
288 private static final class CLMemUtil extends InfoUtilAbstract<CLMem> implements CLMem.CLMemUtil {
289
290 protected int getInfo(final CLMem mem, final int param_name, final ByteBuffer param_value, final PointerBuffer param_value_size_ret) {
291 return clGetMemObjectInfo(mem, param_name, param_value, param_value_size_ret);
292 }
293
294 public CLMem createImage2D(final CLContext context, final long flags, final CLImageFormat image_format, final long image_width, final long image_height, final long image_row_pitch, final Buffer host_ptr, IntBuffer errcode_ret) {
295 final ByteBuffer formatBuffer = APIUtil.getBufferByte(2 * 4);
296 formatBuffer.putInt(0, image_format.getChannelOrder());
297 formatBuffer.putInt(4, image_format.getChannelType());
298
299 final long function_pointer = CLCapabilities.clCreateImage2D;
300 BufferChecks.checkFunctionAddress(function_pointer);
301 if ( errcode_ret != null )
302 BufferChecks.checkBuffer(errcode_ret, 1);
303 else if ( LWJGLUtil.DEBUG )
304 errcode_ret = APIUtil.getBufferInt();
305
306 CLMem __result = new CLMem(nclCreateImage2D(context.getPointer(), flags, formatBuffer, 0, image_width, image_height, image_row_pitch, host_ptr,
307 host_ptr != null ? BufferChecks.checkBuffer(host_ptr, CLChecks.calculateImage2DSize(formatBuffer, image_width, image_height, image_row_pitch)) : 0,
308 errcode_ret, errcode_ret != null ? errcode_ret.position() : 0, function_pointer), context);
309 if ( LWJGLUtil.DEBUG )
310 Util.checkCLError(errcode_ret.get(0));
311 return __result;
312 }
313
314 public CLMem createImage3D(final CLContext context, final long flags, final CLImageFormat image_format, final long image_width, final long image_height, final long image_depth, final long image_row_pitch, final long image_slice_pitch, final Buffer host_ptr, IntBuffer errcode_ret) {
315 final ByteBuffer formatBuffer = APIUtil.getBufferByte(2 * 4);
316 formatBuffer.putInt(0, image_format.getChannelOrder());
317 formatBuffer.putInt(4, image_format.getChannelType());
318
319 final long function_pointer = CLCapabilities.clCreateImage3D;
320 BufferChecks.checkFunctionAddress(function_pointer);
321 if ( errcode_ret != null )
322 BufferChecks.checkBuffer(errcode_ret, 1);
323 else if ( LWJGLUtil.DEBUG )
324 errcode_ret = APIUtil.getBufferInt();
325
326 CLMem __result = new CLMem(nclCreateImage3D(context.getPointer(), flags, formatBuffer, 0, image_width, image_height, image_depth, image_row_pitch, image_slice_pitch, host_ptr,
327 host_ptr != null ? BufferChecks.checkBuffer(host_ptr, CLChecks.calculateImage3DSize(formatBuffer, image_width, image_height, image_depth, image_row_pitch, image_slice_pitch)) : 0,
328 errcode_ret, errcode_ret != null ? errcode_ret.position() : 0, function_pointer), context);
329 if ( LWJGLUtil.DEBUG )
330 Util.checkCLError(errcode_ret.get(0));
331 return __result;
332 }
333
334 public CLMem createSubBuffer(final CLMem mem, final long flags, final int buffer_create_type, final CLBufferRegion buffer_create_info, final IntBuffer errcode_ret) {
335 final PointerBuffer infoBuffer = APIUtil.getBufferPointer(2);
336
337 infoBuffer.put(buffer_create_info.getOrigin());
338 infoBuffer.put(buffer_create_info.getSize());
339
340 return clCreateSubBuffer(mem, flags, buffer_create_type, infoBuffer.getBuffer(), errcode_ret);
341 }
342
343 public ByteBuffer getInfoHostBuffer(final CLMem mem) {
344 mem.checkValid();
345
346 if ( LWJGLUtil.DEBUG ) {
347 final long mem_flags = getInfoLong(mem, CL_MEM_FLAGS);
348 if ( (mem_flags & CL_MEM_USE_HOST_PTR) != CL_MEM_USE_HOST_PTR )
349 throw new IllegalArgumentException("The specified CLMem object does not use host memory.");
350 }
351
352 final long size = getInfoSize(mem, CL_MEM_SIZE);
353 if ( size == 0 )
354 return null;
355
356 final long address = getInfoSize(mem, CL_MEM_HOST_PTR);
357
358 return CL.getHostBuffer(address, (int)size);
359 }
360
361 public long getImageInfoSize(final CLMem mem, final int param_name) {
362 mem.checkValid();
363
364 final PointerBuffer buffer = APIUtil.getBufferPointer();
365 clGetImageInfo(mem, param_name, buffer.getBuffer(), null);
366
367 return buffer.get(0);
368 }
369
370 public CLImageFormat getImageInfoFormat(final CLMem mem) {
371 mem.checkValid();
372
373 final ByteBuffer format = APIUtil.getBufferByte(2 * 4);
374
375 clGetImageInfo(mem, CL_IMAGE_FORMAT, format, null);
376
377 return new CLImageFormat(format.getInt(0), format.getInt(4));
378 }
379
380 public int getImageInfoFormat(final CLMem mem, final int index) {
381 mem.checkValid();
382
383 final ByteBuffer format = APIUtil.getBufferByte(2 * 4);
384
385 clGetImageInfo(mem, CL_IMAGE_FORMAT, format, null);
386
387 return format.getInt(index << 2);
388 }
389
390 public int getGLObjectType(final CLMem mem) {
391 mem.checkValid();
392
393 final IntBuffer buffer = APIUtil.getBufferInt();
394 clGetGLObjectInfo(mem, buffer, null);
395
396 return buffer.get(0);
397 }
398
399 public int getGLObjectName(final CLMem mem) {
400 mem.checkValid();
401
402 final IntBuffer buffer = APIUtil.getBufferInt();
403 clGetGLObjectInfo(mem, null, buffer);
404
405 return buffer.get(0);
406 }
407
408 public int getGLTextureInfoInt(final CLMem mem, final int param_name) {
409 mem.checkValid();
410
411 final ByteBuffer buffer = APIUtil.getBufferByte(4);
412 clGetGLTextureInfo(mem, param_name, buffer, null);
413
414 return buffer.getInt(0);
415 }
416
417 }
418
419 static final CLPlatform.CLPlatformUtil CL_PLATFORM_UTIL = new CLPlatformUtil();
420 private static final class CLPlatformUtil extends InfoUtilAbstract<CLPlatform> implements CLPlatform.CLPlatformUtil {
421
422 protected int getInfo(final CLPlatform platform, final int param_name, final ByteBuffer param_value, final PointerBuffer param_value_size_ret) {
423 return clGetPlatformInfo(platform, param_name, param_value, param_value_size_ret);
424 }
425
426 public List<CLPlatform> getPlatforms(final Filter<CLPlatform> filter) {
427 final IntBuffer numBuffer = APIUtil.getBufferInt();
428 clGetPlatformIDs(null, numBuffer);
429
430 final int num_platforms = numBuffer.get(0);
431 if ( num_platforms == 0 )
432 return null;
433
434 final PointerBuffer platformIDs = APIUtil.getBufferPointer(num_platforms);
435 clGetPlatformIDs(platformIDs, null);
436
437 final List<CLPlatform> platforms = new ArrayList<CLPlatform>(num_platforms);
438 for ( int i = 0; i < num_platforms; i++ ) {
439 final CLPlatform platform = CLPlatform.getCLPlatform(platformIDs.get(i));
440 if ( filter == null || filter.accept(platform) )
441 platforms.add(platform);
442 }
443
444 return platforms.size() == 0 ? null : platforms;
445 }
446
447 public List<CLDevice> getDevices(final CLPlatform platform, final int device_type, final Filter<CLDevice> filter) {
448 platform.checkValid();
449
450 final IntBuffer numBuffer = APIUtil.getBufferInt();
451 clGetDeviceIDs(platform, device_type, null, numBuffer);
452
453 final int num_devices = numBuffer.get(0);
454 if ( num_devices == 0 )
455 return null;
456
457 final PointerBuffer deviceIDs = APIUtil.getBufferPointer(num_devices);
458 clGetDeviceIDs(platform, device_type, deviceIDs, null);
459
460 final List<CLDevice> devices = new ArrayList<CLDevice>(num_devices);
461 for ( int i = 0; i < num_devices; i++ ) {
462 final CLDevice device = platform.getCLDevice(deviceIDs.get(i));
463 if ( filter == null || filter.accept(device) )
464 devices.add(device);
465 }
466
467 return devices.size() == 0 ? null : devices;
468 }
469
470 }
471
472 static final CLProgram.CLProgramUtil CL_PROGRAM_UTIL = new CLProgramUtil();
473 private static final class CLProgramUtil extends InfoUtilAbstract<CLProgram> implements CLProgram.CLProgramUtil {
474
475 protected int getInfo(final CLProgram program, final int param_name, final ByteBuffer param_value, final PointerBuffer param_value_size_ret) {
476 return clGetProgramInfo(program, param_name, param_value, param_value_size_ret);
477 }
478
479 protected int getInfoSizeArraySize(final CLProgram program, final int param_name) {
480 switch ( param_name ) {
481 case CL_PROGRAM_BINARY_SIZES:
482 return getInfoInt(program, CL_PROGRAM_NUM_DEVICES);
483 default:
484 throw new IllegalArgumentException("Unsupported parameter: " + LWJGLUtil.toHexString(param_name));
485 }
486 }
487
488 public CLKernel[] createKernelsInProgram(final CLProgram program) {
489 final IntBuffer numBuffer = APIUtil.getBufferInt();
490 clCreateKernelsInProgram(program, null, numBuffer);
491
492 final int num_kernels = numBuffer.get(0);
493 if ( num_kernels == 0 )
494 return null;
495
496 final PointerBuffer kernelIDs = APIUtil.getBufferPointer(num_kernels);
497 clCreateKernelsInProgram(program, kernelIDs, null);
498
499 final CLKernel[] kernels = new CLKernel[num_kernels];
500 for ( int i = 0; i < num_kernels; i++ )
501 kernels[i] = program.getCLKernel(kernelIDs.get(i));
502
503 return kernels;
504 }
505
506 public CLDevice[] getInfoDevices(final CLProgram program) {
507 program.checkValid();
508
509 final int size = getInfoInt(program, CL_PROGRAM_NUM_DEVICES);
510 final PointerBuffer buffer = APIUtil.getBufferPointer(size);
511
512 clGetProgramInfo(program, CL_PROGRAM_DEVICES, buffer.getBuffer(), null);
513
514 final CLPlatform platform = program.getParent().getParent();
515 final CLDevice[] array = new CLDevice[size];
516 for ( int i = 0; i < size; i++ )
517 array[i] = platform.getCLDevice(buffer.get(i));
518
519 return array;
520 }
521
522 public ByteBuffer getInfoBinaries(final CLProgram program, ByteBuffer target) {
523 program.checkValid();
524
525 final PointerBuffer sizes = getSizesBuffer(program, CL_PROGRAM_BINARY_SIZES);
526
527 int totalSize = 0;
528 for ( int i = 0; i < sizes.limit(); i++ )
529 totalSize += sizes.get(i);
530
531 if ( target == null )
532 target = BufferUtils.createByteBuffer(totalSize);
533 else if ( LWJGLUtil.DEBUG )
534 BufferChecks.checkBuffer(target, totalSize);
535
536 clGetProgramInfo(program, sizes, target, null);
537
538 return target;
539 }
540
541 public ByteBuffer[] getInfoBinaries(final CLProgram program, ByteBuffer[] target) {
542 program.checkValid();
543
544 if ( target == null ) {
545 final PointerBuffer sizes = getSizesBuffer(program, CL_PROGRAM_BINARY_SIZES);
546
547 target = new ByteBuffer[sizes.remaining()];
548 for ( int i = 0; i < sizes.remaining(); i++ )
549 target[i] = BufferUtils.createByteBuffer((int)sizes.get(0));
550 } else if ( LWJGLUtil.DEBUG ) {
551 final PointerBuffer sizes = getSizesBuffer(program, CL_PROGRAM_BINARY_SIZES);
552
553 if ( target.length < sizes.remaining() )
554 throw new IllegalArgumentException("The target array is not big enough: " + sizes.remaining() + " buffers are required.");
555
556 for ( int i = 0; i < target.length; i++ )
557 BufferChecks.checkBuffer(target[i], (int)sizes.get(i));
558 }
559
560 clGetProgramInfo(program, target, null);
561
562 return target;
563 }
564
565 public String getBuildInfoString(final CLProgram program, final CLDevice device, final int param_name) {
566 program.checkValid();
567
568 final int bytes = getBuildSizeRet(program, device, param_name);
569 if ( bytes <= 1 )
570 return null;
571
572 final ByteBuffer buffer = APIUtil.getBufferByte(bytes);
573 clGetProgramBuildInfo(program, device, param_name, buffer, null);
574
575 buffer.limit(bytes - 1); // Exclude null-termination
576 return APIUtil.getString(buffer);
577 }
578
579 public int getBuildInfoInt(final CLProgram program, final CLDevice device, final int param_name) {
580 program.checkValid();
581
582 final ByteBuffer buffer = APIUtil.getBufferByte(4);
583 clGetProgramBuildInfo(program, device, param_name, buffer, null);
584
585 return buffer.getInt(0);
586 }
587
588 private static int getBuildSizeRet(final CLProgram program, final CLDevice device, final int param_name) {
589 final PointerBuffer bytes = APIUtil.getBufferPointer();
590 final int errcode = clGetProgramBuildInfo(program, device, param_name, null, bytes);
591 if ( errcode != CL_SUCCESS )
592 throw new IllegalArgumentException("Invalid parameter specified: " + LWJGLUtil.toHexString(param_name));
593
594 return (int)bytes.get(0);
595 }
596
597 }
598
599 static final InfoUtil<CLSampler> CL_SAMPLER_UTIL = new InfoUtilAbstract<CLSampler>() {
600 protected int getInfo(final CLSampler sampler, final int param_name, final ByteBuffer param_value, final PointerBuffer param_value_size_ret) {
601 return clGetSamplerInfo(sampler, param_name, param_value, param_value_size_ret);
602 }
603 };
604
605 }
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.opencl;
32
33 public class OpenCLException extends RuntimeException {
34
35 private static final long serialVersionUID = 1L;
36
37 public OpenCLException() {
38 super();
39 }
40
41 public OpenCLException(final String message) {
42 super(message);
43 }
44
45 public OpenCLException(final String message, final Throwable cause) {
46 super(message, cause);
47 }
48
49 public OpenCLException(final Throwable cause) {
50 super(cause);
51 }
52
53 }
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.opencl;
32
33 import org.lwjgl.LWJGLUtil;
34
35 import java.lang.reflect.Field;
36 import java.util.Map;
37
38 /**
39 * Utility methods for OpenCL
40 *
41 * @author Spasi
42 */
43 public final class Util {
44
45 /** Maps OpenCL error token values to their String representations. */
46 private static final Map<Integer, String> CL_ERROR_TOKENS = LWJGLUtil.getClassTokens(new LWJGLUtil.TokenFilter() {
47 public boolean accept(final Field field, final int value) {
48 return value < 0; // Currently, all OpenCL errors have negative values.
49 }
50 }, null, CL10.class, CL11.class, KHRGLSharing.class, KHRICD.class, APPLEGLSharing.class, EXTDeviceFission.class);
51
52 private Util() {
53 }
54
55 public static void checkCLError(final int errcode) {
56 if ( errcode != CL10.CL_SUCCESS )
57 throwCLError(errcode);
58 }
59
60 private static void throwCLError(final int errcode) {
61 String errname = CL_ERROR_TOKENS.get(errcode);
62 if ( errname == null )
63 errname = "UNKNOWN";
64 throw new OpenCLException("Error Code: " + errname + " (" + LWJGLUtil.toHexString(errcode) + ")");
65 }
66
67 }
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.opencl.api;
32
33 import org.lwjgl.PointerBuffer;
34
35 /**
36 * Simple container for cl_buffer_region struct values.
37 *
38 * @author Spasi
39 */
40 public final class CLBufferRegion {
41
42 /** The cl_buffer_region struct size in bytes. */
43 public static final int STRUCT_SIZE = 2 * PointerBuffer.getPointerSize();
44
45 private final int origin;
46 private final int size;
47
48 public CLBufferRegion(final int origin, final int size) {
49 this.origin = origin;
50 this.size = size;
51 }
52
53 public int getOrigin() {
54 return origin;
55 }
56
57 public int getSize() {
58 return size;
59 }
60
61 }
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.opencl.api;
32
33 /**
34 * Simple container for cl_image_format struct values.
35 *
36 * @author Spasi
37 */
38 public final class CLImageFormat {
39
40 /** The cl_image_format struct size in bytes. */
41 public static final int STRUCT_SIZE = 2 * 4;
42
43 private final int channelOrder;
44 private final int channelType;
45
46 public CLImageFormat(final int channelOrder, final int channelType) {
47 this.channelOrder = channelOrder;
48 this.channelType = channelType;
49 }
50
51 public int getChannelOrder() {
52 return channelOrder;
53 }
54
55 public int getChannelType() {
56 return channelType;
57 }
58
59 }
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
32 package org.lwjgl.opencl.api;
33
34 /**
35 * Simple filter interface.
36 *
37 * @author Spasi
38 */
39 public interface Filter<T> {
40
41 /**
42 * Returns true if the specified object passes the filter.
43 *
44 * @param object the object to test
45 *
46 * @return true if the object is accepted
47 */
48 boolean accept(T object);
49
50 }
3030 */
3131 package org.lwjgl.opengl;
3232
33 import org.lwjgl.PointerWrapperAbstract;
34
3335 /**
3436 * Instances of this class are needed to use the callback functionality of the AMD_debug_output extension.
3537 * A debug context must be current before creating instances of this class. Users of this class may provide
3840 *
3941 * @author Spasi
4042 */
41 public final class AMDDebugOutputCallback implements PointerWrapper {
43 public final class AMDDebugOutputCallback extends PointerWrapperAbstract {
4244
4345 /** Severity levels. */
4446 private static final int GL_DEBUG_SEVERITY_HIGH_AMD = 0x9146,
5557 GL_DEBUG_CATEGORY_APPLICATION_AMD = 0x914F,
5658 GL_DEBUG_CATEGORY_OTHER_AMD = 0x9150;
5759
58 private final long pointer;
60 private static final long CALLBACK_POINTER;
61
62 static {
63 long pointer = 0;
64 try {
65 // Call reflectively so that we can compile this class for the Generator.
66 pointer = (Long)Class.forName("org.lwjgl.opengl.CallbackUtil").getDeclaredMethod("getDebugOutputCallbackAMD").invoke(null);
67 } catch (Exception e) {
68 // ignore
69 }
70 CALLBACK_POINTER = pointer;
71 }
72
73 private final Handler handler;
5974
6075 /**
61 * Creates a AMDDebugOutputCallback with a default callback handler.
76 * Creates an AMDDebugOutputCallback with a default callback handler.
6277 * The default handler will simply print the message on System.err.
6378 */
6479 public AMDDebugOutputCallback() {
119134 }
120135
121136 /**
122 * Creates a AMDDebugOutputCallback with the specified callback handlers.
137 * Creates an AMDDebugOutputCallback with the specified callback handler.
123138 * The handler's {@code handleMessage} method will be called whenever
124139 * debug output is generated by the GL.
125140 *
126141 * @param handler the callback handler
127142 */
128143 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();
144 super(CALLBACK_POINTER);
145
146 this.handler = handler;
138147 }
139148
140 public long getPointer() {
141 return pointer;
149 Handler getHandler() {
150 return handler;
142151 }
143
144 private static native long getFunctionPointer();
145152
146153 /** Implementations of this interface can be used to receive AMD_debug_output notifications. */
147154 public interface Handler {
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.BufferUtils;
34 import org.lwjgl.LWJGLUtil;
35
36 import java.nio.*;
37
38 /** @author spasi */
39 final class APIUtil {
40
41 private static final int INITIAL_BUFFER_SIZE = 256;
42 private static final int INITIAL_LENGTHS_SIZE = 4;
43
44 private static final int BUFFERS_SIZE = 32;
45
46 private static final ThreadLocal<char[]> arrayTL = new ThreadLocal<char[]>() {
47 protected char[] initialValue() { return new char[INITIAL_BUFFER_SIZE]; }
48 };
49
50 private static final ThreadLocal<ByteBuffer> bufferTL = new ThreadLocal<ByteBuffer>() {
51 protected ByteBuffer initialValue() { return BufferUtils.createByteBuffer(INITIAL_BUFFER_SIZE); }
52 };
53
54 private static final ThreadLocal<IntBuffer> lengthsTL = new ThreadLocal<IntBuffer>() {
55 protected IntBuffer initialValue() { return BufferUtils.createIntBuffer(INITIAL_LENGTHS_SIZE); }
56 };
57
58 private static final ThreadLocal<Buffers> buffersTL = new ThreadLocal<Buffers>() {
59 protected Buffers initialValue() { return new Buffers(); }
60 };
61
62 private APIUtil() {
63 }
64
65 private static char[] getArray(final int size) {
66 char[] array = arrayTL.get();
67
68 if ( array.length < size ) {
69 int sizeNew = array.length << 1;
70 while ( sizeNew < size )
71 sizeNew <<= 1;
72
73 array = new char[size];
74 arrayTL.set(array);
75 }
76
77 return array;
78 }
79
80 static ByteBuffer getBufferByte(final int size) {
81 ByteBuffer buffer = bufferTL.get();
82
83 if ( buffer.capacity() < size ) {
84 int sizeNew = buffer.capacity() << 1;
85 while ( sizeNew < size )
86 sizeNew <<= 1;
87
88 buffer = BufferUtils.createByteBuffer(size);
89 bufferTL.set(buffer);
90 } else
91 buffer.clear();
92
93 return buffer;
94 }
95
96 private static ByteBuffer getBufferByteOffset(final int size) {
97 ByteBuffer buffer = bufferTL.get();
98
99 if ( buffer.capacity() < size ) {
100 int sizeNew = buffer.capacity() << 1;
101 while ( sizeNew < size )
102 sizeNew <<= 1;
103
104 final ByteBuffer bufferNew = BufferUtils.createByteBuffer(size);
105 bufferNew.put(buffer);
106 bufferTL.set(buffer = bufferNew);
107 } else {
108 buffer.position(buffer.limit());
109 buffer.limit(buffer.capacity());
110 }
111
112 return buffer;
113 }
114
115 static ShortBuffer getBufferShort() { return buffersTL.get().shorts; }
116
117 static IntBuffer getBufferInt() { return buffersTL.get().ints; }
118
119 static LongBuffer getBufferLong() { return buffersTL.get().longs; }
120
121 static FloatBuffer getBufferFloat() { return buffersTL.get().floats; }
122
123 static DoubleBuffer getBufferDouble() { return buffersTL.get().doubles; }
124
125 static IntBuffer getLengths() {
126 return getLengths(1);
127 }
128
129 static IntBuffer getLengths(final int size) {
130 IntBuffer lengths = lengthsTL.get();
131
132 if ( lengths.capacity() < size ) {
133 int sizeNew = lengths.capacity();
134 while ( sizeNew < size )
135 sizeNew <<= 1;
136
137 lengths = BufferUtils.createIntBuffer(size);
138 lengthsTL.set(lengths);
139 } else
140 lengths.clear();
141
142 return lengths;
143 }
144
145 /**
146 * Simple ASCII encoding.
147 *
148 * @param buffer The target buffer
149 * @param string The source string
150 */
151 private static ByteBuffer encode(final ByteBuffer buffer, final CharSequence string) {
152 for ( int i = 0; i < string.length(); i++ ) {
153 final char c = string.charAt(i);
154 if ( LWJGLUtil.DEBUG && 0x80 <= c ) // Silently ignore and map to 0x1A.
155 buffer.put((byte)0x1A);
156 else
157 buffer.put((byte)c);
158 }
159
160 return buffer;
161 }
162
163 /**
164 * Reads a byte string from the specified buffer.
165 *
166 * @param buffer
167 *
168 * @return the buffer as a String.
169 */
170 static String getString(final ByteBuffer buffer) {
171 final int length = buffer.remaining();
172 final char[] charArray = getArray(length);
173
174 for ( int i = buffer.position(); i < buffer.limit(); i++ )
175 charArray[i - buffer.position()] = (char)buffer.get(i);
176
177 return new String(charArray, 0, length);
178 }
179
180 /**
181 * Returns a buffer containing the specified string as bytes.
182 *
183 * @param string
184 *
185 * @return the String as a ByteBuffer
186 */
187 static ByteBuffer getBuffer(final CharSequence string) {
188 final ByteBuffer buffer = encode(getBufferByte(string.length()), string);
189 buffer.flip();
190 return buffer;
191 }
192
193 /**
194 * Returns a buffer containing the specified string as bytes, starting at the specified offset.
195 *
196 * @param string
197 *
198 * @return the String as a ByteBuffer
199 */
200 static ByteBuffer getBuffer(final CharSequence string, final int offset) {
201 final ByteBuffer buffer = encode(getBufferByteOffset(offset + string.length()), string);
202 buffer.flip();
203 return buffer;
204 }
205
206 /**
207 * Returns a buffer containing the specified string as bytes, including null-termination.
208 *
209 * @param string
210 *
211 * @return the String as a ByteBuffer
212 */
213 static ByteBuffer getBufferNT(final CharSequence string) {
214 final ByteBuffer buffer = encode(getBufferByte(string.length() + 1), string);
215 buffer.put((byte)0);
216 buffer.flip();
217 return buffer;
218 }
219
220 static int getTotalLength(final CharSequence[] strings) {
221 int length = 0;
222 for ( CharSequence string : strings )
223 length += string.length();
224
225 return length;
226 }
227
228 /**
229 * Returns a buffer containing the specified strings as bytes.
230 *
231 * @param strings
232 *
233 * @return the Strings as a ByteBuffer
234 */
235 static ByteBuffer getBuffer(final CharSequence[] strings) {
236 final ByteBuffer buffer = getBufferByte(getTotalLength(strings));
237
238 for ( CharSequence string : strings )
239 encode(buffer, string);
240
241 buffer.flip();
242 return buffer;
243 }
244
245 /**
246 * Returns a buffer containing the specified strings as bytes, including null-termination.
247 *
248 * @param strings
249 *
250 * @return the Strings as a ByteBuffer
251 */
252 static ByteBuffer getBufferNT(final CharSequence[] strings) {
253 final ByteBuffer buffer = getBufferByte(getTotalLength(strings) + strings.length);
254
255 for ( CharSequence string : strings ) {
256 encode(buffer, string);
257 buffer.put((byte)0);
258 }
259
260 buffer.flip();
261 return buffer;
262 }
263
264 /**
265 * Returns a buffer containing the lengths of the specified strings.
266 *
267 * @param strings
268 *
269 * @return the String lengths in an IntBuffer
270 */
271 static IntBuffer getLengths(final CharSequence[] strings) {
272 IntBuffer buffer = getLengths(strings.length);
273
274 for ( CharSequence string : strings )
275 buffer.put(string.length());
276
277 buffer.flip();
278 return buffer;
279 }
280
281 private static class Buffers {
282
283 final ShortBuffer shorts;
284 final IntBuffer ints;
285 final LongBuffer longs;
286
287 final FloatBuffer floats;
288 final DoubleBuffer doubles;
289
290 Buffers() {
291 shorts = BufferUtils.createShortBuffer(BUFFERS_SIZE);
292 ints = BufferUtils.createIntBuffer(BUFFERS_SIZE);
293 longs = BufferUtils.createLongBuffer(BUFFERS_SIZE);
294
295 floats = BufferUtils.createFloatBuffer(BUFFERS_SIZE);
296 doubles = BufferUtils.createDoubleBuffer(BUFFERS_SIZE);
297 }
298
299 }
300
301 }
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.PointerWrapperAbstract;
34
35 /**
36 * Instances of this class are needed to use the callback functionality of the ARB_debug_output extension.
37 * A debug context must be current before creating instances of this class. Users of this class may provide
38 * implementations of the {@code Handler} interface to receive notifications. The same {@code Handler}
39 * instance may be used by different contexts but it is not recommended. Handler notifications are synchronized.
40 *
41 * @author Spasi
42 */
43 public final class ARBDebugOutputCallback extends PointerWrapperAbstract {
44
45 /** Severity levels. */
46 private static final int
47 GL_DEBUG_SEVERITY_HIGH_ARB = 0x9146,
48 GL_DEBUG_SEVERITY_MEDIUM_ARB = 0x9147,
49 GL_DEBUG_SEVERITY_LOW_ARB = 0x9148;
50
51 /** Sources. */
52 private static final int
53 GL_DEBUG_SOURCE_API_ARB = 0x8246,
54 GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB = 0x8247,
55 GL_DEBUG_SOURCE_SHADER_COMPILER_ARB = 0x8248,
56 GL_DEBUG_SOURCE_THIRD_PARTY_ARB = 0x8249,
57 GL_DEBUG_SOURCE_APPLICATION_ARB = 0x824A,
58 GL_DEBUG_SOURCE_OTHER_ARB = 0x824B;
59
60 /** Types. */
61 private static final int
62 GL_DEBUG_TYPE_ERROR_ARB = 0x824C,
63 GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB = 0x824D,
64 GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB = 0x824E,
65 GL_DEBUG_TYPE_PORTABILITY_ARB = 0x824F,
66 GL_DEBUG_TYPE_PERFORMANCE_ARB = 0x8250,
67 GL_DEBUG_TYPE_OTHER_ARB = 0x8251;
68
69 private static final long CALLBACK_POINTER;
70
71 static {
72 long pointer = 0;
73 try {
74 // Call reflectively so that we can compile this class for the Generator.
75 pointer = (Long)Class.forName("org.lwjgl.opengl.CallbackUtil").getDeclaredMethod("getDebugOutputCallbackARB").invoke(null);
76 } catch (Exception e) {
77 // ignore
78 }
79 CALLBACK_POINTER = pointer;
80 }
81
82 private final Handler handler;
83
84 /**
85 * Creates an ARBDebugOutputCallback with a default callback handler.
86 * The default handler will simply print the message on System.err.
87 */
88 public ARBDebugOutputCallback() {
89 this(new Handler() {
90 public void handleMessage(final int source, final int type, final int id, final int severity, final String message) {
91 System.err.println("[LWJGL] ARB_debug_output message");
92 System.err.println("\tID: " + id);
93
94 String description;
95 switch ( source ) {
96 case GL_DEBUG_SOURCE_API_ARB:
97 description = "API";
98 break;
99 case GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB:
100 description = "WINDOW SYSTEM";
101 break;
102 case GL_DEBUG_SOURCE_SHADER_COMPILER_ARB:
103 description = "SHADER COMPILER";
104 break;
105 case GL_DEBUG_SOURCE_THIRD_PARTY_ARB:
106 description = "THIRD PARTY";
107 break;
108 case GL_DEBUG_SOURCE_APPLICATION_ARB:
109 description = "APPLICATION";
110 break;
111 case GL_DEBUG_SOURCE_OTHER_ARB:
112 description = "OTHER";
113 break;
114 default:
115 description = "Unknown (" + Integer.toHexString(source) + ")";
116 }
117 System.err.println("\tSource: " + description);
118
119 switch ( type ) {
120 case GL_DEBUG_TYPE_ERROR_ARB:
121 description = "ERROR";
122 break;
123 case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB:
124 description = "DEPRECATED BEHAVIOR";
125 break;
126 case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB:
127 description = "UNDEFINED BEHAVIOR";
128 break;
129 case GL_DEBUG_TYPE_PORTABILITY_ARB:
130 description = "PORTABILITY";
131 break;
132 case GL_DEBUG_TYPE_PERFORMANCE_ARB:
133 description = "PERFORMANCE";
134 break;
135 case GL_DEBUG_TYPE_OTHER_ARB:
136 description = "OTHER";
137 break;
138 default:
139 description = "Unknown (" + Integer.toHexString(source) + ")";
140 }
141 System.err.println("\tType: " + description);
142
143 switch ( severity ) {
144 case GL_DEBUG_SEVERITY_HIGH_ARB:
145 description = "HIGH";
146 break;
147 case GL_DEBUG_SEVERITY_MEDIUM_ARB:
148 description = "MEDIUM";
149 break;
150 case GL_DEBUG_SEVERITY_LOW_ARB:
151 description = "LOW";
152 break;
153 default:
154 description = "Unknown (" + Integer.toHexString(source) + ")";
155 }
156 System.err.println("\tSeverity: " + description);
157
158 System.err.println("\tMessage: " + message);
159 }
160 });
161 }
162
163 /**
164 * Creates an ARBDebugOutputCallback with the specified callback handler.
165 * The handler's {@code handleMessage} method will be called whenever
166 * debug output is generated by the GL.
167 *
168 * @param handler the callback handler
169 */
170 public ARBDebugOutputCallback(final Handler handler) {
171 super(CALLBACK_POINTER);
172
173 this.handler = handler;
174 }
175
176 Handler getHandler() {
177 return handler;
178 }
179
180 /** Implementations of this interface can be used to receive ARB_debug_output notifications. */
181 public interface Handler {
182
183 /**
184 * This method will be called when an ARB_debug_output message is generated.
185 *
186 * @param id the message ID
187 * @param source the message source
188 * @param type the message type
189 * @param severity the message severity
190 * @param message the string representation of the message.
191 */
192 void handleMessage(int source, int type, int id, int severity, String message);
193
194 }
195
196 }
3232
3333 import org.lwjgl.LWJGLException;
3434 import org.lwjgl.LWJGLUtil;
35 import org.lwjgl.PointerBuffer;
3536 import org.lwjgl.Sys;
3637
3738 import java.awt.*;
4647 * <p/>
4748 *
4849 * @author $Author: spasi $
49 * $Id: AWTGLCanvas.java 3334 2010-04-22 23:21:48Z spasi $
50 * @version $Revision: 3334 $
50 * $Id: AWTGLCanvas.java 3418 2010-09-28 21:11:35Z spasi $
51 * @version $Revision: 3418 $
5152 */
5253 public class AWTGLCanvas extends Canvas implements DrawableLWJGL, ComponentListener, HierarchyListener {
5354
5455 private static final long serialVersionUID = 1L;
5556
56 private final static AWTCanvasImplementation implementation;
57 private static final AWTCanvasImplementation implementation;
5758 private boolean update_context;
5859 private Object SYNC_LOCK = new Object();
5960
254255 } catch (LWJGLException e) {
255256 throw new RuntimeException(e);
256257 }
258 }
259 }
260
261 public final void setCLSharingProperties(final PointerBuffer properties) throws LWJGLException {
262 synchronized ( SYNC_LOCK ) {
263 if ( context == null )
264 throw new IllegalStateException("Canvas not yet displayable");
265 context.setCLSharingProperties(properties);
257266 }
258267 }
259268
4242 /**
4343 *
4444 * @author elias_naur <elias_naur@users.sourceforge.net>
45 * @version $Revision: 3116 $
46 * $Id: AWTSurfaceLock.java 3116 2008-08-19 16:46:03Z spasi $
45 * @version $Revision: 3418 $
46 * $Id: AWTSurfaceLock.java 3418 2010-09-28 21:11:35Z spasi $
4747 */
4848 final class AWTSurfaceLock {
4949
50 private final static int WAIT_DELAY_MILLIS = 100;
50 private static final int WAIT_DELAY_MILLIS = 100;
5151
5252 private final ByteBuffer lock_buffer;
5353
54 private boolean firstLockSucceeded = false;
54 private boolean firstLockSucceeded;
5555
5656 AWTSurfaceLock() {
5757 lock_buffer = createHandle();
8282 return lockAndInitHandle(lock_buffer, component);
8383 else
8484 try {
85 final Object result = AccessController.doPrivileged(new PrivilegedExceptionAction() {
86
87 public Object run() throws LWJGLException {
88 return Boolean.valueOf(lockAndInitHandle(lock_buffer, component));
85 firstLockSucceeded = AccessController.doPrivileged(new PrivilegedExceptionAction<Boolean>() {
86 public Boolean run() throws LWJGLException {
87 return lockAndInitHandle(lock_buffer, component);
8988 }
9089 });
91 firstLockSucceeded = ((Boolean) result).booleanValue();
9290 return firstLockSucceeded;
9391 } catch (PrivilegedActionException e) {
9492 throw (LWJGLException) e.getException();
8686
8787 public static Robot createRobot(final Component component) {
8888 try {
89 Robot robot = (Robot)AccessController.doPrivileged(new PrivilegedExceptionAction() {
90 public Object run() throws Exception {
89 return AccessController.doPrivileged(new PrivilegedExceptionAction<Robot>() {
90 public Robot run() throws Exception {
9191 return new Robot(component.getGraphicsConfiguration().getDevice());
9292 }
9393 });
94 return robot;
9594 } catch (PrivilegedActionException e) {
9695 LWJGLUtil.log("Got exception while creating robot: " + e.getCause());
9796 return null;
111110 try {
112111 final GraphicsConfiguration config = component.getGraphicsConfiguration();
113112 if (config != null) {
114 PointerInfo pointer_info = (PointerInfo)AccessController.doPrivileged(new PrivilegedExceptionAction() {
115 public Object run() throws Exception {
113 PointerInfo pointer_info = AccessController.doPrivileged(new PrivilegedExceptionAction<PointerInfo>() {
114 public PointerInfo run() throws Exception {
116115 return MouseInfo.getPointerInfo();
117116 }
118117 });
122121 }
123122 return null;
124123 }
125 } catch (PrivilegedActionException e) {
124 } catch (Exception e) {
126125 LWJGLUtil.log("Failed to query pointer location: " + e.getCause());
127126 }
128127 return null;
11
22 import org.lwjgl.LWJGLException;
33 import org.lwjgl.LWJGLUtil;
4 import org.lwjgl.PointerBuffer;
45
56 /**
67 * @author Spasi
7273 }
7374 }
7475
76 public void setCLSharingProperties(final PointerBuffer properties) throws LWJGLException {
77 synchronized ( GlobalLock.lock ) {
78 checkDestroyed();
79 context.setCLSharingProperties(properties);
80 }
81 }
82
7583 protected final void checkDestroyed() {
7684 if ( context == null )
7785 throw new IllegalStateException("The Drawable has no context available.");
3333 import java.nio.Buffer;
3434 import java.util.Arrays;
3535
36 import static org.lwjgl.opengl.GL11.*;
37 import static org.lwjgl.opengl.GL13.*;
38 import static org.lwjgl.opengl.GL20.*;
39
3640 class BaseReferences {
3741
38 int elementArrayBuffer;
39 int arrayBuffer;
40 Buffer[] glVertexAttribPointer_buffer;
41 Buffer[] glTexCoordPointer_buffer;
42 int elementArrayBuffer;
43 int arrayBuffer;
44 final Buffer[] glVertexAttribPointer_buffer;
45 final Buffer[] glTexCoordPointer_buffer;
4246 int glClientActiveTexture;
47
48 int vertexArrayObject;
4349
4450 int pixelPackBuffer;
4551 int pixelUnpackBuffer;
4854
4955 BaseReferences(ContextCapabilities caps) {
5056 int max_vertex_attribs;
51 if (caps.OpenGL20 || caps.GL_ARB_vertex_shader)
52 max_vertex_attribs = GL11.glGetInteger(ARBVertexShader.GL_MAX_VERTEX_ATTRIBS_ARB);
57 if ( caps.OpenGL20 || caps.GL_ARB_vertex_shader )
58 max_vertex_attribs = glGetInteger(GL_MAX_VERTEX_ATTRIBS);
5359 else
5460 max_vertex_attribs = 0;
55 glVertexAttribPointer_buffer = new Buffer[max_vertex_attribs];
61 glVertexAttribPointer_buffer = new Buffer[max_vertex_attribs];
5662
5763 int max_texture_units;
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);
64 if ( caps.OpenGL20 )
65 max_texture_units = glGetInteger(GL_MAX_TEXTURE_IMAGE_UNITS);
66 else if ( caps.OpenGL13 || caps.GL_ARB_multitexture )
67 max_texture_units = glGetInteger(GL_MAX_TEXTURE_UNITS);
6268 else
6369 max_texture_units = 1;
64 glTexCoordPointer_buffer = new Buffer[max_texture_units];
65 }
70 glTexCoordPointer_buffer = new Buffer[max_texture_units];
71 }
6672
67 void clear() {
68 this.elementArrayBuffer = 0;
69 this.arrayBuffer = 0;
70 this.glClientActiveTexture = 0;
71 Arrays.fill(glVertexAttribPointer_buffer, null);
72 Arrays.fill(glTexCoordPointer_buffer, null);
73 void clear() {
74 this.elementArrayBuffer = 0;
75 this.arrayBuffer = 0;
76 this.glClientActiveTexture = 0;
77 Arrays.fill(glVertexAttribPointer_buffer, null);
78 Arrays.fill(glTexCoordPointer_buffer, null);
7379
74 this.pixelPackBuffer = 0;
75 this.pixelUnpackBuffer = 0;
80 this.vertexArrayObject = 0;
7681
77 this.indirectBuffer = 0;
78 }
82 this.pixelPackBuffer = 0;
83 this.pixelUnpackBuffer = 0;
7984
80 void copy(BaseReferences references, int mask) {
81 if ( (mask & GL11.GL_CLIENT_VERTEX_ARRAY_BIT) != 0 ) {
82 this.elementArrayBuffer = references.elementArrayBuffer;
83 this.arrayBuffer = references.arrayBuffer;
84 this.glClientActiveTexture = references.glClientActiveTexture;
85 System.arraycopy(references.glVertexAttribPointer_buffer, 0, glVertexAttribPointer_buffer, 0, glVertexAttribPointer_buffer.length);
86 System.arraycopy(references.glTexCoordPointer_buffer, 0, glTexCoordPointer_buffer, 0, glTexCoordPointer_buffer.length);
85 this.indirectBuffer = 0;
86 }
8787
88 this.indirectBuffer = references.indirectBuffer;
89 }
88 void copy(BaseReferences references, int mask) {
89 if ( (mask & GL_CLIENT_VERTEX_ARRAY_BIT) != 0 ) {
90 this.elementArrayBuffer = references.elementArrayBuffer;
91 this.arrayBuffer = references.arrayBuffer;
92 this.glClientActiveTexture = references.glClientActiveTexture;
93 System.arraycopy(references.glVertexAttribPointer_buffer, 0, glVertexAttribPointer_buffer, 0, glVertexAttribPointer_buffer.length);
94 System.arraycopy(references.glTexCoordPointer_buffer, 0, glTexCoordPointer_buffer, 0, glTexCoordPointer_buffer.length);
9095
91 if ( (mask & GL11.GL_CLIENT_PIXEL_STORE_BIT) != 0 ) {
96 this.vertexArrayObject = references.vertexArrayObject;
97
98 this.indirectBuffer = references.indirectBuffer;
99 }
100
101 if ( (mask & GL_CLIENT_PIXEL_STORE_BIT) != 0 ) {
92102 this.pixelPackBuffer = references.pixelPackBuffer;
93103 this.pixelUnpackBuffer = references.pixelUnpackBuffer;
94 }
95 }
104 }
105 }
96106 }
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.opengl;
32
33 import java.util.HashMap;
34 import java.util.Map;
35
36 /**
37 * Utility class that handles OpenGL API callbacks.
38 *
39 * @author Spasi
40 */
41 final class CallbackUtil {
42
43 /** Context -> Long */
44 private static final Map<Context, Long> contextUserParamsARB = new HashMap<Context, Long>();
45 /** Context -> Long */
46 private static final Map<Context, Long> contextUserParamsAMD = new HashMap<Context, Long>();
47
48 private CallbackUtil() {}
49
50 /**
51 * Creates a new global reference to the specified Object.
52 *
53 * @param obj the Object
54 *
55 * @return the GlobalRef memory address or 0 if the Object is null.
56 */
57 static long createGlobalRef(final Object obj) {
58 return obj == null ? 0 : ncreateGlobalRef(obj);
59 }
60
61 /**
62 * Creates a new global reference to the specified Object.
63 *
64 * @param obj the Object
65 *
66 * @return the GlobalRef memory address.
67 */
68 private static native long ncreateGlobalRef(Object obj);
69
70 /**
71 * Deletes a global reference.
72 *
73 * @param ref the GlobalRef memory address.
74 */
75 private static native void deleteGlobalRef(long ref);
76
77 // --------- [ XXX_debug_output ] ---------
78
79 /**
80 * Associates the current OpenGL context with the specified global reference. If there
81 * is no context current, the global reference is deleted and an exception is thrown.
82 * Any previous callback registrations will be cleared.
83 *
84 * @param userParam the global reference pointer
85 */
86 private static void registerContextCallback(final long userParam, final Map<Context, Long> contextUserData) {
87 Context context = Context.getCurrentContext();
88 if ( context == null ) {
89 deleteGlobalRef(userParam);
90 throw new IllegalStateException("No context is current.");
91 }
92
93 final Long userParam_old = contextUserData.remove(context);
94 if ( userParam_old != null )
95 deleteGlobalRef(userParam_old);
96
97 if ( userParam != 0 )
98 contextUserData.put(context, userParam);
99 }
100
101 /**
102 * Releases references to any callbacks associated with the specified GL context.
103 *
104 * @param context the Context to unregister
105 */
106 static void unregisterCallbacks(final Context context) {
107 Long userParam = contextUserParamsARB.remove(context);
108 if ( userParam != null )
109 deleteGlobalRef(userParam);
110
111 userParam = contextUserParamsAMD.remove(context);
112 if ( userParam != null )
113 deleteGlobalRef(userParam);
114 }
115
116 // --------- [ ARB_debug_output ] ---------
117
118 /**
119 * Returns the memory address of the native function we pass to glDebugMessageCallbackARB.
120 *
121 * @return the callback function address
122 */
123 static native long getDebugOutputCallbackARB();
124
125 /**
126 * Associates the current OpenGL context with the specified global reference. If there
127 * is no context current, the global reference is deleted and an exception is thrown.
128 * Any previous callback registrations will be cleared.
129 *
130 * @param userParam the global reference pointer
131 */
132 static void registerContextCallbackARB(final long userParam) {
133 registerContextCallback(userParam, contextUserParamsARB);
134 }
135
136 // --------- [ AMD_debug_output ] ---------
137
138 /**
139 * Returns the memory address of the native function we pass to glDebugMessageCallbackAMD.
140 *
141 * @return the callback function address
142 */
143 static native long getDebugOutputCallbackAMD();
144
145 /**
146 * Associates the current OpenGL context with the specified global reference. If there
147 * is no context current, the global reference is deleted and an exception is thrown.
148 * Any previous callback registrations will be cleared.
149 *
150 * @param userParam the global reference pointer
151 */
152 static void registerContextCallbackAMD(final long userParam) {
153 registerContextCallback(userParam, contextUserParamsAMD);
154 }
155
156 }
3232
3333 import org.lwjgl.LWJGLException;
3434 import org.lwjgl.LWJGLUtil;
35 import org.lwjgl.PointerBuffer;
3536 import org.lwjgl.Sys;
37 import org.lwjgl.opencl.KHRGLSharing;
3638
3739 import java.nio.ByteBuffer;
3840 import java.nio.IntBuffer;
41
42 import static org.lwjgl.opengl.GL11.*;
3943
4044 /**
4145 * <p/>
4549 * This class is thread-safe.
4650 *
4751 * @author elias_naur <elias_naur@users.sourceforge.net>
48 * @version $Revision: 3332 $
49 * $Id: Context.java 3332 2010-04-20 18:21:05Z spasi $
52 * @version $Revision: 3418 $
53 * $Id: Context.java 3418 2010-09-28 21:11:35Z spasi $
5054 */
5155 final class Context {
5256
5357 /** The platform specific implementation of context methods */
54 private final static ContextImplementation implementation;
58 private static final ContextImplementation implementation;
5559
5660 /** The current Context */
57 private final static ThreadLocal current_context_local = new ThreadLocal();
61 private static final ThreadLocal<Context> current_context_local = new ThreadLocal<Context>();
5862
5963 /** Handle to the native GL rendering context */
6064 private final ByteBuffer handle;
98102 }
99103
100104 static Context getCurrentContext() {
101 return (Context)current_context_local.get();
105 return current_context_local.get();
102106 }
103107
104108 /** Create a context with the specified peer info and shared context */
205209 try {
206210 releaseDrawable();
207211 implementation.destroy(peer_info, handle);
212 CallbackUtil.unregisterCallbacks(this);
208213 destroyed = true;
209214 thread = null;
210215 GLContext.unloadOpenGLLibrary();
244249 return;
245250 destroy_requested = true;
246251 boolean was_current = isCurrent();
247 int error = GL11.GL_NO_ERROR;
252 int error = GL_NO_ERROR;
248253 if ( was_current ) {
249254 if ( GLContext.getCapabilities() != null && GLContext.getCapabilities().OpenGL11 )
250 error = GL11.glGetError();
255 error = glGetError();
251256 releaseCurrentContext();
252257 }
253258 checkDestroy();
254 if ( was_current && error != GL11.GL_NO_ERROR )
259 if ( was_current && error != GL_NO_ERROR )
255260 throw new OpenGLException(error);
256261 }
257262
263 public synchronized void setCLSharingProperties(final PointerBuffer properties) throws LWJGLException {
264 final ByteBuffer peer_handle = peer_info.lockAndGetHandle();
265 try {
266 switch ( LWJGLUtil.getPlatform() ) {
267 case LWJGLUtil.PLATFORM_WINDOWS:
268 final WindowsContextImplementation implWindows = (WindowsContextImplementation)implementation;
269 properties.put(KHRGLSharing.CL_GL_CONTEXT_KHR).put(implWindows.getHGLRC(handle));
270 properties.put(KHRGLSharing.CL_WGL_HDC_KHR).put(implWindows.getHDC(peer_handle));
271 break;
272 case LWJGLUtil.PLATFORM_LINUX:
273 final LinuxContextImplementation implLinux = (LinuxContextImplementation)implementation;
274 properties.put(KHRGLSharing.CL_GL_CONTEXT_KHR).put(implLinux.getGLXContext(handle));
275 properties.put(KHRGLSharing.CL_GLX_DISPLAY_KHR).put(implLinux.getDisplay(peer_handle));
276 break;
277 default:
278 throw new UnsupportedOperationException("CL/GL context sharing is not supposed on this platform.");
279 }
280 } finally {
281 peer_info.unlock();
282 }
283 }
284
258285 }
5555 */
5656 public final class ContextAttribs {
5757
58 // Same values for GLX & WGL
59 private static final int CONTEXT_ES2_PROFILE_BIT_EXT = 0x00000004;
60
61 private static final int CONTEXT_ROBUST_ACCESS_BIT_ARB = 0x00000004;
62 private static final int CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB = 0x8256;
63 private static final int
64 NO_RESET_NOTIFICATION_ARB = 0x8261,
65 LOSE_CONTEXT_ON_RESET_ARB = 0x8252;
66
5867 private int majorVersion;
5968 private int minorVersion;
6069
6271
6372 private boolean debug;
6473 private boolean forwardCompatible;
74 private boolean robustAccess;
6575
6676 private boolean profileCore;
6777 private boolean profileCompatibility;
78 private boolean profileES;
79
80 private boolean loseContextOnReset;
6881
6982 public ContextAttribs() {
7083 this(1, 0);
8194
8295 this.majorVersion = majorVersion;
8396 this.minorVersion = minorVersion;
84
85 this.layerPlane = 0;
86
87 this.debug = false;
88 this.forwardCompatible = false;
89
90 this.profileCore = false;
91 this.profileCompatibility = false;
9297 }
9398
9499 private ContextAttribs(final ContextAttribs attribs) {
99104
100105 this.debug = attribs.debug;
101106 this.forwardCompatible = attribs.forwardCompatible;
107 this.robustAccess = attribs.robustAccess;
102108
103109 this.profileCore = attribs.profileCore;
104110 this.profileCompatibility = attribs.profileCompatibility;
111 this.profileES = attribs.profileES;
112
113 this.loseContextOnReset = attribs.loseContextOnReset;
105114 }
106115
107116 public int getMajorVersion() {
130139
131140 public boolean isProfileCompatibility() {
132141 return profileCompatibility;
142 }
143
144 public boolean isProfileES() {
145 return profileES;
133146 }
134147
135148 public ContextAttribs withLayer(final int layerPlane) {
189202 if ( profileCompatibility )
190203 attribs.profileCore = false;
191204
205 return attribs;
206 }
207
208 public ContextAttribs withProfileES(final boolean profileES) {
209 if ( !(majorVersion == 2 && minorVersion == 0) )
210 throw new IllegalArgumentException("The OpenGL ES profiles is only supported for OpenGL version 2.0.");
211
212 if ( profileES == this.profileES )
213 return this;
214
215 final ContextAttribs attribs = new ContextAttribs(this);
216 attribs.profileES = profileES;
217
218 return attribs;
219 }
220
221 /**
222 * Returns a ContextAttribs instance with CONTEXT_RESET_NOTIFICATION_STRATEGY set
223 * to LOSE_CONTEXT_ON_RESET if the parameter is true or to NO_RESET_NOTIFICATION
224 * if the parameter is false.
225 *
226 * @param loseContextOnReset
227 *
228 * @return the new ContextAttribs
229 */
230 public ContextAttribs withLoseContextOnReset(final boolean loseContextOnReset) {
231 if ( loseContextOnReset == this.loseContextOnReset )
232 return this;
233
234 final ContextAttribs attribs = new ContextAttribs(this);
235 attribs.loseContextOnReset = loseContextOnReset;
192236 return attribs;
193237 }
194238
220264 flags |= implementation.getDebugBit();
221265 if ( forwardCompatible )
222266 flags |= implementation.getForwardCompatibleBit();
267 if ( robustAccess )
268 flags |= CONTEXT_ROBUST_ACCESS_BIT_ARB;
223269 if ( 0 < flags )
224270 attribCount++;
225271
228274 profileMask |= implementation.getProfileCoreBit();
229275 else if ( profileCompatibility )
230276 profileMask |= implementation.getProfileCompatibilityBit();
277 else if ( profileES )
278 profileMask |= CONTEXT_ES2_PROFILE_BIT_EXT;
231279 if ( 0 < profileMask )
232280 attribCount++;
233281
246294 attribs.put(implementation.getFlagsAttrib()).put(flags);
247295 if ( 0 < profileMask )
248296 attribs.put(implementation.getProfileMaskAttrib()).put(profileMask);
297 if ( loseContextOnReset )
298 attribs.put(CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB).put(LOSE_CONTEXT_ON_RESET_ARB);
249299
250300 attribs.put(0);
251301 attribs.rewind();
253303 }
254304
255305 public String toString() {
256 StringBuffer sb = new StringBuffer(32);
306 StringBuilder sb = new StringBuilder(32);
257307
258308 sb.append("ContextAttribs:");
259309 sb.append(" Version=").append(majorVersion).append('.').append(minorVersion);
260310 sb.append(" - Layer=").append(layerPlane);
261311 sb.append(" - Debug=").append(debug);
262312 sb.append(" - ForwardCompatible=").append(forwardCompatible);
313 sb.append(" - RobustAccess=").append(robustAccess);
314 if ( robustAccess )
315 sb.append(" (").append(loseContextOnReset ? "LOSE_CONTEXT_ON_RESET" : "NO_RESET_NOTIFICATION");
263316 sb.append(" - Profile=");
264317 if ( profileCore )
265318 sb.append("Core");
6161 import java.util.Arrays;
6262 import java.util.HashSet;
6363
64 import static org.lwjgl.opengl.GL11.*;
65
6466 public final class Display {
6567
6668 private static final Thread shutdown_hook = new Thread() {
113115 private static boolean parent_resized;
114116
115117 /** Initial Background Color of Display */
116 private static float r = 0, g = 0, b = 0;
117
118 private static ComponentListener component_listener = new ComponentAdapter() {
118 private static float r, g, b;
119
120 private static final ComponentListener component_listener = new ComponentAdapter() {
119121 public void componentResized(ComponentEvent e) {
120122 synchronized ( GlobalLock.lock ) {
121123 parent_resized = true;
200202 }
201203
202204 // We'll use a HashSet to filter out the duplicated modes
203 HashSet modes = new HashSet(unfilteredModes.length);
205 HashSet<DisplayMode> modes = new HashSet<DisplayMode>(unfilteredModes.length);
204206
205207 modes.addAll(Arrays.asList(unfilteredModes));
206208 DisplayMode[] filteredModes = new DisplayMode[modes.size()];
637639 * Swap the display buffers. This method is called from update(), and should normally not be called by
638640 * the application.
639641 *
640 * @throws OpenGLException if an OpenGL error has occured since the last call to GL11.glGetError()
642 * @throws OpenGLException if an OpenGL error has occured since the last call to glGetError()
641643 */
642644 public static void swapBuffers() throws LWJGLException {
643645 synchronized ( GlobalLock.lock ) {
730732 }
731733
732734 private static void removeShutdownHook() {
733 AccessController.doPrivileged(new PrivilegedAction() {
735 AccessController.doPrivileged(new PrivilegedAction<Object>() {
734736 public Object run() {
735737 Runtime.getRuntime().removeShutdownHook(shutdown_hook);
736738 return null;
739741 }
740742
741743 private static void registerShutdownHook() {
742 AccessController.doPrivileged(new PrivilegedAction() {
744 AccessController.doPrivileged(new PrivilegedAction<Object>() {
743745 public Object run() {
744746 Runtime.getRuntime().addShutdownHook(shutdown_hook);
745747 return null;
902904
903905 private static void initContext() {
904906 // set background clear color
905 GL11.glClearColor(r, g, b, 1.0f);
907 glClearColor(r, g, b, 0.0f);
906908 // Clear window to avoid the desktop "showing through"
907 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
909 glClear(GL_COLOR_BUFFER_BIT);
908910 update();
909911 }
910912
914916
915917 /** Gets a boolean property as a privileged action. */
916918 static boolean getPrivilegedBoolean(final String property_name) {
917 Boolean value = (Boolean)AccessController.doPrivileged(new PrivilegedAction() {
918 public Object run() {
919 return new Boolean(Boolean.getBoolean(property_name));
919 return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
920 public Boolean run() {
921 return Boolean.getBoolean(property_name);
920922 }
921923 });
922 return value.booleanValue();
923924 }
924925
925926 private static void initControls() {
3737 * getAvailableDisplayModes()</code> method.
3838 *
3939 * @author cix_foo <cix_foo@users.sourceforge.net>
40 * @version $Revision: 3171 $
41 * $Id: DisplayMode.java 3171 2008-12-28 17:50:08Z elias_naur $
40 * @version $Revision: 3418 $
41 * $Id: DisplayMode.java 3418 2010-09-28 21:11:35Z spasi $
4242 */
4343
4444 public final class DisplayMode {
127127 * @see java.lang.Object#toString()
128128 */
129129 public String toString() {
130 StringBuffer sb = new StringBuffer(32);
130 StringBuilder sb = new StringBuilder(32);
131131 sb.append(width);
132132 sb.append(" x ");
133133 sb.append(height);
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.LWJGLException;
34 import org.lwjgl.PointerBuffer;
3435
3536 /**
3637 * The Drawable interface describes an OpenGL drawable with an associated
6162 /** Destroys the Drawable. */
6263 void destroy();
6364
65 /**
66 * Sets the appropriate khr_gl_sharing properties in the target <code>PointerBuffer</code>,
67 * so that if it is used in a <code>clCreateContext(FromType)</code> call, the created CL
68 * context will be sharing objects with this <code>Drawable</code>'s GL context. After a
69 * call to this method, the target buffer position will have advanced by 2 to 4 positions,
70 * depending on the implementation.
71 *
72 * @param properties The target properties buffer. It must have at least 4 positions remaining.
73 */
74 void setCLSharingProperties(PointerBuffer properties) throws LWJGLException;
75
6476 }
0 /*
1 * Copyright 2002-2004 The Apache Software Foundation.
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
4 * License. You may obtain a copy of the License at
5 *
6 * http://www.apache.org/licenses/LICENSE-2.0
7 *
8 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS"
9 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language
10 * governing permissions and limitations under the License.
11 */
12 package org.lwjgl.opengl;
13
14 import java.util.Iterator;
15
16 /**
17 * A hash map using primitive ints as keys rather than objects.
18 *
19 * @author Justin Couch
20 * @author Alex Chaffee (alex@apache.org)
21 * @author Stephen Colebourne
22 * @author Nathan Sweet
23 */
24 final class FastIntMap<V> implements Iterable<FastIntMap.Entry<V>> {
25
26 private Entry[] table;
27 private int size, mask, capacity, threshold;
28
29 /** Same as: FastIntMap(16, 0.75f); */
30 FastIntMap() {
31 this(16, 0.75f);
32 }
33
34 /** Same as: FastIntMap(initialCapacity, 0.75f); */
35 FastIntMap(int initialCapacity) {
36 this(initialCapacity, 0.75f);
37 }
38
39 FastIntMap(int initialCapacity, float loadFactor) {
40 if ( initialCapacity > 1 << 30 ) throw new IllegalArgumentException("initialCapacity is too large.");
41 if ( initialCapacity < 0 ) throw new IllegalArgumentException("initialCapacity must be greater than zero.");
42 if ( loadFactor <= 0 ) throw new IllegalArgumentException("initialCapacity must be greater than zero.");
43 capacity = 1;
44 while ( capacity < initialCapacity )
45 capacity <<= 1;
46 this.threshold = (int)(capacity * loadFactor);
47 this.table = new Entry[capacity];
48 this.mask = capacity - 1;
49 }
50
51 private int index(final int key) {
52 return index(key, mask);
53 }
54
55 private static int index(final int key, final int mask) {
56 return key & mask;
57 }
58
59 public V put(int key, V value) {
60 final Entry<V>[] table = this.table;
61 int index = index(key);
62
63 // Check if key already exists.
64 for ( Entry<V> e = table[index]; e != null; e = e.next ) {
65 if ( e.key != key ) continue;
66 V oldValue = e.value;
67 e.value = value;
68 return oldValue;
69 }
70
71 table[index] = new Entry<V>(key, value, table[index]);
72
73 if ( size++ >= threshold )
74 rehash(table);
75
76 return null;
77 }
78
79 private void rehash(final Entry<V>[] table) {
80 final int newCapacity = 2 * capacity;
81 final int newMask = newCapacity - 1;
82
83 final Entry<V>[] newTable = new Entry[newCapacity];
84
85 for ( int i = 0, index; i < table.length; i++ ) {
86 Entry<V> e = table[i];
87 if ( e == null ) continue;
88 do {
89 final Entry<V> next = e.next;
90 index = index(e.key, newMask);
91 e.next = newTable[index];
92 newTable[index] = e;
93 e = next;
94 } while ( e != null );
95 }
96
97 this.table = newTable;
98 capacity = newCapacity;
99 mask = newMask;
100 threshold *= 2;
101 }
102
103 public V get(int key) {
104 final int index = index(key);
105 for ( Entry<V> e = table[index]; e != null; e = e.next )
106 if ( e.key == key ) return e.value;
107 return null;
108 }
109
110 public boolean containsValue(Object value) {
111 final Entry<V>[] table = this.table;
112 for ( int i = table.length - 1; i >= 0; i-- )
113 for ( Entry<V> e = table[i]; e != null; e = e.next )
114 if ( e.value.equals(value) ) return true;
115 return false;
116 }
117
118 public boolean containsKey(int key) {
119 final int index = index(key);
120 for ( Entry<V> e = table[index]; e != null; e = e.next )
121 if ( e.key == key ) return true;
122 return false;
123 }
124
125 public V remove(int key) {
126 final int index = index(key);
127
128 Entry<V> prev = table[index];
129 Entry<V> e = prev;
130 while ( e != null ) {
131 Entry<V> next = e.next;
132 if ( e.key == key ) {
133 size--;
134 if ( prev == e )
135 table[index] = next;
136 else
137 prev.next = next;
138 return e.value;
139 }
140 prev = e;
141 e = next;
142 }
143 return null;
144 }
145
146 public int size() {
147 return size;
148 }
149
150 public boolean isEmpty() {
151 return size == 0;
152 }
153
154 public void clear() {
155 final Entry<V>[] table = this.table;
156 for ( int index = table.length - 1; index >= 0; index-- )
157 table[index] = null;
158 size = 0;
159 }
160
161 public EntryIterator iterator() {
162 return new EntryIterator();
163 }
164
165 public class EntryIterator implements Iterator<Entry<V>> {
166
167 private int nextIndex;
168 private Entry<V> current;
169
170 EntryIterator() {
171 reset();
172 }
173
174 public void reset() {
175 current = null;
176 // Find first bucket.
177 final Entry<V>[] table = FastIntMap.this.table;
178 int i;
179 for ( i = table.length - 1; i >= 0; i-- )
180 if ( table[i] != null ) break;
181 nextIndex = i;
182 }
183
184 public boolean hasNext() {
185 if ( nextIndex >= 0 ) return true;
186 Entry e = current;
187 return e != null && e.next != null;
188 }
189
190 public Entry<V> next() {
191 // Next entry in current bucket.
192 Entry<V> e = current;
193 if ( e != null ) {
194 e = e.next;
195 if ( e != null ) {
196 current = e;
197 return e;
198 }
199 }
200 // Use the bucket at nextIndex and find the next nextIndex.
201 final Entry<V>[] table = FastIntMap.this.table;
202 int i = nextIndex;
203 e = current = table[i];
204 while ( --i >= 0 )
205 if ( table[i] != null ) break;
206 nextIndex = i;
207 return e;
208 }
209
210 public void remove() {
211 FastIntMap.this.remove(current.key);
212 }
213 }
214
215 static final class Entry<T> {
216
217 final int key;
218 T value;
219 Entry<T> next;
220
221 Entry(int key, T value, Entry<T> next) {
222 this.key = key;
223 this.value = value;
224 this.next = next;
225 }
226
227 public int getKey() {
228 return key;
229 }
230
231 public T getValue() {
232 return value;
233 }
234
235 }
236
237 }
3131 package org.lwjgl.opengl;
3232
3333 import java.nio.Buffer;
34 import java.nio.IntBuffer;
3534
3635 import org.lwjgl.BufferUtils;
3736 import org.lwjgl.LWJGLUtil;
37
38 import static org.lwjgl.opengl.ARBBufferObject.*;
39 import static org.lwjgl.opengl.ATIVertexArrayObject.*;
40 import static org.lwjgl.opengl.EXTAbgr.*;
41 import static org.lwjgl.opengl.EXTBgra.*;
42 import static org.lwjgl.opengl.EXTDirectStateAccess.*;
43 import static org.lwjgl.opengl.GL11.*;
44 import static org.lwjgl.opengl.GL15.*;
3845
3946 /**
4047 * A class to check buffer boundaries in GL methods. Many GL
4653 * Thrown by the debug build library of the LWJGL if any OpenGL operation causes an error.
4754 *
4855 * @author cix_foo <cix_foo@users.sourceforge.net>
49 * @version $Revision: 3334 $
50 * $Id: GLChecks.java 3334 2010-04-22 23:21:48Z spasi $
56 * @version $Revision: 3459 $
57 * $Id: GLChecks.java 3459 2010-11-29 17:21:05Z spasi $
5158 */
5259 class GLChecks {
5360
5562 private GLChecks() {
5663 }
5764
58 static References getReferences(ContextCapabilities caps) {
59 return StateTracker.getReferencesStack(caps).getReferences();
60 }
61
6265 static int getBufferObjectSize(ContextCapabilities caps, int buffer_enum) {
63 return GL15.glGetBufferParameter(buffer_enum, GL15.GL_BUFFER_SIZE);
66 return glGetBufferParameter(buffer_enum, GL_BUFFER_SIZE);
6467 }
6568
6669 static int getBufferObjectSizeARB(ContextCapabilities caps, int buffer_enum) {
67 return ARBBufferObject.glGetBufferParameterARB(buffer_enum, ARBBufferObject.GL_BUFFER_SIZE_ARB);
70 return glGetBufferParameterARB(buffer_enum, GL_BUFFER_SIZE_ARB);
6871 }
6972
7073 static int getBufferObjectSizeATI(ContextCapabilities caps, int buffer) {
71 return ATIVertexArrayObject.glGetObjectBufferATI(buffer, ATIVertexArrayObject.GL_OBJECT_BUFFER_SIZE_ATI);
74 return glGetObjectBufferATI(buffer, GL_OBJECT_BUFFER_SIZE_ATI);
7275 }
7376
7477 static int getNamedBufferObjectSize(ContextCapabilities caps, int buffer) {
75 return EXTDirectStateAccess.glGetNamedBufferParameterEXT(buffer, GL15.GL_BUFFER_SIZE);
78 return glGetNamedBufferParameterEXT(buffer, GL_BUFFER_SIZE);
7679 }
7780
7881 /** Helper method to ensure that array buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */
7982 static void ensureArrayVBOdisabled(ContextCapabilities caps) {
80 if( LWJGLUtil.CHECKS && StateTracker.getReferencesStack(caps).getReferences().arrayBuffer != 0 )
83 if( LWJGLUtil.CHECKS && StateTracker.getReferences(caps).arrayBuffer != 0 )
8184 throw new OpenGLException("Cannot use Buffers when Array Buffer Object is enabled");
8285 }
8386
8487 /** Helper method to ensure that array buffer objects are enabled. If they are disabled, we'll throw an OpenGLException */
8588 static void ensureArrayVBOenabled(ContextCapabilities caps) {
86 if( LWJGLUtil.CHECKS && StateTracker.getReferencesStack(caps).getReferences().arrayBuffer == 0 )
89 if( LWJGLUtil.CHECKS && StateTracker.getReferences(caps).arrayBuffer == 0 )
8790 throw new OpenGLException("Cannot use offsets when Array Buffer Object is disabled");
8891 }
8992
9093 /** Helper method to ensure that element array buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */
9194 static void ensureElementVBOdisabled(ContextCapabilities caps) {
92 if( LWJGLUtil.CHECKS && StateTracker.getReferencesStack(caps).getReferences().elementArrayBuffer != 0 )
95 if( LWJGLUtil.CHECKS && StateTracker.getElementArrayBufferBound(caps) != 0 )
9396 throw new OpenGLException("Cannot use Buffers when Element Array Buffer Object is enabled");
9497 }
9598
9699 /** Helper method to ensure that element array buffer objects are enabled. If they are disabled, we'll throw an OpenGLException */
97100 static void ensureElementVBOenabled(ContextCapabilities caps) {
98 if( LWJGLUtil.CHECKS && StateTracker.getReferencesStack(caps).getReferences().elementArrayBuffer == 0 )
101 if( LWJGLUtil.CHECKS && StateTracker.getElementArrayBufferBound(caps) == 0 )
99102 throw new OpenGLException("Cannot use offsets when Element Array Buffer Object is disabled");
100103 }
101104
102105 /** Helper method to ensure that array buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */
103106 static void ensureIndirectBOdisabled(ContextCapabilities caps) {
104 if ( LWJGLUtil.CHECKS && StateTracker.getReferencesStack(caps).getReferences().indirectBuffer != 0 )
107 if ( LWJGLUtil.CHECKS && StateTracker.getReferences(caps).indirectBuffer != 0 )
105108 throw new OpenGLException("Cannot use Buffers when Draw Indirect Object is enabled");
106109 }
107110
108111 /** Helper method to ensure that array buffer objects are enabled. If they are disabled, we'll throw an OpenGLException */
109112 static void ensureIndirectBOenabled(ContextCapabilities caps) {
110 if ( LWJGLUtil.CHECKS && StateTracker.getReferencesStack(caps).getReferences().indirectBuffer == 0 )
113 if ( LWJGLUtil.CHECKS && StateTracker.getReferences(caps).indirectBuffer == 0 )
111114 throw new OpenGLException("Cannot use offsets when Draw Indirect Object is disabled");
112115 }
113116
114117 /** Helper method to ensure that pixel pack buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */
115118 static void ensurePackPBOdisabled(ContextCapabilities caps) {
116 if ( LWJGLUtil.CHECKS && StateTracker.getReferencesStack(caps).getReferences().pixelPackBuffer != 0 )
119 if ( LWJGLUtil.CHECKS && StateTracker.getReferences(caps).pixelPackBuffer != 0 )
117120 throw new OpenGLException("Cannot use Buffers when Pixel Pack Buffer Object is enabled");
118121 }
119122
120123 /** Helper method to ensure that pixel pack buffer objects are enabled. If they are disabled, we'll throw an OpenGLException */
121124 static void ensurePackPBOenabled(ContextCapabilities caps) {
122 if ( LWJGLUtil.CHECKS && StateTracker.getReferencesStack(caps).getReferences().pixelPackBuffer == 0 )
125 if ( LWJGLUtil.CHECKS && StateTracker.getReferences(caps).pixelPackBuffer == 0 )
123126 throw new OpenGLException("Cannot use offsets when Pixel Pack Buffer Object is disabled");
124127 }
125128
126129 /** Helper method to ensure that pixel unpack buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */
127130 static void ensureUnpackPBOdisabled(ContextCapabilities caps) {
128 if ( LWJGLUtil.CHECKS && StateTracker.getReferencesStack(caps).getReferences().pixelUnpackBuffer != 0 )
131 if ( LWJGLUtil.CHECKS && StateTracker.getReferences(caps).pixelUnpackBuffer != 0 )
129132 throw new OpenGLException("Cannot use Buffers when Pixel Unpack Buffer Object is enabled");
130133 }
131134
132135 /** Helper method to ensure that pixel unpack buffer objects are enabled. If they are disabled, we'll throw an OpenGLException */
133136 static void ensureUnpackPBOenabled(ContextCapabilities caps) {
134 if ( LWJGLUtil.CHECKS && StateTracker.getReferencesStack(caps).getReferences().pixelUnpackBuffer == 0 )
137 if ( LWJGLUtil.CHECKS && StateTracker.getReferences(caps).pixelUnpackBuffer == 0 )
135138 throw new OpenGLException("Cannot use offsets when Pixel Unpack Buffer Object is disabled");
136139 }
137140
192195 private static int calculateBytesPerPixel(int format, int type) {
193196 int bpe;
194197 switch ( type ) {
195 case GL11.GL_UNSIGNED_BYTE:
196 case GL11.GL_BYTE:
198 case GL_UNSIGNED_BYTE:
199 case GL_BYTE:
197200 bpe = 1;
198201 break;
199 case GL11.GL_UNSIGNED_SHORT:
200 case GL11.GL_SHORT:
202 case GL_UNSIGNED_SHORT:
203 case GL_SHORT:
201204 bpe = 2;
202205 break;
203 case GL11.GL_UNSIGNED_INT:
204 case GL11.GL_INT:
205 case GL11.GL_FLOAT:
206 case GL_UNSIGNED_INT:
207 case GL_INT:
208 case GL_FLOAT:
206209 bpe = 4;
207210 break;
208211 default :
212215 }
213216 int epp;
214217 switch ( format ) {
215 case GL11.GL_LUMINANCE:
216 case GL11.GL_ALPHA:
218 case GL_LUMINANCE:
219 case GL_ALPHA:
217220 epp = 1;
218221 break;
219222
220 case GL11.GL_LUMINANCE_ALPHA:
223 case GL_LUMINANCE_ALPHA:
221224 epp = 2;
222225 break;
223 case GL11.GL_RGB:
224 case EXTBgra.GL_BGR_EXT:
226 case GL_RGB:
227 case GL_BGR_EXT:
225228 epp = 3;
226229 break;
227 case GL11.GL_RGBA:
228 case EXTAbgr.GL_ABGR_EXT:
229 case EXTBgra.GL_BGRA_EXT:
230 case GL_RGBA:
231 case GL_ABGR_EXT:
232 case GL_BGRA_EXT:
230233 epp = 4;
231234 break;
232235 default :
3030 */
3131 package org.lwjgl.opengl;
3232
33 import org.lwjgl.BufferUtils;
3433 import org.lwjgl.LWJGLException;
3534 import org.lwjgl.LWJGLUtil;
3635 import org.lwjgl.Sys;
3736
3837 import java.lang.reflect.Method;
39 import java.nio.IntBuffer;
4038 import java.security.AccessController;
4139 import java.security.PrivilegedAction;
4240 import java.security.PrivilegedExceptionAction;
4341 import java.util.*;
42
43 import static org.lwjgl.opengl.GL11.*;
44 import static org.lwjgl.opengl.GL30.*;
45 import static org.lwjgl.opengl.GL32.*;
4446
4547 /**
4648 * <p/>
5355 * That way, multiple threads can have multiple contexts current and render to them concurrently.
5456 *
5557 * @author elias_naur <elias_naur@users.sourceforge.net>
56 * @version $Revision: 3355 $
57 * $Id: GLContext.java 3355 2010-05-27 22:56:29Z spasi $
58 * @version $Revision: 3418 $
59 * $Id: GLContext.java 3418 2010-09-28 21:11:35Z spasi $
5860 */
5961 public final class GLContext {
6062
6163 /** Maps threads to their current context's ContextCapabilities, if any */
62 private final static ThreadLocal current_capabilities = new ThreadLocal();
64 private static final ThreadLocal<ContextCapabilities> current_capabilities = new ThreadLocal<ContextCapabilities>();
6365
6466 /**
6567 * The getCapabilities() method is a potential hot spot in any LWJGL application, since
9193 * Simple lock-free cache of CapabilitesEntryCache to avoid allocating more than one
9294 * cache entry per thread
9395 */
94 private final static ThreadLocal thread_cache_entries = new ThreadLocal();
96 private static final ThreadLocal<CapabilitiesCacheEntry> thread_cache_entries = new ThreadLocal<CapabilitiesCacheEntry>();
9597
9698 /**
9799 * The weak mapping from context Object instances to ContextCapabilities. Used
98100 * to avoid recreating a ContextCapabilities every time a context is made current.
99101 */
100 private final static Map capability_cache = new WeakHashMap();
102 private static final Map<Object, ContextCapabilities> capability_cache = new WeakHashMap<Object, ContextCapabilities>();
101103
102104 /** Reference count of the native opengl implementation library */
103105 private static int gl_ref_count;
126128 }
127129
128130 private static ContextCapabilities getThreadLocalCapabilities() {
129 return ((ContextCapabilities)current_capabilities.get());
131 return current_capabilities.get();
130132 }
131133
132134 /**
138140 static void setCapabilities(ContextCapabilities capabilities) {
139141 current_capabilities.set(capabilities);
140142
141 CapabilitiesCacheEntry thread_cache_entry = (CapabilitiesCacheEntry)thread_cache_entries.get();
143 CapabilitiesCacheEntry thread_cache_entry = thread_cache_entries.get();
142144 if ( thread_cache_entry == null ) {
143145 thread_cache_entry = new CapabilitiesCacheEntry();
144146 thread_cache_entries.set(thread_cache_entry);
154156 * with a name dependent on the current platform
155157 */
156158 static long getPlatformSpecificFunctionAddress(String function_prefix, String[] os_prefixes, String[] os_function_prefixes, String function) {
157 String os_name = (String)AccessController.doPrivileged(new PrivilegedAction() {
158 public Object run() {
159 String os_name = AccessController.doPrivileged(new PrivilegedAction<String>() {
160 public String run() {
159161 return System.getProperty("os.name");
160162 }
161163 });
176178 * @return the function pointer address
177179 */
178180 static long getFunctionAddress(String[] aliases) {
179 for ( int i = 0; i < aliases.length; i++ ) {
180 long address = getFunctionAddress(aliases[i]);
181 for ( String alias : aliases ) {
182 long address = getFunctionAddress(alias);
181183 if ( address != 0 )
182184 return address;
183185 }
194196 *
195197 * @return the context profile mask, will be 0 for any version < 3.2
196198 */
197 static int getSupportedExtensions(final Set supported_extensions) {
199 static int getSupportedExtensions(final Set<String> supported_extensions) {
198200 // Detect OpenGL version first
199201
200 final String version = GL11.glGetString(GL11.GL_VERSION);
202 final String version = glGetString(GL_VERSION);
201203 if ( version == null )
202204 throw new IllegalStateException("glGetString(GL_VERSION) returned null - possibly caused by missing current context.");
203205
214216 LWJGLUtil.log("The major and/or minor OpenGL version is malformed: " + e.getMessage());
215217 }
216218
217 // ----------------------[ 4.X ]----------------------
218 if ( 4 <= majorVersion )
219 supported_extensions.add("OpenGL40");
220
221 // ----------------------[ 3.X ]----------------------
222 if ( 3 < majorVersion || (3 == majorVersion && 3 <= minorVersion) )
223 supported_extensions.add("OpenGL33");
224 if ( 3 < majorVersion || (3 == majorVersion && 2 <= minorVersion) )
225 supported_extensions.add("OpenGL32");
226 if ( 3 < majorVersion || (3 == majorVersion && 1 <= minorVersion) )
227 supported_extensions.add("OpenGL31");
228 if ( 3 <= majorVersion )
229 supported_extensions.add("OpenGL30");
230
231 // ----------------------[ 2.X ]----------------------
232 if ( 2 < majorVersion || (2 == majorVersion && 1 <= minorVersion) )
233 supported_extensions.add("OpenGL21");
234 if ( 2 <= majorVersion )
235 supported_extensions.add("OpenGL20");
236
237 // ----------------------[ 1.X ]----------------------
238 if ( 1 < majorVersion || 5 <= minorVersion )
239 supported_extensions.add("OpenGL15");
240 if ( 1 < majorVersion || 4 <= minorVersion )
241 supported_extensions.add("OpenGL14");
242 if ( 1 < majorVersion || 3 <= minorVersion )
243 supported_extensions.add("OpenGL13");
244 if ( 1 < majorVersion || 2 <= minorVersion )
245 supported_extensions.add("OpenGL12");
246 if ( 1 < majorVersion || 1 <= minorVersion )
247 supported_extensions.add("OpenGL11");
219 final int[][] GL_VERSIONS = {
220 { 1, 2, 3, 4, 5 }, // OpenGL 1
221 { 0, 1 }, // OpenGL 2
222 { 0, 1, 2, 3 }, // OpenGL 3
223 { 0, 1 }, // OpenGL 4
224 };
225
226 for ( int major = 1; major <= GL_VERSIONS.length; major++ ) {
227 int[] minors = GL_VERSIONS[major - 1];
228 for ( int minor : minors ) {
229 if ( major < majorVersion || (major == majorVersion && minor <= minorVersion) )
230 supported_extensions.add("OpenGL" + Integer.toString(major) + Integer.toString(minor));
231 }
232 }
248233
249234 int profileMask = 0;
250235
251236 if ( majorVersion < 3 ) {
252237 // Parse EXTENSIONS string
253 final String extensions_string = GL11.glGetString(GL11.GL_EXTENSIONS);
238 final String extensions_string = glGetString(GL_EXTENSIONS);
254239 if ( extensions_string == null )
255240 throw new IllegalStateException("glGetString(GL_EXTENSIONS) returned null - is there a context current?");
256241
259244 supported_extensions.add(tokenizer.nextToken());
260245 } else {
261246 // Use forward compatible indexed EXTENSIONS
262 final IntBuffer buffer = BufferUtils.createIntBuffer(16);
263 GL11.glGetInteger(GL30.GL_NUM_EXTENSIONS, buffer);
264 final int extensionCount = buffer.get(0);
247 final int extensionCount = glGetInteger(GL_NUM_EXTENSIONS);
265248
266249 for ( int i = 0; i < extensionCount; i++ )
267 supported_extensions.add(GL30.glGetStringi(GL11.GL_EXTENSIONS, i));
250 supported_extensions.add(glGetStringi(GL_EXTENSIONS, i));
268251
269252 // Get the context profile mask for versions >= 3.2
270253 if ( 3 < majorVersion || 2 <= minorVersion ) {
271254 Util.checkGLError(); // Make sure we have no errors up to this point
272255
273 GL11.glGetInteger(GL32.GL_CONTEXT_PROFILE_MASK, buffer);
274
275256 try {
257 profileMask = glGetInteger(GL_CONTEXT_PROFILE_MASK);
276258 // Retrieving GL_CONTEXT_PROFILE_MASK may generate an INVALID_OPERATION error on certain implementations, ignore.
277259 // Happens on pre10.1 ATI drivers, when ContextAttribs.withProfileCompatibility is not used
278260 Util.checkGLError();
279 profileMask = buffer.get(0);
280261 } catch (OpenGLException e) {
281262 LWJGLUtil.log("Failed to retrieve CONTEXT_PROFILE_MASK");
282263 }
290271 * Helper method to ContextCapabilities. It will try to initialize the native stubs,
291272 * and remove the given extension name from the extension set if the initialization fails.
292273 */
293 static void initNativeStubs(final Class extension_class, Set supported_extensions, String ext_name) {
274 static void initNativeStubs(final Class<?> extension_class, Set supported_extensions, String ext_name) {
294275 resetNativeStubs(extension_class);
295276 if ( supported_extensions.contains(ext_name) ) {
296277 try {
297 AccessController.doPrivileged(new PrivilegedExceptionAction() {
278 AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
298279 public Object run() throws Exception {
299 Method init_stubs_method = extension_class.getDeclaredMethod("initNativeStubs", null);
300 init_stubs_method.invoke(null, null);
280 Method init_stubs_method = extension_class.getDeclaredMethod("initNativeStubs");
281 init_stubs_method.invoke(null);
301282 return null;
302283 }
303284 });
356337 did_auto_load = true;
357338 }
358339 try {
359 ContextCapabilities capabilities = (ContextCapabilities)capability_cache.get(context);
340 ContextCapabilities capabilities = capability_cache.get(context);
360341 if ( capabilities == null ) {
361342 /*
362343 * The capabilities object registers itself as current. This behaviour is caused
400381 /** Native method to clear native stub bindings */
401382 static native void resetNativeStubs(Class clazz);
402383
403 private final static class CapabilitiesCacheEntry {
384 private static final class CapabilitiesCacheEntry {
404385
405386 Thread owner;
406387 ContextCapabilities capabilities;
3030 */
3131 package org.lwjgl.opengl;
3232
33 import org.lwjgl.PointerWrapperAbstract;
34
3335 /**
36 * This class is a wrapper around a GLsync pointer.
37 *
3438 * @author spasi <spasi@users.sourceforge.net>
3539 */
36 public final class GLSync implements PointerWrapper {
37
38 private final long sync;
40 public final class GLSync extends PointerWrapperAbstract {
3941
4042 GLSync(final long sync) {
41 this.sync = sync;
42 }
43
44 public long getPointer() {
45 return sync;
43 super(sync);
4644 }
4745
4846 }
3030 */
3131 package org.lwjgl.opengl;
3232
33 import static org.lwjgl.opengl.GL11.*;
34
3335 /**
3436 * <p/>
3537 * GLU constants.
3638 *
3739 * @author cix_foo <cix_foo@users.sourceforge.net>
38 * @version $Revision: 2983 $
39 * $Id: GLUConstants.java 2983 2008-04-07 18:36:09Z matzon $
40 * @version $Revision: 3418 $
41 * $Id: GLUConstants.java 3418 2010-09-28 21:11:35Z spasi $
4042 */
4143 public interface GLUConstants {
4244
5153 int GLU_EXTENSIONS = 100801;
5254
5355 /* Boolean */
54 int GLU_TRUE = GL11.GL_TRUE;
55 int GLU_FALSE = GL11.GL_FALSE;
56 int GLU_TRUE = GL_TRUE;
57 int GLU_FALSE = GL_FALSE;
5658
5759 }
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 */
3535 * synchronize access to Display.
3636 */
3737 final class GlobalLock {
38 final static Object lock = new Object();
38 static final Object lock = new Object();
3939 }
4343 /**
4444 *
4545 * @author elias_naur <elias_naur@users.sourceforge.net>
46 * @version $Revision: 3002 $
47 * $Id: LinuxCanvasImplementation.java 3002 2008-04-10 20:25:54Z elias_naur $
46 * @version $Revision: 3418 $
47 * $Id: LinuxCanvasImplementation.java 3418 2010-09-28 21:11:35Z spasi $
4848 */
4949 final class LinuxCanvasImplementation implements AWTCanvasImplementation {
5050 static int getScreenFromDevice(final GraphicsDevice device) throws LWJGLException {
5151 try {
52 Method getScreen_method = (Method)AccessController.doPrivileged(new PrivilegedExceptionAction() {
53 public Object run() throws Exception {
54 return device.getClass().getMethod("getScreen", null);
52 Method getScreen_method = AccessController.doPrivileged(new PrivilegedExceptionAction<Method>() {
53 public Method run() throws Exception {
54 return device.getClass().getMethod("getScreen");
5555 }
5656 });
57 Integer screen = (Integer)getScreen_method.invoke(device, null);
58 return screen.intValue();
57 Integer screen = (Integer)getScreen_method.invoke(device);
58 return screen;
5959 } catch (Exception e) {
6060 throw new LWJGLException(e);
6161 }
6363
6464 private static int getVisualIDFromConfiguration(final GraphicsConfiguration configuration) throws LWJGLException {
6565 try {
66 Method getVisual_method = (Method)AccessController.doPrivileged(new PrivilegedExceptionAction() {
67 public Object run() throws Exception {
68 return configuration.getClass().getMethod("getVisual", null);
66 Method getVisual_method = AccessController.doPrivileged(new PrivilegedExceptionAction<Method>() {
67 public Method run() throws Exception {
68 return configuration.getClass().getMethod("getVisual");
6969 }
7070 });
71 Integer visual = (Integer)getVisual_method.invoke(configuration, null);
72 return visual.intValue();
71 Integer visual = (Integer)getVisual_method.invoke(configuration);
72 return visual;
7373 } catch (Exception e) {
7474 throw new LWJGLException(e);
7575 }
8989 int screen = getScreenFromDevice(device);
9090 int visual_id_matching_format = findVisualIDFromFormat(screen, pixel_format);
9191 GraphicsConfiguration[] configurations = device.getConfigurations();
92 for (int i = 0; i < configurations.length; i++) {
93 int visual_id = getVisualIDFromConfiguration(configurations[i]);
94 if (visual_id == visual_id_matching_format)
95 return configurations[i];
92 for ( GraphicsConfiguration configuration : configurations ) {
93 int visual_id = getVisualIDFromConfiguration(configuration);
94 if ( visual_id == visual_id_matching_format )
95 return configuration;
9696 }
9797 } catch (LWJGLException e) {
9898 LWJGLUtil.log("Got exception while trying to determine configuration: " + e);
3737
3838 /**
3939 * @author elias_naur <elias_naur@users.sourceforge.net>
40 * @version $Revision: 3116 $
41 * $Id: LinuxContextImplementation.java 3116 2008-08-19 16:46:03Z spasi $
40 * @version $Revision: 3412 $
41 * $Id: LinuxContextImplementation.java 3412 2010-09-26 23:43:24Z spasi $
4242 */
4343 final class LinuxContextImplementation implements ContextImplementation {
4444
5757 }
5858
5959 private static native ByteBuffer nCreate(ByteBuffer peer_handle, IntBuffer attribs, ByteBuffer shared_context_handle) throws LWJGLException;
60
61 native long getGLXContext(ByteBuffer context_handle);
62
63 native long getDisplay(ByteBuffer peer_info_handle);
6064
6165 public void releaseDrawable(ByteBuffer context_handle) throws LWJGLException {
6266 }
5353 import java.security.AccessController;
5454 import java.security.PrivilegedAction;
5555 import java.util.ArrayList;
56 import java.util.Iterator;
5756 import java.util.List;
5857
5958 final class LinuxDisplay implements DisplayImplementation {
6059 /* X11 constants */
61 public final static int CurrentTime = 0;
62 public final static int GrabSuccess = 0;
63 public final static int AutoRepeatModeOff = 0;
64 public final static int AutoRepeatModeOn = 1;
65 public final static int AutoRepeatModeDefault = 2;
66 public final static int None = 0;
67
68 private final static int KeyPressMask = 1 << 0;
69 private final static int KeyReleaseMask = 1 << 1;
70 private final static int ButtonPressMask = 1 << 2;
71 private final static int ButtonReleaseMask = 1 << 3;
72
73 private final static int NotifyAncestor = 0;
74 private final static int NotifyNonlinear = 3;
75 private final static int NotifyPointer = 5;
76 private final static int NotifyPointerRoot = 6;
77 private final static int NotifyDetailNone = 7;
78
79 private final static int SetModeInsert = 0;
80 private final static int SaveSetRoot = 1;
81 private final static int SaveSetUnmap = 1;
60 public static final int CurrentTime = 0;
61 public static final int GrabSuccess = 0;
62 public static final int AutoRepeatModeOff = 0;
63 public static final int AutoRepeatModeOn = 1;
64 public static final int AutoRepeatModeDefault = 2;
65 public static final int None = 0;
66
67 private static final int KeyPressMask = 1 << 0;
68 private static final int KeyReleaseMask = 1 << 1;
69 private static final int ButtonPressMask = 1 << 2;
70 private static final int ButtonReleaseMask = 1 << 3;
71
72 private static final int NotifyAncestor = 0;
73 private static final int NotifyNonlinear = 3;
74 private static final int NotifyPointer = 5;
75 private static final int NotifyPointerRoot = 6;
76 private static final int NotifyDetailNone = 7;
77
78 private static final int SetModeInsert = 0;
79 private static final int SaveSetRoot = 1;
80 private static final int SaveSetUnmap = 1;
8281
8382 /** Window mode enum */
8483 private static final int FULLSCREEN_LEGACY = 1;
9897 private static long current_window;
9998 private static long saved_error_handler;
10099
101 private static int display_connection_usage_count = 0;
100 private static int display_connection_usage_count;
102101
103102 /** Event buffer */
104103 private final LinuxEvent event_buffer = new LinuxEvent();
119118 /** Saved mode to restore with */
120119 private DisplayMode saved_mode;
121120 private DisplayMode current_mode;
122
121
123122 private Screen[] savedXrandrConfig;
124123
125124 private boolean keyboard_grabbed;
136135 private long parent_window;
137136 private boolean xembedded;
138137 private boolean parent_focus;
139
138 private boolean mouseInside = true;
139
140140 private LinuxKeyboard keyboard;
141141 private LinuxMouse mouse;
142142
368368 }
369369 static native int nUngrabPointer(long display);
370370
371 private boolean isFullscreen() {
371 private static boolean isFullscreen() {
372372 return current_window_mode == FULLSCREEN_LEGACY || current_window_mode == FULLSCREEN_NETWM;
373373 }
374374
396396 }
397397 private static native void nDefineCursor(long display, long window, long cursor_handle);
398398
399 private boolean isLegacyFullscreen() {
399 private static boolean isLegacyFullscreen() {
400400 return current_window_mode == FULLSCREEN_LEGACY;
401401 }
402402
543543 try {
544544 if( current_displaymode_extension == XRANDR && savedXrandrConfig.length > 0 )
545545 {
546 AccessController.doPrivileged(new PrivilegedAction() {
546 AccessController.doPrivileged(new PrivilegedAction<Object>() {
547547 public Object run() {
548548 XRandR.setConfiguration( savedXrandrConfig );
549549 return null;
606606 }
607607 }
608608
609 private void setGammaRampOnTmpDisplay(ByteBuffer native_gamma) throws LWJGLException {
609 private static void setGammaRampOnTmpDisplay(ByteBuffer native_gamma) throws LWJGLException {
610610 incDisplay();
611611 try {
612612 nSetGammaRamp(getDisplay(), getDefaultScreen(), native_gamma);
643643 throw new LWJGLException("No modes available");
644644 switch (current_displaymode_extension) {
645645 case XRANDR:
646 savedXrandrConfig = (Screen[])AccessController.doPrivileged(new PrivilegedAction() {
647 public Object run() {
646 savedXrandrConfig = AccessController.doPrivileged(new PrivilegedAction<Screen[]>() {
647 public Screen[] run() {
648648 return XRandR.getConfiguration();
649649 }
650650 });
777777 case LinuxEvent.Expose:
778778 dirty = true;
779779 break;
780 case LinuxEvent.EnterNotify:
781 mouseInside = true;
782 break;
783 case LinuxEvent.LeaveNotify:
784 mouseInside = false;
785 break;
780786 default:
781787 break;
782788 }
871877
872878 private void checkInput() {
873879 if (parent == null) return;
874
880
875881 if (parent_focus != parent.hasFocus()) {
876882 parent_focus = parent.hasFocus();
877
883
878884 if (parent_focus) {
879885 setInputFocusUnsafe(current_window);
880886 }
891897 if (focused == got_focus || focus_detail == NotifyDetailNone || focus_detail == NotifyPointer || focus_detail == NotifyPointerRoot)
892898 return;
893899 focused = got_focus;
894
900
895901 if (focused) {
896902 acquireInput();
903 if (parent != null && !xembedded) parent.setFocusable(false);
897904 }
898905 else {
899906 releaseInput();
907 if (parent != null && !xembedded) parent.setFocusable(true);
900908 }
901909 }
902910 static native long nGetInputFocus(long display);
903911
904 private void setInputFocusUnsafe(long window) {
912 private static void setInputFocusUnsafe(long window) {
905913 try {
906914 setInputFocus(getDisplay(), window, CurrentTime);
907915 sync(getDisplay(), false);
922930 try {
923931 if( current_displaymode_extension == XRANDR && savedXrandrConfig.length > 0 )
924932 {
925 AccessController.doPrivileged(new PrivilegedAction() {
933 AccessController.doPrivileged(new PrivilegedAction<Object>() {
926934 public Object run() {
927935 XRandR.setConfiguration( savedXrandrConfig );
928936 return null;
10871095 incDisplay();
10881096 try {
10891097 long cursor = nCreateCursor(getDisplay(), width, height, xHotspot, yHotspot, numImages, images, images.position(), delays, delays != null ? delays.position() : -1);
1090 return new Long(cursor);
1098 return cursor;
10911099 } catch (LWJGLException e) {
10921100 decDisplay();
10931101 throw e;
10981106 }
10991107
11001108 private static long getCursorHandle(Object cursor_handle) {
1101 return cursor_handle != null ? ((Long)cursor_handle).longValue() : None;
1109 return cursor_handle != null ? (Long)cursor_handle : None;
11021110 }
11031111
11041112 public void destroyCursor(Object cursorHandle) {
12141222 try {
12151223 incDisplay();
12161224 try {
1217 for (int i=0;i<icons.length;i++) {
1218 int size = icons[i].limit() / 4;
1225 for ( ByteBuffer icon : icons ) {
1226 int size = icon.limit() / 4;
12191227 int dimension = (int)Math.sqrt(size);
1220 if (dimension > 0) {
1221 ByteBuffer icon_rgb = convertIcon(icons[i], dimension, dimension);
1222 ByteBuffer icon_mask = convertIconMask(icons[i], dimension, dimension);
1228 if ( dimension > 0 ) {
1229 ByteBuffer icon_rgb = convertIcon(icon, dimension, dimension);
1230 ByteBuffer icon_mask = convertIconMask(icon, dimension, dimension);
12231231 nSetWindowIcon(getDisplay(), getWindow(), icon_rgb, icon_rgb.capacity(), icon_mask, icon_mask.capacity(), dimension, dimension);
12241232 return 1;
12251233 }
12461254 return Display.getDisplayMode().getHeight();
12471255 }
12481256
1249 public boolean isInsideWindow() {
1250 return true;
1251 }
1257 public boolean isInsideWindow() {
1258 return mouseInside;
1259 }
12521260
12531261 /**
12541262 * Helper class for managing Compiz's workarounds. We need this to enable Legacy
12711279 if ( Display.getPrivilegedBoolean("org.lwjgl.opengl.Window.nocompiz_lfs") )
12721280 return;
12731281
1274 AccessController.doPrivileged(new PrivilegedAction() {
1282 AccessController.doPrivileged(new PrivilegedAction<Object>() {
12751283 public Object run() {
12761284 try {
12771285 // Check if Compiz is active
12901298 private static final String KEY = "/org/freedesktop/compiz/workarounds/allscreens/legacy_fullscreen";
12911299
12921300 public boolean hasLegacyFullscreenSupport() throws LWJGLException {
1293 final List output = Compiz.run(new String[] {
1301 final List output = Compiz.run(
12941302 "dbus-send", "--print-reply", "--type=method_call", "--dest=org.freedesktop.compiz", KEY, "org.freedesktop.compiz.get"
1295 });
1303 );
12961304
12971305 if ( output == null || output.size() < 2 )
12981306 throw new LWJGLException("Invalid Dbus reply.");
13101318 }
13111319
13121320 public void setLegacyFullscreenSupport(final boolean state) throws LWJGLException {
1313 if ( Compiz.run(new String[] {
1321 if ( Compiz.run(
13141322 "dbus-send", "--type=method_call", "--dest=org.freedesktop.compiz", KEY, "org.freedesktop.compiz.set", "boolean:" + Boolean.toString(state)
1315 }) == null )
1323 ) == null )
13161324 throw new LWJGLException("Failed to apply Compiz LFS workaround.");
13171325 }
13181326 };
13761384 if ( !applyFix )
13771385 return;
13781386
1379 AccessController.doPrivileged(new PrivilegedAction() {
1387 AccessController.doPrivileged(new PrivilegedAction<Object>() {
13801388 public Object run() {
13811389 try {
13821390 provider.setLegacyFullscreenSupport(enabled);
13881396 });
13891397 }
13901398
1391 private static List run(final String[] command) throws LWJGLException {
1392 final List output = new ArrayList();
1399 private static List<String> run(final String... command) throws LWJGLException {
1400 final List<String> output = new ArrayList<String>();
13931401
13941402 try {
13951403 final Process p = Runtime.getRuntime().exec(command);
14161424 }
14171425
14181426 private static boolean isProcessActive(final String processName) throws LWJGLException {
1419 final List output = run(new String[] { "ps", "-C", processName });
1427 final List<String> output = run(new String[] { "ps", "-C", processName });
14201428 if ( output == null )
14211429 return false;
14221430
1423 for ( Iterator iter = output.iterator(); iter.hasNext(); ) {
1424 final String line = (String)iter.next();
1425 if ( line.contains(processName) );
1431 for ( final String line : output ) {
1432 if ( line.contains(processName) )
14261433 return true;
14271434 }
14281435
4040 * $Id: LinuxPeerInfo.java 2286 2006-03-23 19:32:21Z matzon $
4141 */
4242 final class LinuxEvent {
43 public final static int FocusIn = 9;
44 public final static int FocusOut = 10;
45 public final static int KeyPress = 2;
46 public final static int KeyRelease = 3;
47 public final static int ButtonPress = 4;
48 public final static int ButtonRelease = 5;
49 public final static int MotionNotify = 6;
50 public final static int UnmapNotify = 18;
51 public final static int MapNotify = 19;
52 public final static int Expose = 12;
53 public final static int ClientMessage = 33;
43 public static final int FocusIn = 9;
44 public static final int FocusOut = 10;
45 public static final int KeyPress = 2;
46 public static final int KeyRelease = 3;
47 public static final int ButtonPress = 4;
48 public static final int ButtonRelease = 5;
49 public static final int MotionNotify = 6;
50 public static final int EnterNotify = 7;
51 public static final int LeaveNotify = 8;
52 public static final int UnmapNotify = 18;
53 public static final int MapNotify = 19;
54 public static final int Expose = 12;
55 public static final int ClientMessage = 33;
5456
5557 private final ByteBuffer event_buffer;
5658
3737 import org.lwjgl.input.Keyboard;
3838
3939 final class LinuxKeycodes {
40 public final static int XK_Kanji = 0xff21;
41
42 public final static int XK_ISO_Left_Tab = 0xfe20;
43
44 public final static int XK_dead_grave = 0xfe50;
45 public final static int XK_dead_acute = 0xfe51;
46 public final static int XK_dead_circumflex = 0xfe52;
47 public final static int XK_dead_tilde = 0xfe53;
48 public final static int XK_dead_macron = 0xfe54;
49 public final static int XK_dead_breve = 0xfe55;
50 public final static int XK_dead_abovedot = 0xfe56;
51 public final static int XK_dead_diaeresis = 0xfe57;
52 public final static int XK_dead_abovering = 0xfe58;
53 public final static int XK_dead_doubleacute = 0xfe59;
54 public final static int XK_dead_caron = 0xfe5a;
55 public final static int XK_dead_cedilla = 0xfe5b;
56 public final static int XK_dead_ogonek = 0xfe5c;
57 public final static int XK_dead_iota = 0xfe5d;
58 public final static int XK_dead_voiced_sound = 0xfe5e;
59 public final static int XK_dead_semivoiced_sound = 0xfe5f;
60 public final static int XK_dead_belowdot = 0xfe60;
61 public final static int XK_dead_hook = 0xfe61;
62 public final static int XK_dead_horn = 0xfe62;
63
64 public final static int XK_BackSpace = 0xff08;
65 public final static int XK_Tab = 0xff09;
66 public final static int XK_Linefeed = 0xff0a;
67 public final static int XK_Clear = 0xff0b;
68 public final static int XK_Return = 0xff0d;
69 public final static int XK_Pause = 0xff13;
70 public final static int XK_Scroll_Lock = 0xff14;
71 public final static int XK_Sys_Req = 0xff15;
72 public final static int XK_Escape = 0xff1b;
73 public final static int XK_Delete = 0xffff;
74
75 public final static int XK_Home = 0xff50;
76 public final static int XK_Left = 0xff51;
77 public final static int XK_Up = 0xff52;
78 public final static int XK_Right = 0xff53;
79 public final static int XK_Down = 0xff54;
80 public final static int XK_Prior = 0xff55;
81 public final static int XK_Page_Up = 0xff55;
82 public final static int XK_Next = 0xff56;
83 public final static int XK_Page_Down = 0xff56;
84 public final static int XK_End = 0xff57;
85 public final static int XK_Begin = 0xff58;
40 public static final int XK_Kanji = 0xff21;
41
42 public static final int XK_ISO_Left_Tab = 0xfe20;
43
44 public static final int XK_dead_grave = 0xfe50;
45 public static final int XK_dead_acute = 0xfe51;
46 public static final int XK_dead_circumflex = 0xfe52;
47 public static final int XK_dead_tilde = 0xfe53;
48 public static final int XK_dead_macron = 0xfe54;
49 public static final int XK_dead_breve = 0xfe55;
50 public static final int XK_dead_abovedot = 0xfe56;
51 public static final int XK_dead_diaeresis = 0xfe57;
52 public static final int XK_dead_abovering = 0xfe58;
53 public static final int XK_dead_doubleacute = 0xfe59;
54 public static final int XK_dead_caron = 0xfe5a;
55 public static final int XK_dead_cedilla = 0xfe5b;
56 public static final int XK_dead_ogonek = 0xfe5c;
57 public static final int XK_dead_iota = 0xfe5d;
58 public static final int XK_dead_voiced_sound = 0xfe5e;
59 public static final int XK_dead_semivoiced_sound = 0xfe5f;
60 public static final int XK_dead_belowdot = 0xfe60;
61 public static final int XK_dead_hook = 0xfe61;
62 public static final int XK_dead_horn = 0xfe62;
63
64 public static final int XK_BackSpace = 0xff08;
65 public static final int XK_Tab = 0xff09;
66 public static final int XK_Linefeed = 0xff0a;
67 public static final int XK_Clear = 0xff0b;
68 public static final int XK_Return = 0xff0d;
69 public static final int XK_Pause = 0xff13;
70 public static final int XK_Scroll_Lock = 0xff14;
71 public static final int XK_Sys_Req = 0xff15;
72 public static final int XK_Escape = 0xff1b;
73 public static final int XK_Delete = 0xffff;
74
75 public static final int XK_Home = 0xff50;
76 public static final int XK_Left = 0xff51;
77 public static final int XK_Up = 0xff52;
78 public static final int XK_Right = 0xff53;
79 public static final int XK_Down = 0xff54;
80 public static final int XK_Prior = 0xff55;
81 public static final int XK_Page_Up = 0xff55;
82 public static final int XK_Next = 0xff56;
83 public static final int XK_Page_Down = 0xff56;
84 public static final int XK_End = 0xff57;
85 public static final int XK_Begin = 0xff58;
8686
8787
8888 /* Misc functions */
8989
90 public final static int XK_Select = 0xff60;
91 public final static int XK_Print = 0xff61;
92 public final static int XK_Execute = 0xff62;
93 public final static int XK_Insert = 0xff63;
94 public final static int XK_Undo = 0xff65;
95 public final static int XK_Redo = 0xff66;
96 public final static int XK_Menu = 0xff67;
97 public final static int XK_Find = 0xff68;
98 public final static int XK_Cancel = 0xff69;
99 public final static int XK_Help = 0xff6a;
100 public final static int XK_Break = 0xff6b;
101 public final static int XK_Mode_switch = 0xff7e;
102 public final static int XK_script_switch = 0xff7e;
103 public final static int XK_Num_Lock = 0xff7f;
90 public static final int XK_Select = 0xff60;
91 public static final int XK_Print = 0xff61;
92 public static final int XK_Execute = 0xff62;
93 public static final int XK_Insert = 0xff63;
94 public static final int XK_Undo = 0xff65;
95 public static final int XK_Redo = 0xff66;
96 public static final int XK_Menu = 0xff67;
97 public static final int XK_Find = 0xff68;
98 public static final int XK_Cancel = 0xff69;
99 public static final int XK_Help = 0xff6a;
100 public static final int XK_Break = 0xff6b;
101 public static final int XK_Mode_switch = 0xff7e;
102 public static final int XK_script_switch = 0xff7e;
103 public static final int XK_Num_Lock = 0xff7f;
104104
105105 /* Keypad functions, keypad numbers cleverly chosen to map to ASCII */
106106
107 public final static int XK_KP_Space = 0xff80;
108 public final static int XK_KP_Tab = 0xff89;
109 public final static int XK_KP_Enter = 0xff8d;
110 public final static int XK_KP_F1 = 0xff91;
111 public final static int XK_KP_F2 = 0xff92;
112 public final static int XK_KP_F3 = 0xff93;
113 public final static int XK_KP_F4 = 0xff94;
114 public final static int XK_KP_Home = 0xff95;
115 public final static int XK_KP_Left = 0xff96;
116 public final static int XK_KP_Up = 0xff97;
117 public final static int XK_KP_Right = 0xff98;
118 public final static int XK_KP_Down = 0xff99;
119 public final static int XK_KP_Prior = 0xff9a;
120 public final static int XK_KP_Page_Up = 0xff9a;
121 public final static int XK_KP_Next = 0xff9b;
122 public final static int XK_KP_Page_Down = 0xff9b;
123 public final static int XK_KP_End = 0xff9c;
124 public final static int XK_KP_Begin = 0xff9d;
125 public final static int XK_KP_Insert = 0xff9e;
126 public final static int XK_KP_Delete = 0xff9f;
127 public final static int XK_KP_Equal = 0xffbd;
128 public final static int XK_KP_Multiply = 0xffaa;
129 public final static int XK_KP_Add = 0xffab;
130 public final static int XK_KP_Separator = 0xffac;
131 public final static int XK_KP_Subtract = 0xffad;
132 public final static int XK_KP_Decimal = 0xffae;
133 public final static int XK_KP_Divide = 0xffaf;
134
135 public final static int XK_KP_0 = 0xffb0;
136 public final static int XK_KP_1 = 0xffb1;
137 public final static int XK_KP_2 = 0xffb2;
138 public final static int XK_KP_3 = 0xffb3;
139 public final static int XK_KP_4 = 0xffb4;
140 public final static int XK_KP_5 = 0xffb5;
141 public final static int XK_KP_6 = 0xffb6;
142 public final static int XK_KP_7 = 0xffb7;
143 public final static int XK_KP_8 = 0xffb8;
144 public final static int XK_KP_9 = 0xffb9;
107 public static final int XK_KP_Space = 0xff80;
108 public static final int XK_KP_Tab = 0xff89;
109 public static final int XK_KP_Enter = 0xff8d;
110 public static final int XK_KP_F1 = 0xff91;
111 public static final int XK_KP_F2 = 0xff92;
112 public static final int XK_KP_F3 = 0xff93;
113 public static final int XK_KP_F4 = 0xff94;
114 public static final int XK_KP_Home = 0xff95;
115 public static final int XK_KP_Left = 0xff96;
116 public static final int XK_KP_Up = 0xff97;
117 public static final int XK_KP_Right = 0xff98;
118 public static final int XK_KP_Down = 0xff99;
119 public static final int XK_KP_Prior = 0xff9a;
120 public static final int XK_KP_Page_Up = 0xff9a;
121 public static final int XK_KP_Next = 0xff9b;
122 public static final int XK_KP_Page_Down = 0xff9b;
123 public static final int XK_KP_End = 0xff9c;
124 public static final int XK_KP_Begin = 0xff9d;
125 public static final int XK_KP_Insert = 0xff9e;
126 public static final int XK_KP_Delete = 0xff9f;
127 public static final int XK_KP_Equal = 0xffbd;
128 public static final int XK_KP_Multiply = 0xffaa;
129 public static final int XK_KP_Add = 0xffab;
130 public static final int XK_KP_Separator = 0xffac;
131 public static final int XK_KP_Subtract = 0xffad;
132 public static final int XK_KP_Decimal = 0xffae;
133 public static final int XK_KP_Divide = 0xffaf;
134
135 public static final int XK_KP_0 = 0xffb0;
136 public static final int XK_KP_1 = 0xffb1;
137 public static final int XK_KP_2 = 0xffb2;
138 public static final int XK_KP_3 = 0xffb3;
139 public static final int XK_KP_4 = 0xffb4;
140 public static final int XK_KP_5 = 0xffb5;
141 public static final int XK_KP_6 = 0xffb6;
142 public static final int XK_KP_7 = 0xffb7;
143 public static final int XK_KP_8 = 0xffb8;
144 public static final int XK_KP_9 = 0xffb9;
145145
146146
147147
152152 * We've not found a keyboard with more than 35 function keys total.
153153 */
154154
155 public final static int XK_F1 = 0xffbe;
156 public final static int XK_F2 = 0xffbf;
157 public final static int XK_F3 = 0xffc0;
158 public final static int XK_F4 = 0xffc1;
159 public final static int XK_F5 = 0xffc2;
160 public final static int XK_F6 = 0xffc3;
161 public final static int XK_F7 = 0xffc4;
162 public final static int XK_F8 = 0xffc5;
163 public final static int XK_F9 = 0xffc6;
164 public final static int XK_F10 = 0xffc7;
165 public final static int XK_F11 = 0xffc8;
166 public final static int XK_L1 = 0xffc8;
167 public final static int XK_F12 = 0xffc9;
168 public final static int XK_L2 = 0xffc9;
169 public final static int XK_F13 = 0xffca;
170 public final static int XK_L3 = 0xffca;
171 public final static int XK_F14 = 0xffcb;
172 public final static int XK_L4 = 0xffcb;
173 public final static int XK_F15 = 0xffcc;
174 public final static int XK_L5 = 0xffcc;
175 public final static int XK_F16 = 0xffcd;
176 public final static int XK_L6 = 0xffcd;
177 public final static int XK_F17 = 0xffce;
178 public final static int XK_L7 = 0xffce;
179 public final static int XK_F18 = 0xffcf;
180 public final static int XK_L8 = 0xffcf;
181 public final static int XK_F19 = 0xffd0;
182 public final static int XK_L9 = 0xffd0;
183 public final static int XK_F20 = 0xffd1;
184 public final static int XK_L10 = 0xffd1;
185 public final static int XK_F21 = 0xffd2;
186 public final static int XK_R1 = 0xffd2;
187 public final static int XK_F22 = 0xffd3;
188 public final static int XK_R2 = 0xffd3;
189 public final static int XK_F23 = 0xffd4;
190 public final static int XK_R3 = 0xffd4;
191 public final static int XK_F24 = 0xffd5;
192 public final static int XK_R4 = 0xffd5;
193 public final static int XK_F25 = 0xffd6;
194 public final static int XK_R5 = 0xffd6;
195 public final static int XK_F26 = 0xffd7;
196 public final static int XK_R6 = 0xffd7;
197 public final static int XK_F27 = 0xffd8;
198 public final static int XK_R7 = 0xffd8;
199 public final static int XK_F28 = 0xffd9;
200 public final static int XK_R8 = 0xffd9;
201 public final static int XK_F29 = 0xffda;
202 public final static int XK_R9 = 0xffda;
203 public final static int XK_F30 = 0xffdb;
204 public final static int XK_R10 = 0xffdb;
205 public final static int XK_F31 = 0xffdc;
206 public final static int XK_R11 = 0xffdc;
207 public final static int XK_F32 = 0xffdd;
208 public final static int XK_R12 = 0xffdd;
209 public final static int XK_F33 = 0xffde;
210 public final static int XK_R13 = 0xffde;
211 public final static int XK_F34 = 0xffdf;
212 public final static int XK_R14 = 0xffdf;
213 public final static int XK_F35 = 0xffe0;
214 public final static int XK_R15 = 0xffe0;
155 public static final int XK_F1 = 0xffbe;
156 public static final int XK_F2 = 0xffbf;
157 public static final int XK_F3 = 0xffc0;
158 public static final int XK_F4 = 0xffc1;
159 public static final int XK_F5 = 0xffc2;
160 public static final int XK_F6 = 0xffc3;
161 public static final int XK_F7 = 0xffc4;
162 public static final int XK_F8 = 0xffc5;
163 public static final int XK_F9 = 0xffc6;
164 public static final int XK_F10 = 0xffc7;
165 public static final int XK_F11 = 0xffc8;
166 public static final int XK_L1 = 0xffc8;
167 public static final int XK_F12 = 0xffc9;
168 public static final int XK_L2 = 0xffc9;
169 public static final int XK_F13 = 0xffca;
170 public static final int XK_L3 = 0xffca;
171 public static final int XK_F14 = 0xffcb;
172 public static final int XK_L4 = 0xffcb;
173 public static final int XK_F15 = 0xffcc;
174 public static final int XK_L5 = 0xffcc;
175 public static final int XK_F16 = 0xffcd;
176 public static final int XK_L6 = 0xffcd;
177 public static final int XK_F17 = 0xffce;
178 public static final int XK_L7 = 0xffce;
179 public static final int XK_F18 = 0xffcf;
180 public static final int XK_L8 = 0xffcf;
181 public static final int XK_F19 = 0xffd0;
182 public static final int XK_L9 = 0xffd0;
183 public static final int XK_F20 = 0xffd1;
184 public static final int XK_L10 = 0xffd1;
185 public static final int XK_F21 = 0xffd2;
186 public static final int XK_R1 = 0xffd2;
187 public static final int XK_F22 = 0xffd3;
188 public static final int XK_R2 = 0xffd3;
189 public static final int XK_F23 = 0xffd4;
190 public static final int XK_R3 = 0xffd4;
191 public static final int XK_F24 = 0xffd5;
192 public static final int XK_R4 = 0xffd5;
193 public static final int XK_F25 = 0xffd6;
194 public static final int XK_R5 = 0xffd6;
195 public static final int XK_F26 = 0xffd7;
196 public static final int XK_R6 = 0xffd7;
197 public static final int XK_F27 = 0xffd8;
198 public static final int XK_R7 = 0xffd8;
199 public static final int XK_F28 = 0xffd9;
200 public static final int XK_R8 = 0xffd9;
201 public static final int XK_F29 = 0xffda;
202 public static final int XK_R9 = 0xffda;
203 public static final int XK_F30 = 0xffdb;
204 public static final int XK_R10 = 0xffdb;
205 public static final int XK_F31 = 0xffdc;
206 public static final int XK_R11 = 0xffdc;
207 public static final int XK_F32 = 0xffdd;
208 public static final int XK_R12 = 0xffdd;
209 public static final int XK_F33 = 0xffde;
210 public static final int XK_R13 = 0xffde;
211 public static final int XK_F34 = 0xffdf;
212 public static final int XK_R14 = 0xffdf;
213 public static final int XK_F35 = 0xffe0;
214 public static final int XK_R15 = 0xffe0;
215215
216216 /* Modifiers */
217217
218 public final static int XK_Shift_L = 0xffe1;
219 public final static int XK_Shift_R = 0xffe2;
220 public final static int XK_Control_L = 0xffe3;
221 public final static int XK_Control_R = 0xffe4;
222 public final static int XK_Caps_Lock = 0xffe5;
223 public final static int XK_Shift_Lock = 0xffe6;
224
225 public final static int XK_Meta_L = 0xffe7;
226 public final static int XK_Meta_R = 0xffe8;
227 public final static int XK_Alt_L = 0xffe9;
228 public final static int XK_Alt_R = 0xffea;
229 public final static int XK_Super_L = 0xffeb;
230 public final static int XK_Super_R = 0xffec;
231 public final static int XK_Hyper_L = 0xffed;
232 public final static int XK_Hyper_R = 0xffee;
233 public final static int XK_space = 0x0020;
234 public final static int XK_exclam = 0x0021;
235 public final static int XK_quotedbl = 0x0022;
236 public final static int XK_numbersign = 0x0023;
237 public final static int XK_dollar = 0x0024;
238 public final static int XK_percent = 0x0025;
239 public final static int XK_ampersand = 0x0026;
240 public final static int XK_apostrophe = 0x0027;
241 public final static int XK_quoteright = 0x0027;
242 public final static int XK_parenleft = 0x0028;
243 public final static int XK_parenright = 0x0029;
244 public final static int XK_asterisk = 0x002a;
245 public final static int XK_plus = 0x002b;
246 public final static int XK_comma = 0x002c;
247 public final static int XK_minus = 0x002d;
248 public final static int XK_period = 0x002e;
249 public final static int XK_slash = 0x002f;
250
251 public final static int XK_0 = 0x0030;
252 public final static int XK_1 = 0x0031;
253 public final static int XK_2 = 0x0032;
254 public final static int XK_3 = 0x0033;
255 public final static int XK_4 = 0x0034;
256 public final static int XK_5 = 0x0035;
257 public final static int XK_6 = 0x0036;
258 public final static int XK_7 = 0x0037;
259 public final static int XK_8 = 0x0038;
260 public final static int XK_9 = 0x0039;
261 public final static int XK_colon = 0x003a;
262 public final static int XK_semicolon = 0x003b;
263 public final static int XK_less = 0x003c;
264 public final static int XK_equal = 0x003d;
265 public final static int XK_greater = 0x003e;
266 public final static int XK_question = 0x003f;
267 public final static int XK_at = 0x0040;
268 public final static int XK_A = 0x0041;
269 public final static int XK_B = 0x0042;
270 public final static int XK_C = 0x0043;
271 public final static int XK_D = 0x0044;
272 public final static int XK_E = 0x0045;
273 public final static int XK_F = 0x0046;
274 public final static int XK_G = 0x0047;
275 public final static int XK_H = 0x0048;
276 public final static int XK_I = 0x0049;
277 public final static int XK_J = 0x004a;
278 public final static int XK_K = 0x004b;
279 public final static int XK_L = 0x004c;
280 public final static int XK_M = 0x004d;
281 public final static int XK_N = 0x004e;
282 public final static int XK_O = 0x004f;
283 public final static int XK_P = 0x0050;
284 public final static int XK_Q = 0x0051;
285 public final static int XK_R = 0x0052;
286 public final static int XK_S = 0x0053;
287 public final static int XK_T = 0x0054;
288 public final static int XK_U = 0x0055;
289 public final static int XK_V = 0x0056;
290 public final static int XK_W = 0x0057;
291 public final static int XK_X = 0x0058;
292 public final static int XK_Y = 0x0059;
293 public final static int XK_Z = 0x005a;
294 public final static int XK_bracketleft = 0x005b;
295 public final static int XK_backslash = 0x005c;
296 public final static int XK_bracketright = 0x005d;
297 public final static int XK_asciicircum = 0x005e;
298 public final static int XK_underscore = 0x005f;
299 public final static int XK_grave = 0x0060;
300 public final static int XK_quoteleft = 0x0060;
301 public final static int XK_a = 0x0061;
302 public final static int XK_b = 0x0062;
303 public final static int XK_c = 0x0063;
304 public final static int XK_d = 0x0064;
305 public final static int XK_e = 0x0065;
306 public final static int XK_f = 0x0066;
307 public final static int XK_g = 0x0067;
308 public final static int XK_h = 0x0068;
309 public final static int XK_i = 0x0069;
310 public final static int XK_j = 0x006a;
311 public final static int XK_k = 0x006b;
312 public final static int XK_l = 0x006c;
313 public final static int XK_m = 0x006d;
314 public final static int XK_n = 0x006e;
315 public final static int XK_o = 0x006f;
316 public final static int XK_p = 0x0070;
317 public final static int XK_q = 0x0071;
318 public final static int XK_r = 0x0072;
319 public final static int XK_s = 0x0073;
320 public final static int XK_t = 0x0074;
321 public final static int XK_u = 0x0075;
322 public final static int XK_v = 0x0076;
323 public final static int XK_w = 0x0077;
324 public final static int XK_x = 0x0078;
325 public final static int XK_y = 0x0079;
326 public final static int XK_z = 0x007a;
327 public final static int XK_braceleft = 0x007b;
328 public final static int XK_bar = 0x007c;
329 public final static int XK_braceright = 0x007d;
330 public final static int XK_asciitilde = 0x007e;
331
332 public final static int XK_nobreakspace = 0x00a0;
333 public final static int XK_exclamdown = 0x00a1;
334 public final static int XK_cent = 0x00a2;
335 public final static int XK_sterling = 0x00a3;
336 public final static int XK_currency = 0x00a4;
337 public final static int XK_yen = 0x00a5;
338 public final static int XK_brokenbar = 0x00a6;
339 public final static int XK_section = 0x00a7;
340 public final static int XK_diaeresis = 0x00a8;
341 public final static int XK_copyright = 0x00a9;
342 public final static int XK_ordfeminine = 0x00aa;
343 public final static int XK_guillemotleft = 0x00ab;
344 public final static int XK_notsign = 0x00ac;
345 public final static int XK_hyphen = 0x00ad;
346 public final static int XK_registered = 0x00ae;
347 public final static int XK_macron = 0x00af;
348 public final static int XK_degree = 0x00b0;
349 public final static int XK_plusminus = 0x00b1;
350 public final static int XK_twosuperior = 0x00b2;
351 public final static int XK_threesuperior = 0x00b3;
352 public final static int XK_acute = 0x00b4;
353 public final static int XK_mu = 0x00b5;
354 public final static int XK_paragraph = 0x00b6;
355 public final static int XK_periodcentered = 0x00b7;
356 public final static int XK_cedilla = 0x00b8;
357 public final static int XK_onesuperior = 0x00b9;
358 public final static int XK_masculine = 0x00ba;
359 public final static int XK_guillemotright = 0x00bb;
360 public final static int XK_onequarter = 0x00bc;
361 public final static int XK_onehalf = 0x00bd;
362 public final static int XK_threequarters = 0x00be;
363 public final static int XK_questiondown = 0x00bf;
364 public final static int XK_Agrave = 0x00c0;
365 public final static int XK_Aacute = 0x00c1;
366 public final static int XK_Acircumflex = 0x00c2;
367 public final static int XK_Atilde = 0x00c3;
368 public final static int XK_Adiaeresis = 0x00c4;
369 public final static int XK_Aring = 0x00c5;
370 public final static int XK_AE = 0x00c6;
371 public final static int XK_Ccedilla = 0x00c7;
372 public final static int XK_Egrave = 0x00c8;
373 public final static int XK_Eacute = 0x00c9;
374 public final static int XK_Ecircumflex = 0x00ca;
375 public final static int XK_Ediaeresis = 0x00cb;
376 public final static int XK_Igrave = 0x00cc;
377 public final static int XK_Iacute = 0x00cd;
378 public final static int XK_Icircumflex = 0x00ce;
379 public final static int XK_Idiaeresis = 0x00cf;
380 public final static int XK_ETH = 0x00d0;
381 public final static int XK_Eth = 0x00d0;
382 public final static int XK_Ntilde = 0x00d1;
383 public final static int XK_Ograve = 0x00d2;
384 public final static int XK_Oacute = 0x00d3;
385 public final static int XK_Ocircumflex = 0x00d4;
386 public final static int XK_Otilde = 0x00d5;
387 public final static int XK_Odiaeresis = 0x00d6;
388 public final static int XK_multiply = 0x00d7;
389 public final static int XK_Oslash = 0x00d8;
390 public final static int XK_Ooblique = 0x00d8;
391 public final static int XK_Ugrave = 0x00d9;
392 public final static int XK_Uacute = 0x00da;
393 public final static int XK_Ucircumflex = 0x00db;
394 public final static int XK_Udiaeresis = 0x00dc;
395 public final static int XK_Yacute = 0x00dd;
396 public final static int XK_THORN = 0x00de;
397 public final static int XK_Thorn = 0x00de;
398 public final static int XK_ssharp = 0x00df;
399 public final static int XK_agrave = 0x00e0;
400 public final static int XK_aacute = 0x00e1;
401 public final static int XK_acircumflex = 0x00e2;
402 public final static int XK_atilde = 0x00e3;
403 public final static int XK_adiaeresis = 0x00e4;
404 public final static int XK_aring = 0x00e5;
405 public final static int XK_ae = 0x00e6;
406 public final static int XK_ccedilla = 0x00e7;
407 public final static int XK_egrave = 0x00e8;
408 public final static int XK_eacute = 0x00e9;
409 public final static int XK_ecircumflex = 0x00ea;
410 public final static int XK_ediaeresis = 0x00eb;
411 public final static int XK_igrave = 0x00ec;
412 public final static int XK_iacute = 0x00ed;
413 public final static int XK_icircumflex = 0x00ee;
414 public final static int XK_idiaeresis = 0x00ef;
415 public final static int XK_eth = 0x00f0;
416 public final static int XK_ntilde = 0x00f1;
417 public final static int XK_ograve = 0x00f2;
418 public final static int XK_oacute = 0x00f3;
419 public final static int XK_ocircumflex = 0x00f4;
420 public final static int XK_otilde = 0x00f5;
421 public final static int XK_odiaeresis = 0x00f6;
422 public final static int XK_division = 0x00f7;
423 public final static int XK_oslash = 0x00f8;
424 public final static int XK_ooblique = 0x00f8;
425 public final static int XK_ugrave = 0x00f9;
426 public final static int XK_uacute = 0x00fa;
427 public final static int XK_ucircumflex = 0x00fb;
428 public final static int XK_udiaeresis = 0x00fc;
429 public final static int XK_yacute = 0x00fd;
430 public final static int XK_thorn = 0x00fe;
431 public final static int XK_ydiaeresis = 0x00ff;
432
433 public final static int XK_ISO_Level3_Shift = 0xfe03;
218 public static final int XK_Shift_L = 0xffe1;
219 public static final int XK_Shift_R = 0xffe2;
220 public static final int XK_Control_L = 0xffe3;
221 public static final int XK_Control_R = 0xffe4;
222 public static final int XK_Caps_Lock = 0xffe5;
223 public static final int XK_Shift_Lock = 0xffe6;
224
225 public static final int XK_Meta_L = 0xffe7;
226 public static final int XK_Meta_R = 0xffe8;
227 public static final int XK_Alt_L = 0xffe9;
228 public static final int XK_Alt_R = 0xffea;
229 public static final int XK_Super_L = 0xffeb;
230 public static final int XK_Super_R = 0xffec;
231 public static final int XK_Hyper_L = 0xffed;
232 public static final int XK_Hyper_R = 0xffee;
233 public static final int XK_space = 0x0020;
234 public static final int XK_exclam = 0x0021;
235 public static final int XK_quotedbl = 0x0022;
236 public static final int XK_numbersign = 0x0023;
237 public static final int XK_dollar = 0x0024;
238 public static final int XK_percent = 0x0025;
239 public static final int XK_ampersand = 0x0026;
240 public static final int XK_apostrophe = 0x0027;
241 public static final int XK_quoteright = 0x0027;
242 public static final int XK_parenleft = 0x0028;
243 public static final int XK_parenright = 0x0029;
244 public static final int XK_asterisk = 0x002a;
245 public static final int XK_plus = 0x002b;
246 public static final int XK_comma = 0x002c;
247 public static final int XK_minus = 0x002d;
248 public static final int XK_period = 0x002e;
249 public static final int XK_slash = 0x002f;
250
251 public static final int XK_0 = 0x0030;
252 public static final int XK_1 = 0x0031;
253 public static final int XK_2 = 0x0032;
254 public static final int XK_3 = 0x0033;
255 public static final int XK_4 = 0x0034;
256 public static final int XK_5 = 0x0035;
257 public static final int XK_6 = 0x0036;
258 public static final int XK_7 = 0x0037;
259 public static final int XK_8 = 0x0038;
260 public static final int XK_9 = 0x0039;
261 public static final int XK_colon = 0x003a;
262 public static final int XK_semicolon = 0x003b;
263 public static final int XK_less = 0x003c;
264 public static final int XK_equal = 0x003d;
265 public static final int XK_greater = 0x003e;
266 public static final int XK_question = 0x003f;
267 public static final int XK_at = 0x0040;
268 public static final int XK_A = 0x0041;
269 public static final int XK_B = 0x0042;
270 public static final int XK_C = 0x0043;
271 public static final int XK_D = 0x0044;
272 public static final int XK_E = 0x0045;
273 public static final int XK_F = 0x0046;
274 public static final int XK_G = 0x0047;
275 public static final int XK_H = 0x0048;
276 public static final int XK_I = 0x0049;
277 public static final int XK_J = 0x004a;
278 public static final int XK_K = 0x004b;
279 public static final int XK_L = 0x004c;
280 public static final int XK_M = 0x004d;
281 public static final int XK_N = 0x004e;
282 public static final int XK_O = 0x004f;
283 public static final int XK_P = 0x0050;
284 public static final int XK_Q = 0x0051;
285 public static final int XK_R = 0x0052;
286 public static final int XK_S = 0x0053;
287 public static final int XK_T = 0x0054;
288 public static final int XK_U = 0x0055;
289 public static final int XK_V = 0x0056;
290 public static final int XK_W = 0x0057;
291 public static final int XK_X = 0x0058;
292 public static final int XK_Y = 0x0059;
293 public static final int XK_Z = 0x005a;
294 public static final int XK_bracketleft = 0x005b;
295 public static final int XK_backslash = 0x005c;
296 public static final int XK_bracketright = 0x005d;
297 public static final int XK_asciicircum = 0x005e;
298 public static final int XK_underscore = 0x005f;
299 public static final int XK_grave = 0x0060;
300 public static final int XK_quoteleft = 0x0060;
301 public static final int XK_a = 0x0061;
302 public static final int XK_b = 0x0062;
303 public static final int XK_c = 0x0063;
304 public static final int XK_d = 0x0064;
305 public static final int XK_e = 0x0065;
306 public static final int XK_f = 0x0066;
307 public static final int XK_g = 0x0067;
308 public static final int XK_h = 0x0068;
309 public static final int XK_i = 0x0069;
310 public static final int XK_j = 0x006a;
311 public static final int XK_k = 0x006b;
312 public static final int XK_l = 0x006c;
313 public static final int XK_m = 0x006d;
314 public static final int XK_n = 0x006e;
315 public static final int XK_o = 0x006f;
316 public static final int XK_p = 0x0070;
317 public static final int XK_q = 0x0071;
318 public static final int XK_r = 0x0072;
319 public static final int XK_s = 0x0073;
320 public static final int XK_t = 0x0074;
321 public static final int XK_u = 0x0075;
322 public static final int XK_v = 0x0076;
323 public static final int XK_w = 0x0077;
324 public static final int XK_x = 0x0078;
325 public static final int XK_y = 0x0079;
326 public static final int XK_z = 0x007a;
327 public static final int XK_braceleft = 0x007b;
328 public static final int XK_bar = 0x007c;
329 public static final int XK_braceright = 0x007d;
330 public static final int XK_asciitilde = 0x007e;
331
332 public static final int XK_nobreakspace = 0x00a0;
333 public static final int XK_exclamdown = 0x00a1;
334 public static final int XK_cent = 0x00a2;
335 public static final int XK_sterling = 0x00a3;
336 public static final int XK_currency = 0x00a4;
337 public static final int XK_yen = 0x00a5;
338 public static final int XK_brokenbar = 0x00a6;
339 public static final int XK_section = 0x00a7;
340 public static final int XK_diaeresis = 0x00a8;
341 public static final int XK_copyright = 0x00a9;
342 public static final int XK_ordfeminine = 0x00aa;
343 public static final int XK_guillemotleft = 0x00ab;
344 public static final int XK_notsign = 0x00ac;
345 public static final int XK_hyphen = 0x00ad;
346 public static final int XK_registered = 0x00ae;
347 public static final int XK_macron = 0x00af;
348 public static final int XK_degree = 0x00b0;
349 public static final int XK_plusminus = 0x00b1;
350 public static final int XK_twosuperior = 0x00b2;
351 public static final int XK_threesuperior = 0x00b3;
352 public static final int XK_acute = 0x00b4;
353 public static final int XK_mu = 0x00b5;
354 public static final int XK_paragraph = 0x00b6;
355 public static final int XK_periodcentered = 0x00b7;
356 public static final int XK_cedilla = 0x00b8;
357 public static final int XK_onesuperior = 0x00b9;
358 public static final int XK_masculine = 0x00ba;
359 public static final int XK_guillemotright = 0x00bb;
360 public static final int XK_onequarter = 0x00bc;
361 public static final int XK_onehalf = 0x00bd;
362 public static final int XK_threequarters = 0x00be;
363 public static final int XK_questiondown = 0x00bf;
364 public static final int XK_Agrave = 0x00c0;
365 public static final int XK_Aacute = 0x00c1;
366 public static final int XK_Acircumflex = 0x00c2;
367 public static final int XK_Atilde = 0x00c3;
368 public static final int XK_Adiaeresis = 0x00c4;
369 public static final int XK_Aring = 0x00c5;
370 public static final int XK_AE = 0x00c6;
371 public static final int XK_Ccedilla = 0x00c7;
372 public static final int XK_Egrave = 0x00c8;
373 public static final int XK_Eacute = 0x00c9;
374 public static final int XK_Ecircumflex = 0x00ca;
375 public static final int XK_Ediaeresis = 0x00cb;
376 public static final int XK_Igrave = 0x00cc;
377 public static final int XK_Iacute = 0x00cd;
378 public static final int XK_Icircumflex = 0x00ce;
379 public static final int XK_Idiaeresis = 0x00cf;
380 public static final int XK_ETH = 0x00d0;
381 public static final int XK_Eth = 0x00d0;
382 public static final int XK_Ntilde = 0x00d1;
383 public static final int XK_Ograve = 0x00d2;
384 public static final int XK_Oacute = 0x00d3;
385 public static final int XK_Ocircumflex = 0x00d4;
386 public static final int XK_Otilde = 0x00d5;
387 public static final int XK_Odiaeresis = 0x00d6;
388 public static final int XK_multiply = 0x00d7;
389 public static final int XK_Oslash = 0x00d8;
390 public static final int XK_Ooblique = 0x00d8;
391 public static final int XK_Ugrave = 0x00d9;
392 public static final int XK_Uacute = 0x00da;
393 public static final int XK_Ucircumflex = 0x00db;
394 public static final int XK_Udiaeresis = 0x00dc;
395 public static final int XK_Yacute = 0x00dd;
396 public static final int XK_THORN = 0x00de;
397 public static final int XK_Thorn = 0x00de;
398 public static final int XK_ssharp = 0x00df;
399 public static final int XK_agrave = 0x00e0;
400 public static final int XK_aacute = 0x00e1;
401 public static final int XK_acircumflex = 0x00e2;
402 public static final int XK_atilde = 0x00e3;
403 public static final int XK_adiaeresis = 0x00e4;
404 public static final int XK_aring = 0x00e5;
405 public static final int XK_ae = 0x00e6;
406 public static final int XK_ccedilla = 0x00e7;
407 public static final int XK_egrave = 0x00e8;
408 public static final int XK_eacute = 0x00e9;
409 public static final int XK_ecircumflex = 0x00ea;
410 public static final int XK_ediaeresis = 0x00eb;
411 public static final int XK_igrave = 0x00ec;
412 public static final int XK_iacute = 0x00ed;
413 public static final int XK_icircumflex = 0x00ee;
414 public static final int XK_idiaeresis = 0x00ef;
415 public static final int XK_eth = 0x00f0;
416 public static final int XK_ntilde = 0x00f1;
417 public static final int XK_ograve = 0x00f2;
418 public static final int XK_oacute = 0x00f3;
419 public static final int XK_ocircumflex = 0x00f4;
420 public static final int XK_otilde = 0x00f5;
421 public static final int XK_odiaeresis = 0x00f6;
422 public static final int XK_division = 0x00f7;
423 public static final int XK_oslash = 0x00f8;
424 public static final int XK_ooblique = 0x00f8;
425 public static final int XK_ugrave = 0x00f9;
426 public static final int XK_uacute = 0x00fa;
427 public static final int XK_ucircumflex = 0x00fb;
428 public static final int XK_udiaeresis = 0x00fc;
429 public static final int XK_yacute = 0x00fd;
430 public static final int XK_thorn = 0x00fe;
431 public static final int XK_ydiaeresis = 0x00ff;
432
433 public static final int XK_ISO_Level3_Shift = 0xfe03;
434434
435435 public static int mapKeySymToLWJGLKeyCode(long keysym) {
436436 switch ((int)keysym) {
4848 private static final int WHEEL_SCALE = 120;
4949
5050 /* X11 constants */
51 private final static int Button1 = 1;
52 private final static int Button2 = 2;
53 private final static int Button3 = 3;
54 private final static int Button4 = 4;
55 private final static int Button5 = 5;
56
57 private final static int ButtonPress = 4;
58 private final static int ButtonRelease = 5;
51 private static final int Button1 = 1;
52 private static final int Button2 = 2;
53 private static final int Button3 = 3;
54 private static final int Button4 = 4;
55 private static final int Button5 = 5;
56
57 private static final int ButtonPress = 4;
58 private static final int ButtonRelease = 5;
5959
6060 private final long display;
6161 private final long window;
5757 import com.apple.eawt.ApplicationAdapter;
5858 import com.apple.eawt.ApplicationEvent;
5959
60 import static org.lwjgl.opengl.GL11.*;
61
6062 final class MacOSXDisplay implements DisplayImplementation {
6163 private static final int PBUFFER_HANDLE_SIZE = 24;
6264 private static final int GAMMA_LENGTH = 256;
7476
7577 MacOSXDisplay() {
7678 try {
77 AccessController.doPrivileged(new PrivilegedExceptionAction() {
79 AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
7880 public Object run() throws Exception {
7981 Application.getApplication().addApplicationListener(new ApplicationAdapter() {
8082 public void handleQuit(ApplicationEvent event) {
125127 canvas_listener = null;
126128 }
127129 if (frame != null) {
128 AccessController.doPrivileged(new PrivilegedAction() {
130 AccessController.doPrivileged(new PrivilegedAction<Object>() {
129131 public Object run() {
130132 if (MacOSXFrame.getDevice().getFullScreenWindow() == frame)
131133 MacOSXFrame.getDevice().setFullScreenWindow(null);
153155 return null;
154156 }
155157
156 private boolean equals(java.awt.DisplayMode awt_mode, DisplayMode mode) {
158 private static boolean equals(java.awt.DisplayMode awt_mode, DisplayMode mode) {
157159 return awt_mode.getWidth() == mode.getWidth() && awt_mode.getHeight() == mode.getHeight()
158160 && awt_mode.getBitDepth() == mode.getBitsPerPixel() && awt_mode.getRefreshRate() == mode.getFrequency();
159161 }
160162
161163 public void switchDisplayMode(DisplayMode mode) throws LWJGLException {
162164 java.awt.DisplayMode[] awt_modes = MacOSXFrame.getDevice().getDisplayModes();
163 for (int i = 0; i < awt_modes.length; i++)
164 if (equals(awt_modes[i], mode)) {
165 requested_mode = awt_modes[i];
165 for ( java.awt.DisplayMode awt_mode : awt_modes ) {
166 if (equals(awt_mode, mode)) {
167 requested_mode = awt_mode;
166168 return;
167169 }
170 }
168171 throw new LWJGLException(mode + " is not supported");
169172 }
170173
177180
178181 private native void restoreGamma();
179182
180 private DisplayMode createLWJGLDisplayMode(java.awt.DisplayMode awt_mode) {
183 private static DisplayMode createLWJGLDisplayMode(java.awt.DisplayMode awt_mode) {
181184 int bit_depth;
182185 int refresh_rate;
183186 int awt_bit_depth = awt_mode.getBitDepth();
199202
200203 public DisplayMode[] getAvailableDisplayModes() throws LWJGLException {
201204 java.awt.DisplayMode[] awt_modes = MacOSXFrame.getDevice().getDisplayModes();
202 List modes = new ArrayList();
203 for (int i = 0; i < awt_modes.length; i++)
204 if (awt_modes[i].getBitDepth() >= 16)
205 modes.add(createLWJGLDisplayMode(awt_modes[i]));
206 DisplayMode[] mode_list = new DisplayMode[modes.size()];
207 modes.toArray(mode_list);
208 return mode_list;
205 List<DisplayMode> modes = new ArrayList<DisplayMode>();
206 for ( java.awt.DisplayMode awt_mode : awt_modes )
207 if ( awt_mode.getBitDepth() >= 16 )
208 modes.add(createLWJGLDisplayMode(awt_mode));
209 return modes.toArray(new DisplayMode[modes.size()]);
209210 }
210211
211212 public void setTitle(String title) {
212 if (frame != null)
213 if (frame != null)
213214 frame.setTitle(title);
214215 }
215216
246247 }
247248 }
248249
249 private final static IntBuffer current_viewport = BufferUtils.createIntBuffer(16);
250 private static final IntBuffer current_viewport = BufferUtils.createIntBuffer(16);
250251 public void update() {
251252 boolean should_update = canvas_listener.syncShouldUpdateContext();
252253 /*
281282 if (should_update) {
282283 drawable.context.update();
283284 /* This is necessary to make sure the context won't "forget" about the view size */
284 GL11.glGetInteger(GL11.GL_VIEWPORT, current_viewport);
285 GL11.glViewport(current_viewport.get(0), current_viewport.get(1), current_viewport.get(2), current_viewport.get(3));
285 glGetInteger(GL_VIEWPORT, current_viewport);
286 glViewport(current_viewport.get(0), current_viewport.get(1), current_viewport.get(2), current_viewport.get(3));
286287 }
287288 if (frame != null && mouse_queue != null) {
288289 if (frame.syncShouldReleaseCursor())
431432 public boolean isBufferLost(PeerInfo handle) {
432433 return false;
433434 }
434
435
435436 public PeerInfo createPbuffer(int width, int height, PixelFormat pixel_format,
436437 IntBuffer pixelFormatCaps,
437438 IntBuffer pBufferAttribs) throws LWJGLException {
465466 public int setIcon(ByteBuffer[] icons) {
466467 /* int size = 0;
467468 int biggest = -1;
468
469
469470 for (int i=0;i<icons.length;i++) {
470471 if (icons[i].remaining() > size) {
471472 biggest = i;
472473 size = icons[i].remaining();
473474 }
474475 }
475
476
476477 if (biggest == -1) {
477478 return 0;
478479 }
479
480
480481 int width;
481482 int height;
482
483
483484 IntBuffer biggest_icon = icons[biggest].asIntBuffer();
484485 int[] imageData = new int[biggest_icon.remaining()];
485486 width = height = (int) Math.sqrt(imageData.length);
486487 biggest_icon.get(imageData);
487
488
488489 BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
489490 img.setRGB(0, 0, width, height, imageData, 0, width);
490491 frame.setIconImage(img);
491
492
492493 return 1;*/
493494 // Don't use any icon, since Mac OS X windows don't have window icons
494495 return 0;
3737 /**
3838 *
3939 * @author elias_naur <elias_naur@users.sourceforge.net>
40 * @version $Revision: 3116 $
41 * $Id: MacOSXDisplayPeerInfo.java 3116 2008-08-19 16:46:03Z spasi $
40 * @version $Revision: 3418 $
41 * $Id: MacOSXDisplayPeerInfo.java 3418 2010-09-28 21:11:35Z spasi $
4242 */
4343 final class MacOSXDisplayPeerInfo extends MacOSXCanvasPeerInfo {
44 private boolean locked = false;
44 private boolean locked;
4545
4646 MacOSXDisplayPeerInfo(PixelFormat pixel_format, boolean support_pbuffer) throws LWJGLException {
4747 super(pixel_format, support_pbuffer);
5555 final class MacOSXFrame extends Frame implements WindowListener, ComponentListener {
5656
5757 private static final long serialVersionUID = -5823294716668988777L;
58
58
5959 private final MacOSXGLCanvas canvas;
6060 private boolean close_requested;
6161
7777 setUndecorated(fullscreen || undecorated);
7878 if ( fullscreen ) {
7979 try {
80 AccessController.doPrivileged(new PrivilegedExceptionAction() {
80 AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
8181 public Object run() throws Exception {
8282 getDevice().setFullScreenWindow(MacOSXFrame.this);
8383 getDevice().setDisplayMode(requested_mode);
109109 Insets insets = getInsets();
110110 setBounds(x, y, width + insets.left + insets.right, height + insets.top + insets.bottom);
111111 }
112
112
113113 public Rectangle syncGetBounds() {
114114 synchronized ( this ) {
115115 return bounds;
5353 }
5454
5555 public void setGrabbed(boolean grab) {
56 super.setGrabbed(grab);
57 warpCursor();
58 grabMouse(grab);
56 if (is_grabbed != grab) {
57 super.setGrabbed(grab);
58 warpCursor();
59 grabMouse(grab);
60 }
5961 }
6062
6163 private static synchronized void grabMouse(boolean grab) {
62 if (is_grabbed != grab) {
63 is_grabbed = grab;
64 if (!grab)
65 nGrabMouse(grab);
66 }
64 is_grabbed = grab;
65 if (!grab)
66 nGrabMouse(grab);
6767 }
6868
6969 protected void resetCursorToCenter() {
3838 /**
3939 *
4040 * @author elias_naur <elias_naur@users.sourceforge.net>
41 * @version $Revision: 3116 $
42 * $Id: PeerInfo.java 3116 2008-08-19 16:46:03Z spasi $
41 * @version $Revision: 3418 $
42 * $Id: PeerInfo.java 3418 2010-09-28 21:11:35Z spasi $
4343 */
4444 abstract class PeerInfo {
4545 private final ByteBuffer handle;
5454 doLockAndInitHandle();
5555 }
5656
57 public synchronized final void unlock() throws LWJGLException {
57 public final synchronized void unlock() throws LWJGLException {
5858 if (lock_count <= 0)
5959 throw new IllegalStateException("PeerInfo not locked!");
6060 if (Thread.currentThread() != locking_thread)
7070 protected abstract void doLockAndInitHandle() throws LWJGLException;
7171 protected abstract void doUnlock() throws LWJGLException;
7272
73 public synchronized final ByteBuffer lockAndGetHandle() throws LWJGLException {
73 public final synchronized ByteBuffer lockAndGetHandle() throws LWJGLException {
7474 Thread this_thread = Thread.currentThread();
7575 while (locking_thread != null && locking_thread != this_thread) {
7676 try {
3030 */
3131 package org.lwjgl.opengl;
3232
33 import static org.lwjgl.opengl.GL11.*;
34
3335 class ReferencesStack {
3436 private References[] references_stack;
3537 private int stack_pos;
4345 if (pos == references_stack.length) {
4446 growStack();
4547 }
46 references_stack[pos].copy(references_stack[pos - 1], GL11.GL_ALL_CLIENT_ATTRIB_BITS);
48 references_stack[pos].copy(references_stack[pos - 1], GL_ALL_CLIENT_ATTRIB_BITS);
4749 }
4850
4951 public References popState(int mask) {
3434
3535 import org.lwjgl.BufferUtils;
3636
37 import static org.lwjgl.opengl.GL11.*;
38
3739 /** This class represents the state necessary for render-to-texture. */
3840 public final class RenderTexture {
3941
213215
214216 if ( useRGB ) {
215217 pixelFormatCaps.put(isRectangle ? WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV : WGL_BIND_TO_TEXTURE_RGB_ARB);
216 pixelFormatCaps.put(GL11.GL_TRUE);
218 pixelFormatCaps.put(GL_TRUE);
217219
218220 pBufferAttribs.put(WGL_TEXTURE_FORMAT_ARB);
219221 pBufferAttribs.put(WGL_TEXTURE_RGB_ARB);
220222 } else if ( useRGBA ) {
221223 pixelFormatCaps.put(isRectangle ? WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV : WGL_BIND_TO_TEXTURE_RGBA_ARB);
222 pixelFormatCaps.put(GL11.GL_TRUE);
224 pixelFormatCaps.put(GL_TRUE);
223225
224226 pBufferAttribs.put(WGL_TEXTURE_FORMAT_ARB);
225227 pBufferAttribs.put(WGL_TEXTURE_RGBA_ARB);
227229
228230 if ( useDepth ) {
229231 pixelFormatCaps.put(isRectangle ? WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV : WGL_BIND_TO_TEXTURE_DEPTH_NV);
230 pixelFormatCaps.put(GL11.GL_TRUE);
232 pixelFormatCaps.put(GL_TRUE);
231233
232234 pBufferAttribs.put(WGL_DEPTH_TEXTURE_FORMAT_NV);
233235 pBufferAttribs.put(WGL_TEXTURE_DEPTH_COMPONENT_NV);
3030 */
3131 package org.lwjgl.opengl;
3232
33 import java.nio.IntBuffer;
34
35 import static org.lwjgl.opengl.GL15.*;
36 import static org.lwjgl.opengl.GL21.*;
37 import static org.lwjgl.opengl.GL40.*;
38
3339 final class StateTracker {
40
3441 private ReferencesStack references_stack;
3542 private final StateStack attrib_stack;
3643
3744 private boolean insideBeginEnd;
45
46 // VAOs are not shareable between contexts, no need to sync or make this static.
47 private final FastIntMap<VAOState> vaoMap = new FastIntMap<VAOState>();
3848
3949 StateTracker() {
4050 attrib_stack = new StateStack(0);
7080 references_stack.pushState();
7181 }
7282
73 static ReferencesStack getReferencesStack(ContextCapabilities caps) {
74 return caps.tracker.references_stack;
83 static References getReferences(ContextCapabilities caps) {
84 return caps.tracker.references_stack.getReferences();
7585 }
7686
77 static void bindBuffer(ContextCapabilities caps, int target, int buffer) {
78 ReferencesStack references_stack = getReferencesStack(caps);
79 switch(target) {
80 case GL15.GL_ELEMENT_ARRAY_BUFFER:
81 references_stack.getReferences().elementArrayBuffer = buffer;
82 break;
83 case GL15.GL_ARRAY_BUFFER:
84 references_stack.getReferences().arrayBuffer = buffer;
85 break;
86 case GL21.GL_PIXEL_PACK_BUFFER:
87 references_stack.getReferences().pixelPackBuffer = buffer;
88 break;
89 case GL21.GL_PIXEL_UNPACK_BUFFER:
90 references_stack.getReferences().pixelUnpackBuffer = buffer;
91 break;
92 case GL40.GL_DRAW_INDIRECT_BUFFER:
93 references_stack.getReferences().indirectBuffer = buffer;
94 break;
87 static void bindBuffer(ContextCapabilities caps, int target, int buffer) {
88 final BaseReferences references = getReferences(caps);
89 switch ( target ) {
90 case GL_ARRAY_BUFFER:
91 references.arrayBuffer = buffer;
92 break;
93 case GL_ELEMENT_ARRAY_BUFFER:
94 // When a vertex array object is currently bound, update
95 // the VAO state instead of client state.
96 if ( references.vertexArrayObject != 0 )
97 caps.tracker.vaoMap.get(references.vertexArrayObject).elementArrayBuffer = buffer;
98 else
99 references.elementArrayBuffer = buffer;
100 break;
101 case GL_PIXEL_PACK_BUFFER:
102 references.pixelPackBuffer = buffer;
103 break;
104 case GL_PIXEL_UNPACK_BUFFER:
105 references.pixelUnpackBuffer = buffer;
106 break;
107 case GL_DRAW_INDIRECT_BUFFER:
108 references.indirectBuffer = buffer;
109 break;
110 }
111 }
95112
96 }
97 }
98 }
113 static void bindVAO(final ContextCapabilities caps, final int array) {
114 final FastIntMap<VAOState> vaoMap = caps.tracker.vaoMap;
115 if ( !vaoMap.containsKey(array) )
116 vaoMap.put(array, new VAOState());
117
118 getReferences(caps).vertexArrayObject = array;
119 }
120
121 static void deleteVAO(final ContextCapabilities caps, final IntBuffer arrays) {
122 for ( int i = arrays.position(); i < arrays.limit(); i++ )
123 deleteVAO(caps, arrays.get(i));
124 }
125
126 static void deleteVAO(final ContextCapabilities caps, final int array) {
127 caps.tracker.vaoMap.remove(array);
128
129 final BaseReferences references = getReferences(caps);
130 if ( references.vertexArrayObject == array )
131 references.vertexArrayObject = 0;
132 }
133
134 /**
135 * Returns the currently bound ELEMENT_ARRAY_BUFFER. If a vertex array
136 * object is currently bound, then the VAO state is returned instead
137 * of the client state.
138 *
139 * @return the currently bound ELEMENT_ARRAY_BUFFER.
140 */
141 static int getElementArrayBufferBound(final ContextCapabilities caps) {
142 final BaseReferences references = getReferences(caps);
143
144 if ( references.vertexArrayObject == 0 )
145 return references.elementArrayBuffer;
146 else
147 return caps.tracker.vaoMap.get(references.vertexArrayObject).elementArrayBuffer;
148 }
149
150 /**
151 * Simple class to help us track VAO state. Currently
152 * only ELEMENT_ARRAY_BUFFER_BINDING is tracked, since
153 * that's the only state we check from tables 6.6-6.9.
154 */
155 private static class VAOState {
156
157 int elementArrayBuffer;
158
159 }
160
161 }
3030 */
3131 package org.lwjgl.opengl;
3232
33 import static org.lwjgl.opengl.ARBImaging.*;
34 import static org.lwjgl.opengl.GL11.*;
35 import static org.lwjgl.opengl.GL30.*;
3336
3437 /**
3538 * Simple utility class.
3639 *
3740 * @author cix_foo <cix_foo@users.sourceforge.net>
38 * @version $Revision: 3316 $
41 * @version $Revision: 3418 $
3942 */
4043
4144 public final class Util {
4245 /** No c'tor */
4346 private Util() {
4447 }
45
48
4649 /**
47 * Throws OpenGLException if GL11.glGetError() returns anything else than GL11.GL_NO_ERROR
50 * Throws OpenGLException if glGetError() returns anything else than GL_NO_ERROR
4851 *
4952 */
5053 public static void checkGLError() throws OpenGLException {
5154 if ( ContextCapabilities.DEBUG && GLContext.getCapabilities().tracker.isBeginEnd() ) // Do not call GetError inside a Begin/End pair.
5255 return;
53 int err = GL11.glGetError();
54 if ( err != GL11.GL_NO_ERROR ) {
56 int err = glGetError();
57 if ( err != GL_NO_ERROR ) {
5558 throw new OpenGLException(err);
5659 }
5760 }
6164 */
6265 public static String translateGLErrorString(int error_code) {
6366 switch (error_code) {
64 case GL11.GL_NO_ERROR:
67 case GL_NO_ERROR:
6568 return "No error";
66 case GL11.GL_INVALID_ENUM:
69 case GL_INVALID_ENUM:
6770 return "Invalid enum";
68 case GL11.GL_INVALID_VALUE:
71 case GL_INVALID_VALUE:
6972 return "Invalid value";
70 case GL11.GL_INVALID_OPERATION:
73 case GL_INVALID_OPERATION:
7174 return "Invalid operation";
72 case GL11.GL_STACK_OVERFLOW:
75 case GL_STACK_OVERFLOW:
7376 return "Stack overflow";
74 case GL11.GL_STACK_UNDERFLOW:
77 case GL_STACK_UNDERFLOW:
7578 return "Stack underflow";
76 case GL11.GL_OUT_OF_MEMORY:
79 case GL_OUT_OF_MEMORY:
7780 return "Out of memory";
78 case ARBImaging.GL_TABLE_TOO_LARGE:
81 case GL_TABLE_TOO_LARGE:
7982 return "Table too large";
80 case EXTFramebufferObject.GL_INVALID_FRAMEBUFFER_OPERATION_EXT:
83 case GL_INVALID_FRAMEBUFFER_OPERATION:
8184 return "Invalid framebuffer operation";
8285 default:
8386 return null;
3939 /**
4040 *
4141 * @author elias_naur <elias_naur@users.sourceforge.net>
42 * @version $Revision: 3116 $
43 * $Id: WindowsAWTGLCanvasPeerInfo.java 3116 2008-08-19 16:46:03Z spasi $
42 * @version $Revision: 3418 $
43 * $Id: WindowsAWTGLCanvasPeerInfo.java 3418 2010-09-28 21:11:35Z spasi $
4444 */
4545 final class WindowsAWTGLCanvasPeerInfo extends WindowsPeerInfo {
4646 private final Canvas component;
4747 private final AWTSurfaceLock awt_surface = new AWTSurfaceLock();
4848 private final PixelFormat pixel_format;
49 private boolean has_pixel_format= false;
49 private boolean has_pixel_format;
5050
5151 WindowsAWTGLCanvasPeerInfo(Canvas component, PixelFormat pixel_format) {
5252 this.component = component;
4343 /**
4444 *
4545 * @author elias_naur <elias_naur@users.sourceforge.net>
46 * @version $Revision: 3002 $
47 * $Id: WindowsCanvasImplementation.java 3002 2008-04-10 20:25:54Z elias_naur $
46 * @version $Revision: 3418 $
47 * $Id: WindowsCanvasImplementation.java 3418 2010-09-28 21:11:35Z spasi $
4848 */
4949 final class WindowsCanvasImplementation implements AWTCanvasImplementation {
5050 static {
5151 // Make sure the awt stuff is properly initialised (the jawt library in particular)
5252 Toolkit.getDefaultToolkit();
53 AccessController.doPrivileged(new PrivilegedAction() {
53 AccessController.doPrivileged(new PrivilegedAction<Object>() {
5454 public Object run() {
5555 try {
5656 System.loadLibrary("jawt");
3838
3939 /**
4040 * @author elias_naur <elias_naur@users.sourceforge.net>
41 * @version $Revision: 3116 $
42 * $Id: WindowsContextImplementation.java 3116 2008-08-19 16:46:03Z spasi $
41 * @version $Revision: 3412 $
42 * $Id: WindowsContextImplementation.java 3412 2010-09-26 23:43:24Z spasi $
4343 */
4444 final class WindowsContextImplementation implements ContextImplementation {
4545
5353 }
5454
5555 private static native ByteBuffer nCreate(ByteBuffer peer_handle, IntBuffer attribs_handle, ByteBuffer shared_context_handle) throws LWJGLException;
56
57 native long getHGLRC(ByteBuffer context_handle);
58
59 native long getHDC(ByteBuffer peer_info_handle);
5660
5761 public void swapBuffers() throws LWJGLException {
5862 Context current_context = Context.getCurrentContext();
5050 import org.lwjgl.input.Mouse;
5151
5252 final class WindowsDisplay implements DisplayImplementation {
53 private final static int GAMMA_LENGTH = 256;
54
55 private final static int WM_CANCELMODE = 0x001F;
56 private final static int WM_MOUSEMOVE = 0x0200;
57 private final static int WM_LBUTTONDOWN = 0x0201;
58 private final static int WM_LBUTTONUP = 0x0202;
59 private final static int WM_LBUTTONDBLCLK = 0x0203;
60 private final static int WM_RBUTTONDOWN = 0x0204;
61 private final static int WM_RBUTTONUP = 0x0205;
62 private final static int WM_RBUTTONDBLCLK = 0x0206;
63 private final static int WM_MBUTTONDOWN = 0x0207;
64 private final static int WM_MBUTTONUP = 0x0208;
65 private final static int WM_MBUTTONDBLCLK = 0x0209;
66 private final static int WM_MOUSEWHEEL = 0x020A;
67 private final static int WM_CAPTURECHANGED = 0x0215;
68 private final static int WM_MOUSELEAVE = 0x02A3;
69 private final static int WM_KEYDOWN = 256;
70 private final static int WM_KEYUP = 257;
71 private final static int WM_SYSKEYUP = 261;
72 private final static int WM_SYSKEYDOWN = 260;
73 private final static int WM_SYSCHAR = 262;
74 private final static int WM_CHAR = 258;
75 private final static int WM_SETICON = 0x0080;
76
77 private final static int WM_QUIT = 0x0012;
78 private final static int WM_SYSCOMMAND = 0x0112;
79 private final static int WM_PAINT = 0x000F;
80 private final static int WM_KILLFOCUS = 8;
81 private final static int WM_SETFOCUS = 7;
82
83 private final static int SC_SIZE = 0xF000;
84 private final static int SC_MOVE = 0xF010;
85 private final static int SC_MINIMIZE = 0xF020;
86 private final static int SC_MAXIMIZE = 0xF030;
87 private final static int SC_NEXTWINDOW = 0xF040;
88 private final static int SC_PREVWINDOW = 0xF050;
89 private final static int SC_CLOSE = 0xF060;
90 private final static int SC_VSCROLL = 0xF070;
91 private final static int SC_HSCROLL = 0xF080;
92 private final static int SC_MOUSEMENU = 0xF090;
93 private final static int SC_KEYMENU = 0xF100;
94 private final static int SC_ARRANGE = 0xF110;
95 private final static int SC_RESTORE = 0xF120;
96 private final static int SC_TASKLIST = 0xF130;
97 private final static int SC_SCREENSAVE = 0xF140;
98 private final static int SC_HOTKEY = 0xF150;
99 private final static int SC_DEFAULT = 0xF160;
100 private final static int SC_MONITORPOWER = 0xF170;
101 private final static int SC_CONTEXTHELP = 0xF180;
102 private final static int SC_SEPARATOR = 0xF00F;
103
104 final static int SM_CXCURSOR = 13;
105 final static int SM_CYCURSOR = 14;
106 final static int SM_CMOUSEBUTTONS = 43;
107 final static int SM_MOUSEWHEELPRESENT = 75;
108
109 private final static int SIZE_RESTORED = 0;
110 private final static int SIZE_MINIMIZED = 1;
111 private final static int SIZE_MAXIMIZED = 2;
112 private final static int WM_SIZE = 0x0005;
113 private final static int WM_ACTIVATE = 0x0006;
114 private final static int WA_INACTIVE = 0;
115 private final static int WA_ACTIVE = 1;
116 private final static int WA_CLICKACTIVE = 2;
117 private final static int SW_SHOWMINNOACTIVE = 7;
118 private final static int SW_SHOWDEFAULT = 10;
119 private final static int SW_RESTORE = 9;
120
121 private final static int ICON_SMALL = 0;
122 private final static int ICON_BIG = 1;
123
124 private final static IntBuffer rect_buffer = BufferUtils.createIntBuffer(4);
125 private final static Rect rect = new Rect();
126 private final static Rect rect2 = new Rect();
53 private static final int GAMMA_LENGTH = 256;
54
55 private static final int WM_CANCELMODE = 0x001F;
56 private static final int WM_MOUSEMOVE = 0x0200;
57 private static final int WM_LBUTTONDOWN = 0x0201;
58 private static final int WM_LBUTTONUP = 0x0202;
59 private static final int WM_LBUTTONDBLCLK = 0x0203;
60 private static final int WM_RBUTTONDOWN = 0x0204;
61 private static final int WM_RBUTTONUP = 0x0205;
62 private static final int WM_RBUTTONDBLCLK = 0x0206;
63 private static final int WM_MBUTTONDOWN = 0x0207;
64 private static final int WM_MBUTTONUP = 0x0208;
65 private static final int WM_MBUTTONDBLCLK = 0x0209;
66 private static final int WM_MOUSEWHEEL = 0x020A;
67 private static final int WM_CAPTURECHANGED = 0x0215;
68 private static final int WM_MOUSELEAVE = 0x02A3;
69 private static final int WM_KEYDOWN = 256;
70 private static final int WM_KEYUP = 257;
71 private static final int WM_SYSKEYUP = 261;
72 private static final int WM_SYSKEYDOWN = 260;
73 private static final int WM_SYSCHAR = 262;
74 private static final int WM_CHAR = 258;
75 private static final int WM_SETICON = 0x0080;
76
77 private static final int WM_QUIT = 0x0012;
78 private static final int WM_SYSCOMMAND = 0x0112;
79 private static final int WM_PAINT = 0x000F;
80 private static final int WM_KILLFOCUS = 8;
81 private static final int WM_SETFOCUS = 7;
82
83 private static final int SC_SIZE = 0xF000;
84 private static final int SC_MOVE = 0xF010;
85 private static final int SC_MINIMIZE = 0xF020;
86 private static final int SC_MAXIMIZE = 0xF030;
87 private static final int SC_NEXTWINDOW = 0xF040;
88 private static final int SC_PREVWINDOW = 0xF050;
89 private static final int SC_CLOSE = 0xF060;
90 private static final int SC_VSCROLL = 0xF070;
91 private static final int SC_HSCROLL = 0xF080;
92 private static final int SC_MOUSEMENU = 0xF090;
93 private static final int SC_KEYMENU = 0xF100;
94 private static final int SC_ARRANGE = 0xF110;
95 private static final int SC_RESTORE = 0xF120;
96 private static final int SC_TASKLIST = 0xF130;
97 private static final int SC_SCREENSAVE = 0xF140;
98 private static final int SC_HOTKEY = 0xF150;
99 private static final int SC_DEFAULT = 0xF160;
100 private static final int SC_MONITORPOWER = 0xF170;
101 private static final int SC_CONTEXTHELP = 0xF180;
102 private static final int SC_SEPARATOR = 0xF00F;
103
104 static final int SM_CXCURSOR = 13;
105 static final int SM_CYCURSOR = 14;
106 static final int SM_CMOUSEBUTTONS = 43;
107 static final int SM_MOUSEWHEELPRESENT = 75;
108
109 private static final int SIZE_RESTORED = 0;
110 private static final int SIZE_MINIMIZED = 1;
111 private static final int SIZE_MAXIMIZED = 2;
112 private static final int WM_SIZE = 0x0005;
113 private static final int WM_ACTIVATE = 0x0006;
114 private static final int WA_INACTIVE = 0;
115 private static final int WA_ACTIVE = 1;
116 private static final int WA_CLICKACTIVE = 2;
117 private static final int SW_SHOWMINNOACTIVE = 7;
118 private static final int SW_SHOWDEFAULT = 10;
119 private static final int SW_RESTORE = 9;
120
121 private static final int ICON_SMALL = 0;
122 private static final int ICON_BIG = 1;
123
124 private static final IntBuffer rect_buffer = BufferUtils.createIntBuffer(4);
125 private static final Rect rect = new Rect();
126 private static final Rect rect2 = new Rect();
127127 private static WindowsDisplay current_display;
128128
129129 private static boolean cursor_clipped;
130130 private WindowsDisplayPeerInfo peer_info;
131131 private Object current_cursor;
132132 private Canvas parent;
133 private static boolean hasParent = false;
133 private static boolean hasParent;
134134
135135 private WindowsKeyboard keyboard;
136136 private WindowsMouse mouse;
155155 private long large_icon;
156156
157157 private int captureMouse = -1;
158 private boolean trackingMouse = false;
159 private boolean mouseInside = false;
158 private boolean trackingMouse;
159 private boolean mouseInside;
160160
161161 WindowsDisplay() {
162162 current_display = this;
377377 String driver = getAdapter();
378378 if (driver != null) {
379379 String[] drivers = driver.split(",");
380 if(drivers.length>0) {
380 if(drivers.length>0) {
381381 WindowsFileVersion version = nGetVersion(drivers[0] + ".dll");
382382 if (version != null)
383383 return version.toString();
663663
664664 int small_icon_size = 16;
665665 int large_icon_size = 32;
666 for (int i=0;i<icons.length;i++) {
667 int size = icons[i].limit() / 4;
668
669 if ((((int) Math.sqrt(size)) == small_icon_size) && (!done_small)) {
666 for ( ByteBuffer icon : icons ) {
667 int size = icon.limit() / 4;
668
669 if ( (((int)Math.sqrt(size)) == small_icon_size) && (!done_small) ) {
670670 freeSmallIcon();
671 small_icon = createIcon(small_icon_size, small_icon_size, icons[i].asIntBuffer());
671 small_icon = createIcon(small_icon_size, small_icon_size, icon.asIntBuffer());
672672 sendMessage(hwnd, WM_SETICON, ICON_SMALL, small_icon);
673673 used++;
674674 done_small = true;
675675 }
676 if ((((int) Math.sqrt(size)) == large_icon_size) && (!done_large)) {
676 if ( (((int)Math.sqrt(size)) == large_icon_size) && (!done_large) ) {
677677 freeLargeIcon();
678 large_icon = createIcon(large_icon_size, large_icon_size, icons[i].asIntBuffer());
678 large_icon = createIcon(large_icon_size, large_icon_size, icon.asIntBuffer());
679679 sendMessage(hwnd, WM_SETICON, ICON_BIG, large_icon);
680680 used++;
681681 done_large = true;
691691 private void handleMouseButton(int button, int state, long millis) {
692692 if (mouse != null) {
693693 mouse.handleMouseButton((byte)button, (byte)state, millis);
694
694
695695 // need to capture?
696696 if (captureMouse == -1 && button != -1 && state == 1) {
697697 captureMouse = button;
698698 nSetCapture(hwnd);
699699 }
700
700
701701 // done with capture?
702702 if(captureMouse != -1 && button == captureMouse && state == 0) {
703703 captureMouse = -1;
704704 nReleaseCapture();
705705 }
706706 }
707
707
708708 if (parent != null && !isFocused) {
709709 setFocus(getHwnd());
710710 }
719719 mouse.handleMouseMoved(x, y, millis, shouldGrab());
720720 }
721721 }
722
722
723723 private static native long nSetCapture(long hwnd);
724724 private static native boolean nReleaseCapture();
725
725
726726 private void handleMouseScrolled(int amount, long millis) {
727727 if (mouse != null)
728728 mouse.handleMouseScrolled(amount, millis);
746746 int scan_code = (int)((lParam >>> 16) & 0xFF);
747747 if (keyboard != null) {
748748 keyboard.handleKey((int)wParam, scan_code, extended != 0, state, millis, repeat);
749
750 if(captureMouse != -1 && keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) {
751 nReleaseCapture();
752 captureMouse = -1;
753 }
754749 }
755750 }
756751
868863 // Set key state to pressed
869864 long fake_lparam = lParam & ~(1 << 31);
870865 // Set key previous state to released
871 fake_lparam = fake_lparam & ~(1 << 30);
866 fake_lparam &= ~(1 << 30);
872867 handleKeyButton(wParam, fake_lparam, millis);
873868 }
874869 /* Fall through */
922917 public int getHeight() {
923918 return Display.getDisplayMode().getHeight();
924919 }
925
920
926921 private int firstMouseButtonDown() {
927922 for(int i=0; i<Mouse.getButtonCount(); i++) {
928923 if(Mouse.isButtonDown(i)) {
4343 import org.lwjgl.input.Keyboard;
4444
4545 final class WindowsKeyboard {
46 private final static int MAPVK_VK_TO_VSC = 0;
46 private static final int MAPVK_VK_TO_VSC = 0;
4747
48 private final static int BUFFER_SIZE = 50;
48 private static final int BUFFER_SIZE = 50;
4949
5050 private final long hwnd;
5151 private final ByteBuffer keyboard_state;
3737 import org.lwjgl.input.Keyboard;
3838
3939 final class WindowsKeycodes {
40 public final static int VK_LBUTTON = 0x01;
41 public final static int VK_RBUTTON = 0x02;
42 public final static int VK_CANCEL = 0x03;
43 public final static int VK_MBUTTON = 0x04; /* NOT contiguous with L & RBUTTON */
44
45 public final static int VK_XBUTTON1 = 0x05; /* NOT contiguous with L & RBUTTON */
46 public final static int VK_XBUTTON2 = 0x06; /* NOT contiguous with L & RBUTTON */
40 public static final int VK_LBUTTON = 0x01;
41 public static final int VK_RBUTTON = 0x02;
42 public static final int VK_CANCEL = 0x03;
43 public static final int VK_MBUTTON = 0x04; /* NOT contiguous with L & RBUTTON */
44
45 public static final int VK_XBUTTON1 = 0x05; /* NOT contiguous with L & RBUTTON */
46 public static final int VK_XBUTTON2 = 0x06; /* NOT contiguous with L & RBUTTON */
4747
4848 /*
4949 * 0x07 : unassigned
5050 */
5151
52 public final static int VK_BACK = 0x08;
53 public final static int VK_TAB = 0x09;
52 public static final int VK_BACK = 0x08;
53 public static final int VK_TAB = 0x09;
5454
5555 /*
5656 * 0x0A - 0x0B : reserved
5757 */
5858
59 public final static int VK_CLEAR = 0x0C;
60 public final static int VK_RETURN = 0x0D;
61
62 public final static int VK_SHIFT = 0x10;
63 public final static int VK_CONTROL = 0x11;
64 public final static int VK_MENU = 0x12;
65 public final static int VK_PAUSE = 0x13;
66 public final static int VK_CAPITAL = 0x14;
67
68 public final static int VK_KANA = 0x15;
69 public final static int VK_HANGEUL = 0x15; /* old name - should be here for compatibility */
70 public final static int VK_HANGUL = 0x15;
71 public final static int VK_JUNJA = 0x17;
72 public final static int VK_FINAL = 0x18;
73 public final static int VK_HANJA = 0x19;
74 public final static int VK_KANJI = 0x19;
75
76 public final static int VK_ESCAPE = 0x1B;
77
78 public final static int VK_CONVERT = 0x1C;
79 public final static int VK_NONCONVERT = 0x1D;
80 public final static int VK_ACCEPT = 0x1E;
81 public final static int VK_MODECHANGE = 0x1F;
82
83 public final static int VK_SPACE = 0x20;
84 public final static int VK_PRIOR = 0x21;
85 public final static int VK_NEXT = 0x22;
86 public final static int VK_END = 0x23;
87 public final static int VK_HOME = 0x24;
88 public final static int VK_LEFT = 0x25;
89 public final static int VK_UP = 0x26;
90 public final static int VK_RIGHT = 0x27;
91 public final static int VK_DOWN = 0x28;
92 public final static int VK_SELECT = 0x29;
93 public final static int VK_PRINT = 0x2A;
94 public final static int VK_EXECUTE = 0x2B;
95 public final static int VK_SNAPSHOT = 0x2C;
96 public final static int VK_INSERT = 0x2D;
97 public final static int VK_DELETE = 0x2E;
98 public final static int VK_HELP = 0x2F;
59 public static final int VK_CLEAR = 0x0C;
60 public static final int VK_RETURN = 0x0D;
61
62 public static final int VK_SHIFT = 0x10;
63 public static final int VK_CONTROL = 0x11;
64 public static final int VK_MENU = 0x12;
65 public static final int VK_PAUSE = 0x13;
66 public static final int VK_CAPITAL = 0x14;
67
68 public static final int VK_KANA = 0x15;
69 public static final int VK_HANGEUL = 0x15; /* old name - should be here for compatibility */
70 public static final int VK_HANGUL = 0x15;
71 public static final int VK_JUNJA = 0x17;
72 public static final int VK_FINAL = 0x18;
73 public static final int VK_HANJA = 0x19;
74 public static final int VK_KANJI = 0x19;
75
76 public static final int VK_ESCAPE = 0x1B;
77
78 public static final int VK_CONVERT = 0x1C;
79 public static final int VK_NONCONVERT = 0x1D;
80 public static final int VK_ACCEPT = 0x1E;
81 public static final int VK_MODECHANGE = 0x1F;
82
83 public static final int VK_SPACE = 0x20;
84 public static final int VK_PRIOR = 0x21;
85 public static final int VK_NEXT = 0x22;
86 public static final int VK_END = 0x23;
87 public static final int VK_HOME = 0x24;
88 public static final int VK_LEFT = 0x25;
89 public static final int VK_UP = 0x26;
90 public static final int VK_RIGHT = 0x27;
91 public static final int VK_DOWN = 0x28;
92 public static final int VK_SELECT = 0x29;
93 public static final int VK_PRINT = 0x2A;
94 public static final int VK_EXECUTE = 0x2B;
95 public static final int VK_SNAPSHOT = 0x2C;
96 public static final int VK_INSERT = 0x2D;
97 public static final int VK_DELETE = 0x2E;
98 public static final int VK_HELP = 0x2F;
9999 /*
100100 * VK_0 - VK_9 are the same as ASCII '0' - '9' (0x30 - 0x39)
101101 * 0x40 : unassigned
102102 * VK_A - VK_Z are the same as ASCII 'A' - 'Z' (0x41 - 0x5A)
103103 */
104 public final static int VK_0 = 0x30;
105 public final static int VK_1 = 0x31;
106 public final static int VK_2 = 0x32;
107 public final static int VK_3 = 0x33;
108 public final static int VK_4 = 0x34;
109 public final static int VK_5 = 0x35;
110 public final static int VK_6 = 0x36;
111 public final static int VK_7 = 0x37;
112 public final static int VK_8 = 0x38;
113 public final static int VK_9 = 0x39;
114
115 public final static int VK_A = 0x41;
116 public final static int VK_B = 0x42;
117 public final static int VK_C = 0x43;
118 public final static int VK_D = 0x44;
119 public final static int VK_E = 0x45;
120 public final static int VK_F = 0x46;
121 public final static int VK_G = 0x47;
122 public final static int VK_H = 0x48;
123 public final static int VK_I = 0x49;
124 public final static int VK_J = 0x4A;
125 public final static int VK_K = 0x4B;
126 public final static int VK_L = 0x4C;
127 public final static int VK_M = 0x4D;
128 public final static int VK_N = 0x4E;
129 public final static int VK_O = 0x4F;
130 public final static int VK_P = 0x50;
131 public final static int VK_Q = 0x51;
132 public final static int VK_R = 0x52;
133 public final static int VK_S = 0x53;
134 public final static int VK_T = 0x54;
135 public final static int VK_U = 0x55;
136 public final static int VK_V = 0x56;
137 public final static int VK_W = 0x57;
138 public final static int VK_X = 0x58;
139 public final static int VK_Y = 0x59;
140 public final static int VK_Z = 0x5A;
141
142 public final static int VK_LWIN = 0x5B;
143 public final static int VK_RWIN = 0x5C;
144 public final static int VK_APPS = 0x5D;
104 public static final int VK_0 = 0x30;
105 public static final int VK_1 = 0x31;
106 public static final int VK_2 = 0x32;
107 public static final int VK_3 = 0x33;
108 public static final int VK_4 = 0x34;
109 public static final int VK_5 = 0x35;
110 public static final int VK_6 = 0x36;
111 public static final int VK_7 = 0x37;
112 public static final int VK_8 = 0x38;
113 public static final int VK_9 = 0x39;
114
115 public static final int VK_A = 0x41;
116 public static final int VK_B = 0x42;
117 public static final int VK_C = 0x43;
118 public static final int VK_D = 0x44;
119 public static final int VK_E = 0x45;
120 public static final int VK_F = 0x46;
121 public static final int VK_G = 0x47;
122 public static final int VK_H = 0x48;
123 public static final int VK_I = 0x49;
124 public static final int VK_J = 0x4A;
125 public static final int VK_K = 0x4B;
126 public static final int VK_L = 0x4C;
127 public static final int VK_M = 0x4D;
128 public static final int VK_N = 0x4E;
129 public static final int VK_O = 0x4F;
130 public static final int VK_P = 0x50;
131 public static final int VK_Q = 0x51;
132 public static final int VK_R = 0x52;
133 public static final int VK_S = 0x53;
134 public static final int VK_T = 0x54;
135 public static final int VK_U = 0x55;
136 public static final int VK_V = 0x56;
137 public static final int VK_W = 0x57;
138 public static final int VK_X = 0x58;
139 public static final int VK_Y = 0x59;
140 public static final int VK_Z = 0x5A;
141
142 public static final int VK_LWIN = 0x5B;
143 public static final int VK_RWIN = 0x5C;
144 public static final int VK_APPS = 0x5D;
145145 /*
146146 * 0x5E : reserved;
147147 */
148148
149 public final static int VK_SLEEP = 0x5F;
150
151 public final static int VK_NUMPAD0 = 0x60;
152 public final static int VK_NUMPAD1 = 0x61;
153 public final static int VK_NUMPAD2 = 0x62;
154 public final static int VK_NUMPAD3 = 0x63;
155 public final static int VK_NUMPAD4 = 0x64;
156 public final static int VK_NUMPAD5 = 0x65;
157 public final static int VK_NUMPAD6 = 0x66;
158 public final static int VK_NUMPAD7 = 0x67;
159 public final static int VK_NUMPAD8 = 0x68;
160 public final static int VK_NUMPAD9 = 0x69;
161 public final static int VK_MULTIPLY = 0x6A;
162 public final static int VK_ADD = 0x6B;
163 public final static int VK_SEPARATOR = 0x6C;
164 public final static int VK_SUBTRACT = 0x6D;
165 public final static int VK_DECIMAL = 0x6E;
166 public final static int VK_DIVIDE = 0x6F;
167 public final static int VK_F1 = 0x70;
168 public final static int VK_F2 = 0x71;
169 public final static int VK_F3 = 0x72;
170 public final static int VK_F4 = 0x73;
171 public final static int VK_F5 = 0x74;
172 public final static int VK_F6 = 0x75;
173 public final static int VK_F7 = 0x76;
174 public final static int VK_F8 = 0x77;
175 public final static int VK_F9 = 0x78;
176 public final static int VK_F10 = 0x79;
177 public final static int VK_F11 = 0x7A;
178 public final static int VK_F12 = 0x7B;
179 public final static int VK_F13 = 0x7C;
180 public final static int VK_F14 = 0x7D;
181 public final static int VK_F15 = 0x7E;
182 public final static int VK_F16 = 0x7F;
183 public final static int VK_F17 = 0x80;
184 public final static int VK_F18 = 0x81;
185 public final static int VK_F19 = 0x82;
186 public final static int VK_F20 = 0x83;
187 public final static int VK_F21 = 0x84;
188 public final static int VK_F22 = 0x85;
189 public final static int VK_F23 = 0x86;
190 public final static int VK_F24 = 0x87;
149 public static final int VK_SLEEP = 0x5F;
150
151 public static final int VK_NUMPAD0 = 0x60;
152 public static final int VK_NUMPAD1 = 0x61;
153 public static final int VK_NUMPAD2 = 0x62;
154 public static final int VK_NUMPAD3 = 0x63;
155 public static final int VK_NUMPAD4 = 0x64;
156 public static final int VK_NUMPAD5 = 0x65;
157 public static final int VK_NUMPAD6 = 0x66;
158 public static final int VK_NUMPAD7 = 0x67;
159 public static final int VK_NUMPAD8 = 0x68;
160 public static final int VK_NUMPAD9 = 0x69;
161 public static final int VK_MULTIPLY = 0x6A;
162 public static final int VK_ADD = 0x6B;
163 public static final int VK_SEPARATOR = 0x6C;
164 public static final int VK_SUBTRACT = 0x6D;
165 public static final int VK_DECIMAL = 0x6E;
166 public static final int VK_DIVIDE = 0x6F;
167 public static final int VK_F1 = 0x70;
168 public static final int VK_F2 = 0x71;
169 public static final int VK_F3 = 0x72;
170 public static final int VK_F4 = 0x73;
171 public static final int VK_F5 = 0x74;
172 public static final int VK_F6 = 0x75;
173 public static final int VK_F7 = 0x76;
174 public static final int VK_F8 = 0x77;
175 public static final int VK_F9 = 0x78;
176 public static final int VK_F10 = 0x79;
177 public static final int VK_F11 = 0x7A;
178 public static final int VK_F12 = 0x7B;
179 public static final int VK_F13 = 0x7C;
180 public static final int VK_F14 = 0x7D;
181 public static final int VK_F15 = 0x7E;
182 public static final int VK_F16 = 0x7F;
183 public static final int VK_F17 = 0x80;
184 public static final int VK_F18 = 0x81;
185 public static final int VK_F19 = 0x82;
186 public static final int VK_F20 = 0x83;
187 public static final int VK_F21 = 0x84;
188 public static final int VK_F22 = 0x85;
189 public static final int VK_F23 = 0x86;
190 public static final int VK_F24 = 0x87;
191191
192192 /*
193193 * 0x88 - 0x8F : unassigned;
194194 */
195195
196 public final static int VK_NUMLOCK = 0x90;
197 public final static int VK_SCROLL = 0x91;
196 public static final int VK_NUMLOCK = 0x90;
197 public static final int VK_SCROLL = 0x91;
198198
199199 /*
200200 * NEC PC-9800 kbd definitions
201201 */
202 public final static int VK_OEM_NEC_EQUAL = 0x92; // '=' key on numpad
202 public static final int VK_OEM_NEC_EQUAL = 0x92; // '=' key on numpad
203203 /*
204204 * Fujitsu/OASYS kbd definitions
205205 */
206 public final static int VK_OEM_FJ_JISHO = 0x92; // 'Dictionary' key
207 public final static int VK_OEM_FJ_MASSHOU = 0x93; // 'Unregister word' key
208 public final static int VK_OEM_FJ_TOUROKU = 0x94; // 'Register word' key
209 public final static int VK_OEM_FJ_LOYA = 0x95; // 'Left OYAYUBI' key
210 public final static int VK_OEM_FJ_ROYA = 0x96; // 'Right OYAYUBI' key
206 public static final int VK_OEM_FJ_JISHO = 0x92; // 'Dictionary' key
207 public static final int VK_OEM_FJ_MASSHOU = 0x93; // 'Unregister word' key
208 public static final int VK_OEM_FJ_TOUROKU = 0x94; // 'Register word' key
209 public static final int VK_OEM_FJ_LOYA = 0x95; // 'Left OYAYUBI' key
210 public static final int VK_OEM_FJ_ROYA = 0x96; // 'Right OYAYUBI' key
211211
212212 /*
213213 * 0x97 - 0x9F : unassigned
218218 * Used only as parameters to GetAsyncKeyState() and GetKeyState().
219219 * No other API or message will distinguish left and right keys in this way.
220220 */
221 public final static int VK_LSHIFT = 0xA0;
222 public final static int VK_RSHIFT = 0xA1;
223 public final static int VK_LCONTROL = 0xA2;
224 public final static int VK_RCONTROL = 0xA3;
225 public final static int VK_LMENU = 0xA4;
226 public final static int VK_RMENU = 0xA5;
227
228 public final static int VK_BROWSER_BACK = 0xA6;
229 public final static int VK_BROWSER_FORWARD = 0xA7;
230 public final static int VK_BROWSER_REFRESH = 0xA8;
231 public final static int VK_BROWSER_STOP = 0xA9;
232 public final static int VK_BROWSER_SEARCH = 0xAA;
233 public final static int VK_BROWSER_FAVORITES = 0xAB;
234 public final static int VK_BROWSER_HOME = 0xAC;
235
236 public final static int VK_VOLUME_MUTE = 0xAD;
237 public final static int VK_VOLUME_DOWN = 0xAE;
238 public final static int VK_VOLUME_UP = 0xAF;
239 public final static int VK_MEDIA_NEXT_TRACK = 0xB0;
240 public final static int VK_MEDIA_PREV_TRACK = 0xB1;
241 public final static int VK_MEDIA_STOP = 0xB2;
242 public final static int VK_MEDIA_PLAY_PAUSE = 0xB3;
243 public final static int VK_LAUNCH_MAIL = 0xB4;
244 public final static int VK_LAUNCH_MEDIA_SELECT = 0xB5;
245 public final static int VK_LAUNCH_APP1 = 0xB6;
246 public final static int VK_LAUNCH_APP2 = 0xB7;
221 public static final int VK_LSHIFT = 0xA0;
222 public static final int VK_RSHIFT = 0xA1;
223 public static final int VK_LCONTROL = 0xA2;
224 public static final int VK_RCONTROL = 0xA3;
225 public static final int VK_LMENU = 0xA4;
226 public static final int VK_RMENU = 0xA5;
227
228 public static final int VK_BROWSER_BACK = 0xA6;
229 public static final int VK_BROWSER_FORWARD = 0xA7;
230 public static final int VK_BROWSER_REFRESH = 0xA8;
231 public static final int VK_BROWSER_STOP = 0xA9;
232 public static final int VK_BROWSER_SEARCH = 0xAA;
233 public static final int VK_BROWSER_FAVORITES = 0xAB;
234 public static final int VK_BROWSER_HOME = 0xAC;
235
236 public static final int VK_VOLUME_MUTE = 0xAD;
237 public static final int VK_VOLUME_DOWN = 0xAE;
238 public static final int VK_VOLUME_UP = 0xAF;
239 public static final int VK_MEDIA_NEXT_TRACK = 0xB0;
240 public static final int VK_MEDIA_PREV_TRACK = 0xB1;
241 public static final int VK_MEDIA_STOP = 0xB2;
242 public static final int VK_MEDIA_PLAY_PAUSE = 0xB3;
243 public static final int VK_LAUNCH_MAIL = 0xB4;
244 public static final int VK_LAUNCH_MEDIA_SELECT = 0xB5;
245 public static final int VK_LAUNCH_APP1 = 0xB6;
246 public static final int VK_LAUNCH_APP2 = 0xB7;
247247
248248 /*
249249 * 0xB8 - 0xB9 : reserved
250250 */
251251
252 public final static int VK_OEM_1 = 0xBA; // ';:' for US
253 public final static int VK_OEM_PLUS = 0xBB; // '+' any country
254 public final static int VK_OEM_COMMA = 0xBC; // ',' any country
255 public final static int VK_OEM_MINUS = 0xBD; // '-' any country
256 public final static int VK_OEM_PERIOD = 0xBE; // '.' any country
257 public final static int VK_OEM_2 = 0xBF; // '/?' for US
258 public final static int VK_OEM_3 = 0xC0; // '`~' for US
252 public static final int VK_OEM_1 = 0xBA; // ';:' for US
253 public static final int VK_OEM_PLUS = 0xBB; // '+' any country
254 public static final int VK_OEM_COMMA = 0xBC; // ',' any country
255 public static final int VK_OEM_MINUS = 0xBD; // '-' any country
256 public static final int VK_OEM_PERIOD = 0xBE; // '.' any country
257 public static final int VK_OEM_2 = 0xBF; // '/?' for US
258 public static final int VK_OEM_3 = 0xC0; // '`~' for US
259259
260260 /*
261261 * 0xC1 - 0xD7 : reserved
265265 * 0xD8 - 0xDA : unassigned
266266 */
267267
268 public final static int VK_OEM_4 = 0xDB; // '[{' for US
269 public final static int VK_OEM_5 = 0xDC; // '\|' for US
270 public final static int VK_OEM_6 = 0xDD; // ']}' for US
271 public final static int VK_OEM_7 = 0xDE; // ''"' for US
272 public final static int VK_OEM_8 = 0xDF;
268 public static final int VK_OEM_4 = 0xDB; // '[{' for US
269 public static final int VK_OEM_5 = 0xDC; // '\|' for US
270 public static final int VK_OEM_6 = 0xDD; // ']}' for US
271 public static final int VK_OEM_7 = 0xDE; // ''"' for US
272 public static final int VK_OEM_8 = 0xDF;
273273
274274 /*
275275 * 0xE0 : reserved
278278 /*
279279 * Various extended or enhanced keyboards
280280 */
281 public final static int VK_OEM_AX = 0xE1; // 'AX' key on Japanese AX kbd
282 public final static int VK_OEM_102 = 0xE2; // "<>" or "\|" on RT 102-key kbd.
283 public final static int VK_ICO_HELP = 0xE3; // Help key on ICO
284 public final static int VK_ICO_00 = 0xE4; // 00 key on ICO
285
286 public final static int VK_PROCESSKEY = 0xE5;
287
288 public final static int VK_ICO_CLEAR = 0xE6;
289
290
291 public final static int VK_PACKET = 0xE7;
281 public static final int VK_OEM_AX = 0xE1; // 'AX' key on Japanese AX kbd
282 public static final int VK_OEM_102 = 0xE2; // "<>" or "\|" on RT 102-key kbd.
283 public static final int VK_ICO_HELP = 0xE3; // Help key on ICO
284 public static final int VK_ICO_00 = 0xE4; // 00 key on ICO
285
286 public static final int VK_PROCESSKEY = 0xE5;
287
288 public static final int VK_ICO_CLEAR = 0xE6;
289
290
291 public static final int VK_PACKET = 0xE7;
292292
293293 /*
294294 * 0xE8 : unassigned
295295 */
296
296
297297 /*
298298 * Nokia/Ericsson definitions
299299 */
300 public final static int VK_OEM_RESET = 0xE9;
301 public final static int VK_OEM_JUMP = 0xEA;
302 public final static int VK_OEM_PA1 = 0xEB;
303 public final static int VK_OEM_PA2 = 0xEC;
304 public final static int VK_OEM_PA3 = 0xED;
305 public final static int VK_OEM_WSCTRL = 0xEE;
306 public final static int VK_OEM_CUSEL = 0xEF;
307 public final static int VK_OEM_ATTN = 0xF0;
308 public final static int VK_OEM_FINISH = 0xF1;
309 public final static int VK_OEM_COPY = 0xF2;
310 public final static int VK_OEM_AUTO = 0xF3;
311 public final static int VK_OEM_ENLW = 0xF4;
312 public final static int VK_OEM_BACKTAB = 0xF5;
313
314 public final static int VK_ATTN = 0xF6;
315 public final static int VK_CRSEL = 0xF7;
316 public final static int VK_EXSEL = 0xF8;
317 public final static int VK_EREOF = 0xF9;
318 public final static int VK_PLAY = 0xFA;
319 public final static int VK_ZOOM = 0xFB;
320 public final static int VK_NONAME = 0xFC;
321 public final static int VK_PA1 = 0xFD;
322 public final static int VK_OEM_CLEAR = 0xFE;
300 public static final int VK_OEM_RESET = 0xE9;
301 public static final int VK_OEM_JUMP = 0xEA;
302 public static final int VK_OEM_PA1 = 0xEB;
303 public static final int VK_OEM_PA2 = 0xEC;
304 public static final int VK_OEM_PA3 = 0xED;
305 public static final int VK_OEM_WSCTRL = 0xEE;
306 public static final int VK_OEM_CUSEL = 0xEF;
307 public static final int VK_OEM_ATTN = 0xF0;
308 public static final int VK_OEM_FINISH = 0xF1;
309 public static final int VK_OEM_COPY = 0xF2;
310 public static final int VK_OEM_AUTO = 0xF3;
311 public static final int VK_OEM_ENLW = 0xF4;
312 public static final int VK_OEM_BACKTAB = 0xF5;
313
314 public static final int VK_ATTN = 0xF6;
315 public static final int VK_CRSEL = 0xF7;
316 public static final int VK_EXSEL = 0xF8;
317 public static final int VK_EREOF = 0xF9;
318 public static final int VK_PLAY = 0xFA;
319 public static final int VK_ZOOM = 0xFB;
320 public static final int VK_NONAME = 0xFC;
321 public static final int VK_PA1 = 0xFD;
322 public static final int VK_OEM_CLEAR = 0xFE;
323323
324324 public static int mapVirtualKeyToLWJGLCode(int virt_key) {
325325 switch (virt_key) {
3939 import org.lwjgl.Sys;
4040
4141 final class WindowsRegistry {
42 final static int HKEY_CLASSES_ROOT = 1;
43 final static int HKEY_CURRENT_USER = 2;
44 final static int HKEY_LOCAL_MACHINE = 3;
45 final static int HKEY_USERS = 4;
42 static final int HKEY_CLASSES_ROOT = 1;
43 static final int HKEY_CURRENT_USER = 2;
44 static final int HKEY_LOCAL_MACHINE = 3;
45 static final int HKEY_USERS = 4;
4646
4747 static {
4848 Sys.initialize();
4949 }
50
50
5151 /**
5252 * Query the registry value specified by the root key, subkey, value tuple
5353 */
6363 }
6464 return nQueryRegistrationKey(root_key, subkey, value);
6565 }
66
66
6767 private static native String nQueryRegistrationKey(int root_key, String subkey, String value) throws LWJGLException;
6868 }
4141 /**
4242 * Utility for working with the xrandr commmand-line utility. Assumes
4343 * xrandr v1.2 or higher.
44 *
44 *
4545 * @author ryanm
4646 */
4747 public class XRandR
4848 {
4949 private static Screen[] current;
5050
51 private static Map /* <String, Screen[]> */screens;
51 private static Map<String, Screen[]> screens;
5252
5353 private static void populate()
5454 {
5555 if( screens == null )
5656 {
57 screens = new HashMap/* <String, Screen[]> */();
57 screens = new HashMap<String, Screen[]>();
5858
5959 // ProcessBuilder pb = new ProcessBuilder( "xrandr", "-q" );
6060 // pb.redirectErrorStream();
6363 // Process p= pb.start();
6464 Process p = Runtime.getRuntime().exec( new String[] { "xrandr", "-q" } );
6565
66 List/* <Screen> */currentList = new ArrayList/* <Screen> */();
67 List/* <Screen> */possibles = new ArrayList/* <Screen> */();
66 List<Screen> currentList = new ArrayList<Screen>();
67 List<Screen> possibles = new ArrayList<Screen>();
6868 String name = null;
6969
7070 BufferedReader br = new BufferedReader( new InputStreamReader( p.getInputStream() ) );
7474 line = line.trim();
7575 String[] sa = line.split( "\\s+" );
7676
77 if( sa[ 1 ].equals( "connected" ) )
77 if( "connected".equals(sa[1]) )
7878 {
7979 // found a new screen block
8080 if( name != null )
9696
9797 screens.put( name, possibles.toArray( new Screen[ possibles.size() ] ) );
9898
99 current = (Screen[]) currentList.toArray(new Screen[currentList.size()]);
99 current = currentList.toArray(new Screen[currentList.size()]);
100100 }
101101 catch( Throwable e )
102102 {
115115 {
116116 populate();
117117
118 return (Screen[]) current.clone();
118 return current.clone();
119119 }
120120
121121 /**
124124 * @throws IllegalArgumentException
125125 * if no screens are specified
126126 */
127 public static void setConfiguration( Screen[]/* ... */screens )
127 public static void setConfiguration(Screen... screens)
128128 {
129129 if( screens.length == 0 )
130 {
131130 throw new IllegalArgumentException( "Must specify at least one screen" );
132 }
133
134 List/* <String> */cmd = new ArrayList/* <String> */();
131
132 List<String> cmd = new ArrayList<String>();
135133 cmd.add( "xrandr" );
136134
137135 // switch off those in the current set not in the new set
138 for( int i = 0; i < current.length; i++ )
139 {
136 for ( Screen screen : current ) {
140137 boolean found = false;
141 for( int j = 0; j < screens.length; j++ )
142 {
143 if( screens[ j ].name.equals( current[ i ].name ) )
144 {
138 for ( Screen screen1 : screens ) {
139 if ( screen1.name.equals(screen.name) ) {
145140 found = true;
146141 break;
147142 }
148143 }
149144
150 if( !found )
151 {
152 cmd.add( "--output" );
153 cmd.add( current[ i ].name );
154 cmd.add( "--off" );
145 if ( !found ) {
146 cmd.add("--output");
147 cmd.add(screen.name);
148 cmd.add("--off");
155149 }
156150 }
157151
158152 // set up new set
159 for( int i = 0; i < screens.length; i++ )
160 {
161 screens[ i ].getArgs( cmd );
162 }
153 for ( Screen screen : screens )
154 screen.getArgs(cmd);
163155
164156 try
165157 {
167159 // pb.redirectErrorStream();
168160 // Process p = pb.start();
169161 Process p =
170 Runtime.getRuntime().exec( ( String[] ) cmd.toArray( new String[ cmd.size() ] ) );
162 Runtime.getRuntime().exec( cmd.toArray( new String[ cmd.size() ] ) );
171163 // no output is expected, but check anyway
172164 BufferedReader br = new BufferedReader( new InputStreamReader( p.getInputStream() ) );
173165 String line;
190182 public static String[] getScreenNames()
191183 {
192184 populate();
193 return ( String[] ) screens.keySet().toArray( new String[ screens.size() ] );
185 return screens.keySet().toArray( new String[ screens.size() ] );
194186 }
195187
196188 /**
202194 {
203195 populate();
204196 // clone the array to prevent held copies being altered
205 return (Screen[]) ((Screen[]) screens.get(name)).clone();
197 return screens.get(name).clone();
206198 }
207199
208200 private static final Pattern SCREEN_PATTERN1 =
213205 /**
214206 * Parses a screen configuration and adds it to the list if it's
215207 * valid.
216 *
208 *
217209 * @param list
218210 * the list to add the Screen to if it's valid
219211 * @param name
222214 * config string, format either widthxheight or
223215 * widthxheight+xPos+yPos
224216 */
225 private static void parseScreen( List /* <Screen> */list, String name, String what )
217 private static void parseScreen( List<Screen> list, String name, String what )
226218 {
227219 Matcher m = SCREEN_PATTERN1.matcher( what );
228220 if( !m.matches() )
253245 /**
254246 * Encapsulates the configuration of a monitor. Resolution is
255247 * fixed, position is mutable
256 *
248 *
257249 * @author ryanm
258250 */
259251 public static class Screen implements Cloneable
276268 /**
277269 * Position on the x-axis, in pixels
278270 */
279 public int xPos = 0;
271 public int xPos;
280272
281273 /**
282274 * Position on the y-axis, in pixels
283275 */
284 public int yPos = 0;
276 public int yPos;
285277
286278 private Screen( String name, int width, int height, int xPos, int yPos )
287279 {
292284 this.yPos = yPos;
293285 }
294286
295 private void getArgs( List/* <String> */argList )
287 private void getArgs( List<String> argList )
296288 {
297289 argList.add( "--output" );
298290 argList.add( name );
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 */
3939 * Test class for Display & DisplayMode
4040 *
4141 * @author Brian Matzon <brian@matzon.dk>
42 * @version $Revision: 2983 $
43 * $Id: DisplayTest.java 2983 2008-04-07 18:36:09Z matzon $
42 * @version $Revision: 3418 $
43 * $Id: DisplayTest.java 3418 2010-09-28 21:11:35Z spasi $
4444 */
4545 public class DisplayTest {
46
46
4747 /**
4848 * Creates a new DisplayTest
4949 */
5050 public DisplayTest() {
5151 }
52
52
5353 /**
5454 * Runs the tests
5555 */
5757 currentTest();
5858 queryModesTest();
5959 setDisplayModeTest();
60 setDisplayConfigurationTest();
61 }
62
60 setDisplayConfigurationTest();
61 }
62
6363 /**
6464 * Prints some info about the current mode
6565 */
6666 private void currentTest() {
6767 System.out.println("==== Test Current ====");
68
68
6969 System.out.println("Info about current:");
7070 System.out.println("Graphics card: " + Display.getAdapter() + ", version: " + Display.getVersion());
71 System.out.println("Resolution: " +
72 Display.getDisplayMode().getWidth() + "x" +
73 Display.getDisplayMode().getHeight() + "x" +
74 Display.getDisplayMode().getBitsPerPixel() + "@" +
71 System.out.println("Resolution: " +
72 Display.getDisplayMode().getWidth() + "x" +
73 Display.getDisplayMode().getHeight() + "x" +
74 Display.getDisplayMode().getBitsPerPixel() + "@" +
7575 Display.getDisplayMode().getFrequency() + "Hz");
7676 System.out.println("---- Test Current ----");
7777 }
78
78
7979 /**
8080 * Tests querying for modes
8181 */
8282 private void queryModesTest() throws LWJGLException {
8383 DisplayMode[] modes = null;
84
84
8585 System.out.println("==== Test query ====");
8686 System.out.println("Retrieving available displaymodes");
8787 modes = Display.getAvailableDisplayModes();
9191 System.out.println("FATAL: unable to find any modes!");
9292 System.exit(-1);
9393 }
94
94
9595 // write some info
9696 System.out.println("Found " + modes.length + " modes");
9797 System.out.println("The first 5 are:");
103103 }
104104 System.out.println("---- Test query ----");
105105 }
106
107
106
107
108108 /**
109109 * Tests setting display modes
110110 */
111111 private void setDisplayModeTest() throws LWJGLException {
112112 DisplayMode mode = null;
113113 DisplayMode[] modes = null;
114
114
115115 System.out.println("==== Test setDisplayMode ====");
116116 System.out.println("Retrieving available displaymodes");
117117 modes = Display.getAvailableDisplayModes();
118
118
119119 // no modes check
120120 if (modes == null) {
121121 System.out.println("FATAL: unable to find any modes!");
122122 System.exit(-1);
123123 }
124
124
125125 // find a mode
126126 System.out.print("Looking for 640x480...");
127 for(int i=0; i<modes.length;i++) {
128 if (modes[i].getWidth() == 640 &&
129 modes[i].getHeight() == 480) {
130 mode = modes[i];
131 System.out.println("found!");
132 break;
133 }
134 }
135
127 for ( DisplayMode mode1 : modes ) {
128 if ( mode1.getWidth() == 640 &&
129 mode1.getHeight() == 480 ) {
130 mode = mode1;
131 System.out.println("found!");
132 break;
133 }
134 }
135
136136 // no mode check
137137 if (mode == null) {
138138 System.out.println("error\nFATAL: Unable to find basic mode.");
139139 System.exit(-1);
140140 }
141
141
142142 // change to mode, and wait a bit
143143 System.out.print("Changing to mode...");
144144 try {
150150 System.exit(-1);
151151 }
152152 System.out.println("done");
153
154 System.out.println("Resolution: " +
155 Display.getDisplayMode().getWidth() + "x" +
156 Display.getDisplayMode().getHeight() + "x" +
157 Display.getDisplayMode().getBitsPerPixel() + "@" +
153
154 System.out.println("Resolution: " +
155 Display.getDisplayMode().getWidth() + "x" +
156 Display.getDisplayMode().getHeight() + "x" +
157 Display.getDisplayMode().getBitsPerPixel() + "@" +
158158 Display.getDisplayMode().getFrequency() + "Hz");
159
159
160160 pause(5000);
161161
162162 // reset
167167 e.printStackTrace();
168168 }
169169 System.out.println("done");
170
171 System.out.println("---- Test setDisplayMode ----");
172 }
173
170
171 System.out.println("---- Test setDisplayMode ----");
172 }
173
174174 /**
175175 * Tests the DisplayConfiguration
176176 */
177177 private void setDisplayConfigurationTest() {
178178 System.out.println("==== Test setDisplayConfigurationTest ====");
179
179
180180 System.out.println("Testing normal setting");
181181 changeConfig(1.0f, 0f, 1f);
182
182
183183 System.out.println("Testing gamma settings");
184184 changeConfig(5.0f, 0f, 1f);
185185 changeConfig(0.5f, 0f, 1f);
186
186
187187 System.out.println("Testing brightness settings");
188188 changeConfig(1.0f, -1.0f, 1f);
189189 changeConfig(1.0f, -0.5f, 1f);
190190 changeConfig(1.0f, 0.5f, 1f);
191191 changeConfig(1.0f, 1.0f, 1f);
192
192
193193 System.out.println("Testing contrast settings");
194194 changeConfig(1.0f, 0f, 0f);
195195 changeConfig(1.0f, 0f, 0.5f);
196196 changeConfig(1.0f, 0f, 10000.0f);
197
197
198198 System.out.print("resetting...");
199199 try {
200200 Display.setFullscreen(false);
202202 e.printStackTrace();
203203 }
204204 System.out.println("done");
205
205
206206 System.out.println("---- Test setDisplayConfigurationTest ----");
207207 }
208
208
209209 /**
210210 * Changes the Displat configuration
211 *
211 *
212212 * @param gamma gamma value to change to
213213 * @param brightness brightness value to change to
214214 * @param contrast contrast value to change to
225225
226226 /**
227227 * Pause current thread for a specified time
228 *
228 *
229229 * @param time milliseconds to sleep
230230 */
231231 private void pause(long time) {
237237 } catch (InterruptedException inte) {
238238 }
239239 }
240 }
241
240 }
241
242242 /**
243243 * Tests the Sys class, and serves as basic usage test
244 *
244 *
245245 * @param args ignored
246246 */
247247 public static void main(String[] args) throws LWJGLException {
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 */
3636 import org.lwjgl.opengl.DisplayMode;
3737 import org.lwjgl.opengl.GL11;
3838
39 import static org.lwjgl.opengl.GL11.*;
40
3941 /**
4042 * Small class for testing that the Window is creatable
4143 * If this class can't run, LWJGL wont work!
42 *
44 *
4345 * @author Brian Matzon <brian@matzon.dk>
4446 */
4547 public class WindowCreationTest {
4648
4749 /** Locatable modes */
4850 private DisplayMode[] located_modes;
49
51
5052 /** Fixed selectable modes */
5153 private DisplayMode[] fixed_modes = new DisplayMode[10];
52
54
5355
5456 /** Window position x */
55 private int window_x = 0;
57 private int window_x;
5658
5759 /** Window position y */
58 private int window_y = 0;
60 private int window_y;
5961
6062 /** Color being cleared to */
6163 private float color = 0f;
6466 private int direction = 1;
6567
6668 /** Whether we're running */
67 private boolean running = false;
69 private boolean running;
6870
6971 /** Whether we're in fullscreen mode */
70 private boolean fullscreen = false;
71
72 /**
73 * Initializes the test
72 private boolean fullscreen;
73
74 /**
75 * Initializes the test
7476 * @return true if initialization was successfull
7577 */
7678 public boolean initialize() {
7880 // get available modes, and print out
7981 located_modes = Display.getAvailableDisplayModes();
8082 System.out.println("Found " + located_modes.length + " display modes");
81
83
8284 // get 640x480, 800x600, 1024x768 modes
8385 findFixedModes();
8486
8587 // create default windowed display 640*480 @ 100, 100
8688 setDefaultDisplayMode();
87
89
8890 window_x = window_y = 100;
8991 Display.setLocation(window_x, window_y);
90
92
9193 Display.create();
9294 return true;
9395 } catch (LWJGLException le) {
9597 }
9698 return false;
9799 }
98
100
99101 /** Locate fixed modes */
100102 private void findFixedModes() {
101103 // get 640*480 modes
150152 }
151153
152154 /**
153 * Handles the input
155 * Handles the input
154156 */
155157 private void handleInput() {
156158 while (Keyboard.next()) {
164166 if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
165167 running = false;
166168 }
167
169
168170 // check for listing of modes
169171 if (Keyboard.getEventKey() == Keyboard.KEY_L) {
170172 for(int i=0;i<fixed_modes.length; i++) {
171173 System.out.println("[" + i + "]: " + fixed_modes[i]);
172174 }
173175 }
174
176
175177 // check for display mode
176178 // ================================
177179 if (Keyboard.getEventKey() == Keyboard.KEY_0) { setMode(0); }
180182 if (Keyboard.getEventKey() == Keyboard.KEY_3) { setMode(3); }
181183 if (Keyboard.getEventKey() == Keyboard.KEY_4) { setMode(4); }
182184 if (Keyboard.getEventKey() == Keyboard.KEY_5) { setMode(5); }
183 if (Keyboard.getEventKey() == Keyboard.KEY_6) { setMode(6); }
185 if (Keyboard.getEventKey() == Keyboard.KEY_6) { setMode(6); }
184186 if (Keyboard.getEventKey() == Keyboard.KEY_7) { setMode(7); }
185187 if (Keyboard.getEventKey() == Keyboard.KEY_8) { setMode(8); }
186188 // --------------------------------
231233 }
232234 }
233235 }
234
236
235237 private void setMode(int mode) {
236238 if(fixed_modes[mode] == null) {
237239 System.out.println("Unable to set mode. Not valid: " + mode);
238240 return;
239241 }
240
242
241243 try {
242244 Display.setDisplayMode(fixed_modes[mode]);
243245 } catch (LWJGLException le) {
250252 *
251253 */
252254 private void render() {
253 GL11.glClearColor(color, color, color, 1f);
254 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
255 glClearColor(color, color, color, 1f);
256 glClear(GL_COLOR_BUFFER_BIT);
255257
256258 color += direction * .05f;
257259
266268
267269 /**
268270 * Main entry point
269 *
271 *
270272 * @param args ignored params to app
271273 */
272274 public static void main(String[] args) throws LWJGLException {
273
275
274276 System.out.println("The following keys are available:\n" +
275 "ESCAPE:\t\tExit test\n" +
277 "ESCAPE:\t\tExit test\n" +
276278 "ARROW Keys:\tMove window when in non-fullscreen mode\n" +
277279 "L:\t\tList selectable display modes\n" +
278 "0-8:\t\tSelection of display modes\n" +
280 "0-8:\t\tSelection of display modes\n" +
279281 "F:\t\tToggle fullscreen\n" +
280282 "SHIFT-F:\tToggle fullscreen with Display.destroy()/create() cycle");
281
283
282284 WindowCreationTest wct = new WindowCreationTest();
283285 if (wct.initialize()) {
284286 wct.execute();
303305 }
304306 return false;
305307 }
306
307 /**
308 * Gets a specific display mode
308
309 /**
310 * Gets a specific display mode
309311 */
310312 private DisplayMode getDisplayMode(int width, int height, int bpp, int freq) {
311313 DisplayMode[] dm = null;
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 */
3535 import java.awt.Canvas;
3636
3737 public class AppletLoaderTest extends Applet {
38
39 Test test = null;
38
39 Test test;
4040
4141 public void destroy() {
4242 super.destroy();
5656
5757 public void init() {
5858 System.out.println("*** init ***");
59
59
6060 setLayout(new BorderLayout());
6161 try {
6262 test = (Test) Class.forName(getParameter("test")).newInstance();
55 import java.nio.FloatBuffer;
66 import org.lwjgl.BufferUtils;
77 import org.lwjgl.LWJGLException;
8 import org.lwjgl.opengl.ARBTransposeMatrix;
8 import org.lwjgl.LWJGLUtil;
9 import org.lwjgl.Sys;
910 import org.lwjgl.opengl.Display;
1011 import org.lwjgl.input.Keyboard;
1112 import org.lwjgl.input.Mouse;
12 import org.lwjgl.opengl.GL11;
1313 import org.lwjgl.opengl.GLContext;
1414
15 import static org.lwjgl.opengl.ARBTransposeMatrix.*;
16 import static org.lwjgl.opengl.GL11.*;
17
1518 public class GearsApplet extends Applet {
16
19
1720 /** The Canvas where the LWJGL Display is added */
1821 Canvas display_parent;
19
22
2023 /** Thread which runs the main game loop */
2124 Thread gameThread;
22
25
2326 /** is the game loop running */
24 boolean running = false;
25
27 boolean running;
28
2629 /** variables used to rotate the view */
2730 private float view_rotx = 20.0f;
2831 private float view_roty = 30.0f;
29 private float view_rotz = 0.0f;
30
32 private float view_rotz;
33
3134 private int gear1;
3235 private int gear2;
3336 private int gear3;
3437 private float angle;
35
36 boolean keyDown = false;
37
38
39 boolean keyDown;
40
3841 private int prevMouseX, prevMouseY;
39 private boolean mouseButtonDown = false;
40
41
42 private boolean mouseButtonDown;
43
44
4245 /**
43 * Once the Canvas is created its add notify method will call this method to
46 * Once the Canvas is created its add notify method will call this method to
4447 * start the LWJGL Display and game loop in another thread.
4548 */
4649 public void startLWJGL() {
6063 };
6164 gameThread.start();
6265 }
63
64
66
67
6568 /**
6669 * Tell game loop to stop running, after which the LWJGL Display will be destoryed.
6770 * The main thread will wait for the Display.destroy() to complete
7679 }
7780
7881 public void start() {
79
82
8083 }
8184
8285 public void stop() {
83
84 }
85
86
87 }
88
8689 /**
87 * Applet Destroy method will remove the canvas, before canvas is destroyed it will notify
90 * Applet Destroy method will remove the canvas, before canvas is destroyed it will notify
8891 * stopLWJGL() to stop main game loop and to destroy the Display
8992 */
9093 public void destroy() {
9295 super.destroy();
9396 System.out.println("Clear up");
9497 }
95
98
9699 /**
97100 * initialise applet by adding a canvas to it, this canvas will start the LWJGL Display and game loop
98 * in another thread. It will also stop the game loop and destroy the display on canvas removal when
101 * in another thread. It will also stop the game loop and destroy the display on canvas removal when
99102 * applet is destroyed.
100103 */
101104 public void init() {
102105 setLayout(new BorderLayout());
103106 try {
104107 display_parent = new Canvas() {
105 public final void addNotify() {
108 public void addNotify() {
106109 super.addNotify();
107110 startLWJGL();
108111 }
109 public final void removeNotify() {
112 public void removeNotify() {
110113 stopLWJGL();
111114 super.removeNotify();
112115 }
130133
131134 while(running) {
132135 angle += 2.0f;
133
136
134137 // draw the gears
135138 drawLoop();
136
139
137140 Display.update();
138
141
139142 if (startTime > System.currentTimeMillis()) {
140143 fps++;
141144 } else {
142145 long timeUsed = 5000 + (startTime - System.currentTimeMillis());
143146 startTime = System.currentTimeMillis() + 5000;
144 System.out.println(fps + " frames 2 in " + (float) (timeUsed / 1000f) + " seconds = "
147 System.out.println(fps + " frames 2 in " + timeUsed / 1000f + " seconds = "
145148 + (fps / (timeUsed / 1000f)));
146149 fps = 0;
147150 }
148
151
149152 if (Mouse.isButtonDown(0)) {
150153 if (!mouseButtonDown) {
151154 prevMouseX = Mouse.getX();
156159 else {
157160 mouseButtonDown = false;
158161 }
159
162
160163 if (mouseButtonDown) {
161164 int x = Mouse.getX();
162165 int y = Mouse.getY();
163
166
164167 float thetaY = 360.0f * ( (float)(x-prevMouseX)/(float)display_parent.getWidth());
165168 float thetaX = 360.0f * ( (float)(prevMouseY-y)/(float)display_parent.getHeight());
166
169
167170 prevMouseX = x;
168171 prevMouseY = y;
169
172
170173 view_rotx += thetaX;
171174 view_roty += thetaY;
172175 }
173
176
174177 // F Key Pressed (i.e. released)
175178 if (keyDown && !Keyboard.isKeyDown(Keyboard.KEY_F)) {
176179 keyDown = false;
177
180
178181 try {
179182 if (Display.isFullscreen()) {
180183 Display.setFullscreen(false);
187190 }
188191 }
189192 }
190
193
191194 Display.destroy();
192195 }
193
196
194197 public void drawLoop() {
195 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
196
197 GL11.glPushMatrix();
198
199 GL11.glRotatef(view_rotx, 1.0f, 0.0f, 0.0f);
200 GL11.glRotatef(view_roty, 0.0f, 1.0f, 0.0f);
201 GL11.glRotatef(view_rotz, 0.0f, 0.0f, 1.0f);
202
203 GL11.glPushMatrix();
204 GL11.glTranslatef(-3.0f, -2.0f, 0.0f);
205 GL11.glRotatef(angle, 0.0f, 0.0f, 1.0f);
206 GL11.glCallList(gear1);
207 GL11.glPopMatrix();
208
209 GL11.glPushMatrix();
210 GL11.glTranslatef(3.1f, -2.0f, 0.0f);
211 GL11.glRotatef(-2.0f * angle - 9.0f, 0.0f, 0.0f, 1.0f);
212 GL11.glCallList(gear2);
213 GL11.glPopMatrix();
214
215 GL11.glPushMatrix();
216 GL11.glTranslatef(-3.1f, 4.2f, 0.0f);
217 GL11.glRotatef(-2.0f * angle - 25.0f, 0.0f, 0.0f, 1.0f);
218 GL11.glCallList(gear3);
219 GL11.glPopMatrix();
220
221 GL11.glPopMatrix();
198 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
199
200 glPushMatrix();
201
202 glRotatef(view_rotx, 1.0f, 0.0f, 0.0f);
203 glRotatef(view_roty, 0.0f, 1.0f, 0.0f);
204 glRotatef(view_rotz, 0.0f, 0.0f, 1.0f);
205
206 glPushMatrix();
207 glTranslatef(-3.0f, -2.0f, 0.0f);
208 glRotatef(angle, 0.0f, 0.0f, 1.0f);
209 glCallList(gear1);
210 glPopMatrix();
211
212 glPushMatrix();
213 glTranslatef(3.1f, -2.0f, 0.0f);
214 glRotatef(-2.0f * angle - 9.0f, 0.0f, 0.0f, 1.0f);
215 glCallList(gear2);
216 glPopMatrix();
217
218 glPushMatrix();
219 glTranslatef(-3.1f, 4.2f, 0.0f);
220 glRotatef(-2.0f * angle - 25.0f, 0.0f, 0.0f, 1.0f);
221 glCallList(gear3);
222 glPopMatrix();
223
224 glPopMatrix();
222225 }
223226
224227 protected void initGL() {
228231 FloatBuffer red = BufferUtils.createFloatBuffer(4).put(new float[] { 0.8f, 0.1f, 0.0f, 1.0f});
229232 FloatBuffer green = BufferUtils.createFloatBuffer(4).put(new float[] { 0.0f, 0.8f, 0.2f, 1.0f});
230233 FloatBuffer blue = BufferUtils.createFloatBuffer(4).put(new float[] { 0.2f, 0.2f, 1.0f, 1.0f});
231
234
232235 pos.flip();
233236 red.flip();
234237 green.flip();
235238 blue.flip();
236
237 GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, pos);
238 GL11.glEnable(GL11.GL_CULL_FACE);
239 GL11.glEnable(GL11.GL_LIGHTING);
240 GL11.glEnable(GL11.GL_LIGHT0);
241 GL11.glEnable(GL11.GL_DEPTH_TEST);
239
240 glLight(GL_LIGHT0, GL_POSITION, pos);
241 glEnable(GL_CULL_FACE);
242 glEnable(GL_LIGHTING);
243 glEnable(GL_LIGHT0);
244 glEnable(GL_DEPTH_TEST);
242245
243246 /* make the gears */
244 gear1 = GL11.glGenLists(1);
245 GL11.glNewList(gear1, GL11.GL_COMPILE);
246 GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE, red);
247 gear1 = glGenLists(1);
248 glNewList(gear1, GL_COMPILE);
249 glMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red);
247250 gear(1.0f, 4.0f, 1.0f, 20, 0.7f);
248 GL11.glEndList();
249
250 gear2 = GL11.glGenLists(1);
251 GL11.glNewList(gear2, GL11.GL_COMPILE);
252 GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE, green);
251 glEndList();
252
253 gear2 = glGenLists(1);
254 glNewList(gear2, GL_COMPILE);
255 glMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green);
253256 gear(0.5f, 2.0f, 2.0f, 10, 0.7f);
254 GL11.glEndList();
255
256 gear3 = GL11.glGenLists(1);
257 GL11.glNewList(gear3, GL11.GL_COMPILE);
258 GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE, blue);
257 glEndList();
258
259 gear3 = glGenLists(1);
260 glNewList(gear3, GL_COMPILE);
261 glMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue);
259262 gear(1.3f, 2.0f, 0.5f, 10, 0.7f);
260 GL11.glEndList();
261 GL11.glEnable(GL11.GL_NORMALIZE);
262 GL11.glMatrixMode(GL11.GL_PROJECTION);
263
264 System.err.println("GL_VENDOR: " + GL11.glGetString(GL11.GL_VENDOR));
265 System.err.println("GL_RENDERER: " + GL11.glGetString(GL11.GL_RENDERER));
266 System.err.println("GL_VERSION: " + GL11.glGetString(GL11.GL_VERSION));
263 glEndList();
264 glEnable(GL_NORMALIZE);
265 glMatrixMode(GL_PROJECTION);
266
267 System.err.println("LWJGL: " + Sys.getVersion() + " / " + LWJGLUtil.getPlatformName());
268 System.err.println("GL_VENDOR: " + glGetString(GL_VENDOR));
269 System.err.println("GL_RENDERER: " + glGetString(GL_RENDERER));
270 System.err.println("GL_VERSION: " + glGetString(GL_VERSION));
267271 System.err.println();
268272 System.err.println("glLoadTransposeMatrixfARB() supported: " + GLContext.getCapabilities().GL_ARB_transpose_matrix);
269
273
270274 if (!GLContext.getCapabilities().GL_ARB_transpose_matrix) {
271275 // --- not using extensions
272 GL11.glLoadIdentity();
276 glLoadIdentity();
273277 } else {
274278 // --- using extensions
275279 final FloatBuffer identityTranspose = BufferUtils.createFloatBuffer(16).put(
276280 new float[] { 1, 0, 0, 0, 0, 1, 0, 0,
277281 0, 0, 1, 0, 0, 0, 0, 1});
278282 identityTranspose.flip();
279 ARBTransposeMatrix.glLoadTransposeMatrixARB(identityTranspose);
283 glLoadTransposeMatrixARB(identityTranspose);
280284 }
281285 float h = (float) display_parent.getHeight() / (float) display_parent.getWidth();
282 GL11.glFrustum(-1.0f, 1.0f, -h, h, 5.0f, 60.0f);
283 GL11.glMatrixMode(GL11.GL_MODELVIEW);
284 GL11.glLoadIdentity();
285 GL11.glTranslatef(0.0f, 0.0f, -40.0f);
286 glFrustum(-1.0f, 1.0f, -h, h, 5.0f, 60.0f);
287 glMatrixMode(GL_MODELVIEW);
288 glLoadIdentity();
289 glTranslatef(0.0f, 0.0f, -40.0f);
286290 } catch (Exception e) {
287291 System.err.println(e);
288292 running = false;
309313 r1 = outer_radius - tooth_depth / 2.0f;
310314 r2 = outer_radius + tooth_depth / 2.0f;
311315 da = 2.0f * (float) Math.PI / teeth / 4.0f;
312 GL11.glShadeModel(GL11.GL_FLAT);
313 GL11.glNormal3f(0.0f, 0.0f, 1.0f);
316 glShadeModel(GL_FLAT);
317 glNormal3f(0.0f, 0.0f, 1.0f);
314318 /* draw front face */
315 GL11.glBegin(GL11.GL_QUAD_STRIP);
319 glBegin(GL_QUAD_STRIP);
316320 for (i = 0; i <= teeth; i++) {
317321 angle = i * 2.0f * (float) Math.PI / teeth;
318 GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f);
319 GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f);
322 glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f);
323 glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f);
320324 if (i < teeth) {
321 GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f);
322 GL11.glVertex3f(r1 * (float) Math.cos(angle + 3.0f * da), r1 * (float) Math.sin(angle + 3.0f * da),
325 glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f);
326 glVertex3f(r1 * (float) Math.cos(angle + 3.0f * da), r1 * (float) Math.sin(angle + 3.0f * da),
323327 width * 0.5f);
324328 }
325329 }
326 GL11.glEnd();
330 glEnd();
327331
328332 /* draw front sides of teeth */
329 GL11.glBegin(GL11.GL_QUADS);
333 glBegin(GL_QUADS);
330334 for (i = 0; i < teeth; i++) {
331335 angle = i * 2.0f * (float) Math.PI / teeth;
332 GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f);
333 GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), width * 0.5f);
334 GL11.glVertex3f(r2 * (float) Math.cos(angle + 2.0f * da), r2 * (float) Math.sin(angle + 2.0f * da), width * 0.5f);
335 GL11.glVertex3f(r1 * (float) Math.cos(angle + 3.0f * da), r1 * (float) Math.sin(angle + 3.0f * da), width * 0.5f);
336 }
337 GL11.glEnd();
336 glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f);
337 glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), width * 0.5f);
338 glVertex3f(r2 * (float) Math.cos(angle + 2.0f * da), r2 * (float) Math.sin(angle + 2.0f * da), width * 0.5f);
339 glVertex3f(r1 * (float) Math.cos(angle + 3.0f * da), r1 * (float) Math.sin(angle + 3.0f * da), width * 0.5f);
340 }
341 glEnd();
338342
339343 /* draw back face */
340 GL11.glBegin(GL11.GL_QUAD_STRIP);
344 glBegin(GL_QUAD_STRIP);
341345 for (i = 0; i <= teeth; i++) {
342346 angle = i * 2.0f * (float) Math.PI / teeth;
343 GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f);
344 GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f);
345 GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f);
346 GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f);
347 }
348 GL11.glEnd();
347 glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f);
348 glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f);
349 glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f);
350 glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f);
351 }
352 glEnd();
349353
350354 /* draw back sides of teeth */
351 GL11.glBegin(GL11.GL_QUADS);
355 glBegin(GL_QUADS);
352356 for (i = 0; i < teeth; i++) {
353357 angle = i * 2.0f * (float) Math.PI / teeth;
354 GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f);
355 GL11.glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), -width * 0.5f);
356 GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), -width * 0.5f);
357 GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f);
358 }
359 GL11.glEnd();
358 glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f);
359 glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), -width * 0.5f);
360 glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), -width * 0.5f);
361 glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f);
362 }
363 glEnd();
360364
361365 /* draw outward faces of teeth */
362 GL11.glBegin(GL11.GL_QUAD_STRIP);
366 glBegin(GL_QUAD_STRIP);
363367 for (i = 0; i < teeth; i++) {
364368 angle = i * 2.0f * (float) Math.PI / teeth;
365 GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f);
366 GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f);
369 glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f);
370 glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f);
367371 u = r2 * (float) Math.cos(angle + da) - r1 * (float) Math.cos(angle);
368372 v = r2 * (float) Math.sin(angle + da) - r1 * (float) Math.sin(angle);
369373 len = (float) Math.sqrt(u * u + v * v);
370374 u /= len;
371375 v /= len;
372 GL11.glNormal3f(v, -u, 0.0f);
373 GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), width * 0.5f);
374 GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), -width * 0.5f);
375 GL11.glNormal3f((float) Math.cos(angle), (float) Math.sin(angle), 0.0f);
376 GL11.glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), width * 0.5f);
377 GL11.glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), -width * 0.5f);
376 glNormal3f(v, -u, 0.0f);
377 glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), width * 0.5f);
378 glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), -width * 0.5f);
379 glNormal3f((float) Math.cos(angle), (float) Math.sin(angle), 0.0f);
380 glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), width * 0.5f);
381 glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), -width * 0.5f);
378382 u = r1 * (float) Math.cos(angle + 3 * da) - r2 * (float) Math.cos(angle + 2 * da);
379383 v = r1 * (float) Math.sin(angle + 3 * da) - r2 * (float) Math.sin(angle + 2 * da);
380 GL11.glNormal3f(v, -u, 0.0f);
381 GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), width * 0.5f);
382 GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f);
383 GL11.glNormal3f((float) Math.cos(angle), (float) Math.sin(angle), 0.0f);
384 }
385 GL11.glVertex3f(r1 * (float) Math.cos(0), r1 * (float) Math.sin(0), width * 0.5f);
386 GL11.glVertex3f(r1 * (float) Math.cos(0), r1 * (float) Math.sin(0), -width * 0.5f);
387 GL11.glEnd();
388
389 GL11.glShadeModel(GL11.GL_SMOOTH);
384 glNormal3f(v, -u, 0.0f);
385 glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), width * 0.5f);
386 glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f);
387 glNormal3f((float) Math.cos(angle), (float) Math.sin(angle), 0.0f);
388 }
389 glVertex3f(r1 * (float) Math.cos(0), r1 * (float) Math.sin(0), width * 0.5f);
390 glVertex3f(r1 * (float) Math.cos(0), r1 * (float) Math.sin(0), -width * 0.5f);
391 glEnd();
392
393 glShadeModel(GL_SMOOTH);
390394 /* draw inside radius cylinder */
391 GL11.glBegin(GL11.GL_QUAD_STRIP);
395 glBegin(GL_QUAD_STRIP);
392396 for (i = 0; i <= teeth; i++) {
393397 angle = i * 2.0f * (float) Math.PI / teeth;
394 GL11.glNormal3f(-(float) Math.cos(angle), -(float) Math.sin(angle), 0.0f);
395 GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f);
396 GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f);
397 }
398 GL11.glEnd();
398 glNormal3f(-(float) Math.cos(angle), -(float) Math.sin(angle), 0.0f);
399 glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f);
400 glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f);
401 }
402 glEnd();
399403 }
400404 }
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 */
3838 import org.lwjgl.openal.AL10;
3939 import org.lwjgl.opengl.AWTGLCanvas;
4040 import org.lwjgl.opengl.Display;
41 import org.lwjgl.opengl.GL11;
4241 import org.lwjgl.util.WaveData;
42
43 import static org.lwjgl.opengl.GL11.*;
4344
4445 public class OpenAL extends AWTGLCanvas implements Test {
4546
46 float angle = 0;
47
47 float angle;
48
4849 // create 1 buffer and 1 source
4950 IntBuffer buffers = BufferUtils.createIntBuffer(1);
50 IntBuffer sources = BufferUtils.createIntBuffer(1);
51 IntBuffer sources = BufferUtils.createIntBuffer(1);
5152
5253 public OpenAL() throws LWJGLException {
53
54
5455 try {
5556 AL.create();
5657 } catch (Exception e) {
5758 System.out.println("Unable to create OpenAL.\nPlease make sure that OpenAL is available on this system. Exception: " + e);
5859 return;
59 }
60
60 }
61
6162 Thread t = new Thread() {
6263
6364 public void run() {
7475
7576 private void playOpenAL() {
7677 int lastError;
77
78
7879 // al generate buffers and sources
7980 buffers.position(0).limit(1);
8081 AL10.alGenBuffers(buffers);
8788 if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
8889 exit(lastError);
8990 }
90
91
9192 // load wave data from buffer
9293 WaveData wavefile = WaveData.create(getClass().getClassLoader().getResourceAsStream("Footsteps.wav"));
9394
9495 //copy to buffers
9596 AL10.alBufferData(buffers.get(0), wavefile.format, wavefile.data, wavefile.samplerate);
96
97
9798 //unload file again
98 wavefile.dispose();
99
99 wavefile.dispose();
100
100101 if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
101102 exit(lastError);
102 }
103 }
103104
104105 //set up source input
105106 AL10.alSourcei(sources.get(0), AL10.AL_BUFFER, buffers.get(0));
106107 if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
107108 exit(lastError);
108 }
109
109 }
110
110111 //lets loop the sound
111112 AL10.alSourcei(sources.get(0), AL10.AL_LOOPING, AL10.AL_TRUE);
112113 if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
113114 exit(lastError);
114 }
115
115 }
116
116117 //play source 0
117118 AL10.alSourcePlay(sources.get(0));
118119 if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
119120 exit(lastError);
120 }
121 }
121122 }
122123
123124 private void exit(int error) {
125126 }
126127
127128 public void paintGL() {
128 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
129 GL11.glMatrixMode(GL11.GL_PROJECTION_MATRIX);
130 GL11.glLoadIdentity();
131 GL11.glOrtho(0, 640, 0, 480, 1, -1);
132 GL11.glMatrixMode(GL11.GL_MODELVIEW_MATRIX);
129 glClear(GL_COLOR_BUFFER_BIT);
130 glMatrixMode(GL_PROJECTION_MATRIX);
131 glLoadIdentity();
132 glOrtho(0, 640, 0, 480, 1, -1);
133 glMatrixMode(GL_MODELVIEW_MATRIX);
133134
134 GL11.glPushMatrix();
135 GL11.glTranslatef(320, 240, 0.0f);
136 GL11.glRotatef(angle, 0, 0, 1.0f);
137 GL11.glBegin(GL11.GL_QUADS);
138 GL11.glVertex2i(-50, -50);
139 GL11.glVertex2i(50, -50);
140 GL11.glVertex2i(50, 50);
141 GL11.glVertex2i(-50, 50);
142 GL11.glEnd();
143 GL11.glPopMatrix();
135 glPushMatrix();
136 glTranslatef(320, 240, 0.0f);
137 glRotatef(angle, 0, 0, 1.0f);
138 glBegin(GL_QUADS);
139 glVertex2i(-50, -50);
140 glVertex2i(50, -50);
141 glVertex2i(50, 50);
142 glVertex2i(-50, 50);
143 glEnd();
144 glPopMatrix();
144145
145146 angle += 1;
146147
151152 }
152153
153154 public void start() {
154 playOpenAL();
155 playOpenAL();
155156 }
156157
157158 public void stop() {
158159 int lastError;
159
160
160161 //stop source 0
161162 AL10.alSourceStop(sources.get(0));
162163 if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
163164 exit(lastError);
164 }
165
165 }
166
166167 //delete buffers and sources
167168 sources.position(0).limit(1);
168169 AL10.alDeleteSources(sources);
169170 if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
170171 exit(lastError);
171172 }
172
173
173174 buffers.position(0).limit(1);
174175 AL10.alDeleteBuffers(buffers);
175176 if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
176177 exit(lastError);
177178 }
178
179
179180 AL.destroy();
180181 }
181182 }
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 */
3434 import org.lwjgl.input.Keyboard;
3535 import org.lwjgl.input.Mouse;
3636 import org.lwjgl.opengl.AWTGLCanvas;
37 import org.lwjgl.opengl.GL11;
37
38 import static org.lwjgl.opengl.GL11.*;
3839
3940 public class OpenGL extends AWTGLCanvas implements Test {
4041
41 float angle = 0;
42 float angle;
4243 float x;
4344 float y;
4445
4647 }
4748
4849 public void initGL() {
49 GL11.glMatrixMode(GL11.GL_PROJECTION_MATRIX);
50 GL11.glLoadIdentity();
51 GL11.glOrtho(0, 640, 0, 480, 1, -1);
50 glMatrixMode(GL_PROJECTION_MATRIX);
51 glLoadIdentity();
52 glOrtho(0, 640, 0, 480, 1, -1);
5253 x = 320;
5354 y = 240;
54 GL11.glMatrixMode(GL11.GL_MODELVIEW_MATRIX);
55 glMatrixMode(GL_MODELVIEW_MATRIX);
5556 setVSyncEnabled(true);
5657 }
5758
5859 public void paintGL() {
59 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
60 glClear(GL_COLOR_BUFFER_BIT);
6061
61 GL11.glPushMatrix();
62 GL11.glTranslatef(x, y, 0.0f);
63 GL11.glRotatef(angle, 0, 0, 1.0f);
64 GL11.glBegin(GL11.GL_QUADS);
65 GL11.glVertex2i(-50, -50);
66 GL11.glVertex2i(50, -50);
67 GL11.glVertex2i(50, 50);
68 GL11.glVertex2i(-50, 50);
69 GL11.glEnd();
70 GL11.glPopMatrix();
62 glPushMatrix();
63 glTranslatef(x, y, 0.0f);
64 glRotatef(angle, 0, 0, 1.0f);
65 glBegin(GL_QUADS);
66 glVertex2i(-50, -50);
67 glVertex2i(50, -50);
68 glVertex2i(50, 50);
69 glVertex2i(-50, 50);
70 glEnd();
71 glPopMatrix();
7172
7273 angle += 1;
7374
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 */
3232
3333 import org.lwjgl.LWJGLException;
3434 import org.lwjgl.opengl.AWTGLCanvas;
35 import org.lwjgl.opengl.GL11;
35
36 import static org.lwjgl.opengl.GL11.*;
3637
3738 public class Speed extends AWTGLCanvas implements Test {
3839
39 private float angle = 0;
40 private float angle;
4041 private long startTime = System.currentTimeMillis() + 5000;
41 private long fps = 0;
42 private long fps;
4243
4344 public Speed() throws LWJGLException {
4445 }
4546
4647 public void paintGL() {
47 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
48 GL11.glMatrixMode(GL11.GL_PROJECTION_MATRIX);
49 GL11.glLoadIdentity();
50 GL11.glOrtho(0, 640, 0, 480, 1, -1);
51 GL11.glMatrixMode(GL11.GL_MODELVIEW_MATRIX);
48 glClear(GL_COLOR_BUFFER_BIT);
49 glMatrixMode(GL_PROJECTION_MATRIX);
50 glLoadIdentity();
51 glOrtho(0, 640, 0, 480, 1, -1);
52 glMatrixMode(GL_MODELVIEW_MATRIX);
5253
53 GL11.glPushMatrix();
54 GL11.glTranslatef(320, 240, 0.0f);
55 GL11.glRotatef(angle, 0, 0, 1.0f);
56 GL11.glBegin(GL11.GL_QUADS);
57 GL11.glVertex2i(-50, -50);
58 GL11.glVertex2i(50, -50);
59 GL11.glVertex2i(50, 50);
60 GL11.glVertex2i(-50, 50);
61 GL11.glEnd();
62 GL11.glPopMatrix();
54 glPushMatrix();
55 glTranslatef(320, 240, 0.0f);
56 glRotatef(angle, 0, 0, 1.0f);
57 glBegin(GL_QUADS);
58 glVertex2i(-50, -50);
59 glVertex2i(50, -50);
60 glVertex2i(50, 50);
61 glVertex2i(-50, 50);
62 glEnd();
63 glPopMatrix();
6364
6465 angle += 1;
6566
7677 } else {
7778 long timeUsed = 5000 + (startTime - System.currentTimeMillis());
7879 startTime = System.currentTimeMillis() + 5000;
79 System.out.println(fps + " frames in " + (float) (timeUsed / 1000f) + " seconds = "
80 System.out.println(fps + " frames in " + timeUsed / 1000f + " seconds = "
8081 + (fps / (timeUsed / 1000f)));
8182 fps = 0;
82 }
83 }
8384 }
8485
8586 public void start() {
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 */
3232
3333
3434 public interface Test {
35 public void start();
36 public void stop();
35 void start();
36 void stop();
3737 }
3030 */
3131 package org.lwjgl.test.glu.tessellation;
3232
33 import org.lwjgl.opengl.GL11;
3433 import org.lwjgl.util.glu.GLUtessellatorCallbackAdapter;
34
35 import static org.lwjgl.opengl.GL11.*;
3536
3637 public class TessCallback extends GLUtessellatorCallbackAdapter {
3738
3839 public void begin(int type) {
39 GL11.glBegin(type);
40 glBegin(type);
4041 }
4142
4243 public void combine(double[] coords, Object[] data, float[] weight, Object[] outData) {
4849 combined[3] = 1;
4950 combined[4] = 1;
5051 combined[5] = 1;
51
52
5253 outData[i] = new VertexData(combined);
5354 }
5455 // vertex[0] = coords[0];
6566 //
6667 // *dataOut = vertex;
6768 }
68
69
6970 public void end() {
70 GL11.glEnd();
71 glEnd();
7172 }
7273
7374 public void vertex(Object vertexData) {
7475 VertexData vertex = (VertexData) vertexData;
7576
76 GL11.glVertex3d(vertex.data[0], vertex.data[1], vertex.data[2]);
77 GL11.glColor3d(vertex.data[3], vertex.data[4], vertex.data[5]);
77 glVertex3d(vertex.data[0], vertex.data[1], vertex.data[2]);
78 glColor3d(vertex.data[3], vertex.data[4], vertex.data[5]);
7879 }
7980 }
3232 import org.lwjgl.LWJGLException;
3333 import org.lwjgl.opengl.Display;
3434 import org.lwjgl.opengl.DisplayMode;
35 import org.lwjgl.opengl.GL11;
36 import org.lwjgl.util.glu.GLU;
3735 import org.lwjgl.util.glu.GLUtessellator;
36
37 import static org.lwjgl.opengl.GL11.*;
38 import static org.lwjgl.util.glu.GLU.*;
3839
3940 public class TessellationTest {
4041 private GLUtessellator tesselator;
41
42
4243 void init()
4344 {
44 // Create a new tessellation object
45 tesselator = GLU.gluNewTess();
46
45 // Create a new tessellation object
46 tesselator = gluNewTess();
47
4748 // Set callback functions
4849 TessCallback callback = new TessCallback();
49 tesselator.gluTessCallback(GLU.GLU_TESS_VERTEX, callback);
50 tesselator.gluTessCallback(GLU.GLU_TESS_BEGIN, callback);
51 tesselator.gluTessCallback(GLU.GLU_TESS_END, callback);
52 tesselator.gluTessCallback(GLU.GLU_TESS_COMBINE, callback);
50 tesselator.gluTessCallback(GLU_TESS_VERTEX, callback);
51 tesselator.gluTessCallback(GLU_TESS_BEGIN, callback);
52 tesselator.gluTessCallback(GLU_TESS_END, callback);
53 tesselator.gluTessCallback(GLU_TESS_COMBINE, callback);
5354 }
5455
5556 void setWindingRule(int windingRule)
5657 {
5758 // Set the winding rule
58 tesselator.gluTessProperty(GLU.GLU_TESS_WINDING_RULE, windingRule);
59 tesselator.gluTessProperty(GLU_TESS_WINDING_RULE, windingRule);
5960 }
60
61
6162 void renderContour(double obj_data[][], int num_vertices)
6263 {
6364 for (int x = 0; x < num_vertices; x++) //loop through the vertices
6566 tesselator.gluTessVertex(obj_data[x], 0, new VertexData(obj_data[x])); //store the vertex
6667 }
6768 }
68
69
6970 void beginPolygon()
7071 {
7172 tesselator.gluTessBeginPolygon(null);
7576 {
7677 tesselator.gluTessEndPolygon();
7778 }
78
79
7980 void beginContour()
8081 {
8182 tesselator.gluTessBeginContour();
8586 {
8687 tesselator.gluTessEndContour();
8788 }
88
89
8990 void end()
9091 {
9192 tesselator.gluDeleteTess();
9495 private void createDisplay() throws LWJGLException {
9596 int width = 300;
9697 int height = 300;
97
98
9899 Display.setDisplayMode(new DisplayMode(width,height));
99100 Display.create();
100101 Display.setVSyncEnabled(true);
101102
102 GL11.glEnable(GL11.GL_TEXTURE_2D);
103 GL11.glShadeModel(GL11.GL_SMOOTH);
104 GL11.glDisable(GL11.GL_DEPTH_TEST);
105 GL11.glDisable(GL11.GL_LIGHTING);
106
107 GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
108 GL11.glClearDepth(1);
109
110 GL11.glEnable(GL11.GL_BLEND);
111 GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
112
113 GL11.glViewport(0,0,width,height);
114 GL11.glMatrixMode(GL11.GL_MODELVIEW);
103 glEnable(GL_TEXTURE_2D);
104 glShadeModel(GL_SMOOTH);
105 glDisable(GL_DEPTH_TEST);
106 glDisable(GL_LIGHTING);
115107
116 GL11.glMatrixMode(GL11.GL_PROJECTION);
117 GL11.glLoadIdentity();
118 GL11.glOrtho(0, width, height, 0, 1, -1);
119 GL11.glMatrixMode(GL11.GL_MODELVIEW);
108 glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
109 glClearDepth(1);
110
111 glEnable(GL_BLEND);
112 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
113
114 glViewport(0,0,width,height);
115 glMatrixMode(GL_MODELVIEW);
116
117 glMatrixMode(GL_PROJECTION);
118 glLoadIdentity();
119 glOrtho(0, width, height, 0, 1, -1);
120 glMatrixMode(GL_MODELVIEW);
120121 }
121
122
122123 private void loop() {
123124 while (true) {
124125 render();
125126 Display.update();
126127 Display.sync(100);
127
128
128129 if (Display.isCloseRequested()) {
129130 System.exit(0);
130131 }
131132 }
132133 }
133
134
134135 private void render() {
135 GL11.glTranslatef(150,125,0);
136
137 GL11.glScalef(50,50,1);
136 glTranslatef(150,125,0);
137
138 glScalef(50,50,1);
138139 // first polygon: a star-5 vertices and color information
139140 double star[][] = { {0.6f, -0.1f, 0f, 1.0f, 1.0f, 1.0f},
140141 {1.35f, 1.4f, 0f, 1.0f, 1.0f, 1.0f},
147148 {1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f},
148149 {1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f},
149150 {0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f} };
150
151
151152 //second polygon: a triangle-3 vertices; second contour
152153 double tri[][] = {{0.3f, 0.3f, 0.0f, 0.0f, 0.0f, 0.0f},
153154 {0.7f, 0.3f, 0.0f, 0.0f, 0.0f, 0.0f},
154155 {0.5f, 0.7f, 0.0f, 0.0f, 0.0f, 0.0f} };
155156
156157 // render the first polygon: the textured star
157
158
158159 // set winding rule to positive
159 setWindingRule(GLU.GLU_TESS_WINDING_POSITIVE);
160 setWindingRule(GLU_TESS_WINDING_POSITIVE);
160161 beginPolygon();
161162 beginContour();
162163 renderContour(star, 5);
165166
166167 // render the second polygon: triangle cut out of a quad
167168
168 GL11.glTranslatef(-2,0,0);
169 glTranslatef(-2,0,0);
169170 // set winding rule to odd
170 setWindingRule(GLU.GLU_TESS_WINDING_ODD);
171 setWindingRule(GLU_TESS_WINDING_ODD);
171172 // begin the new polygon
172173 beginPolygon();
173174 beginContour();
180181 // delete the tess object
181182 end();
182183 }
183
184
184185 private void start() throws LWJGLException {
185186 createDisplay();
186187 init();
187188 loop();
188189 }
189
190
190191 public static void main(String[] argv) throws LWJGLException {
191192 TessellationTest test = new TessellationTest();
192193 test.start();
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 */
3939 import org.lwjgl.input.Mouse;
4040 import org.lwjgl.opengl.Display;
4141 import org.lwjgl.opengl.DisplayMode;
42 import org.lwjgl.opengl.GL11;
43 import org.lwjgl.util.glu.GLU;
42
43 import static org.lwjgl.opengl.GL11.*;
44 import static org.lwjgl.util.glu.GLU.*;
4445
4546 /**
4647 *
4748 * Tests switching between windowed and fullscreen - including hardware cursor test
4849 *
4950 * @author Brian Matzon <brian@matzon.dk>
50 * @version $Revision: 2983 $
51 * $Id: HWCursorTest.java 2983 2008-04-07 18:36:09Z matzon $
51 * @version $Revision: 3418 $
52 * $Id: HWCursorTest.java 3418 2010-09-28 21:11:35Z spasi $
5253 */
5354 public class HWCursorTest {
54
55
5556 /** The native cursor */
56 private static Cursor[] cursor = null;
57
57 private static Cursor[] cursors;
58
5859 /** The mouse cursor position */
5960 private static int mouse_x;
6061 private static int mouse_y;
61 private static int mouse_btn = 0;
62
62 private static int mouse_btn;
63
6364 /**
6465 * Executes the test
6566 */
6667 public void execute() {
6768 initialize();
68
69
6970 mainLoop();
70
71
7172 cleanup();
7273 }
73
74
7475 /**
7576 * Sets the display mode for fullscreen mode
7677 */
8485 "height=" + 480,
8586 "freq=" + 60,
8687 "bpp=" + org.lwjgl.opengl.Display.getDisplayMode().getBitsPerPixel()
87 });
88 });
8889 return true;
8990 } catch (Exception e) {
9091 e.printStackTrace();
9192 }
92
93
9394 return false;
94 }
95
95 }
96
9697 /**
9798 * Initializes the test
9899 */
101102 // start of in windowed mode
102103 setDisplayMode();
103104 Display.create();
104
105
105106 glInit();
106
107
107108 initNativeCursors();
108
109
109110 } catch (Exception e) {
110111 e.printStackTrace();
111112 System.exit(-1);
112113 }
113114 }
114
115
115116 private static void initNativeCursors() throws Exception {
116117 if ((Cursor.getCapabilities() & Cursor.CURSOR_ONE_BIT_TRANSPARENCY) == 0) {
117118 System.out.println("No HW cursor support!");
118119 System.exit(0);
119120 }
120
121 cursor = new Cursor[3];
122
121
122 cursors = new Cursor[3];
123
123124 int cursorImageCount = 1;
124125 int cursorWidth = Math.min(64, Cursor.getMaxCursorSize());
125126 int cursorHeight = cursorWidth;
126127 IntBuffer cursorImages;
127128 IntBuffer cursorDelays;
128
129
129
130
130131 // Create a single cursor
131132 // ==================================
132133 cursorImages = ByteBuffer.allocateDirect(cursorWidth*cursorHeight*cursorImageCount*4).order(ByteOrder.nativeOrder()).asIntBuffer();
137138 }
138139 }
139140 cursorImages.flip();
140 cursor[0] = new Cursor(cursorWidth, cursorHeight, cursorWidth/2, cursorHeight/2, cursorImageCount, cursorImages, cursorDelays);
141 cursors[0] = new Cursor(cursorWidth, cursorHeight, cursorWidth/2, cursorHeight/2, cursorImageCount, cursorImages, cursorDelays);
141142 // ----------------------------------
142
143
143144 // Create 3 piece animation
144145 // ==================================
145146 cursorImageCount = 3;
146147 cursorImages = ByteBuffer.allocateDirect(cursorWidth*cursorHeight*cursorImageCount*4).order(ByteOrder.nativeOrder()).asIntBuffer();
147148 cursorDelays = ByteBuffer.allocateDirect(cursorImageCount*4).order(ByteOrder.nativeOrder()).asIntBuffer();
148149 for(int i=0; i<cursorImageCount; i++) {
149
150 // make a colored square with a chocolate center
150
151 // make a colored square with a chocolate center
151152 int offColor = 0x00000000;
152153 int onColor = 0xffff0000;
153
154
154155 // change color according to cursor
155156 if(i == 1) {
156157 onColor = 0xff00ff00;
157158 } else if (i == 2) {
158159 onColor = 0xff0000ff;
159160 }
160
161
161162 // calculate size of center
162163 int centerSize = (cursorWidth / 5) * (i + 1);
163164 int centerLeft = cursorWidth / 2 - centerSize / 2;
164165 int centerRight = cursorWidth / 2 + centerSize / 2;
165
166
166167 // go!
167168 for(int j=0; j<cursorWidth; j++) {
168169 for(int l=0; l<cursorHeight; l++) {
177178 cursorDelays.put(2000).put(2000).put(2000);
178179 cursorDelays.flip();
179180 cursorImages.flip();
180
181 cursor[1] = new Cursor(cursorWidth, cursorHeight, cursorWidth/2, cursorHeight/2, cursorImageCount, cursorImages, cursorDelays);
181
182 cursors[1] = new Cursor(cursorWidth, cursorHeight, cursorWidth/2, cursorHeight/2, cursorImageCount, cursorImages, cursorDelays);
182183 // ----------------------------------
183
184
184
185
185186 // Create a 20 piece animation
186187 // ==================================
187188 cursorImageCount = 20;
188189 cursorImages = ByteBuffer.allocateDirect(cursorWidth*cursorHeight*cursorImageCount*4).order(ByteOrder.nativeOrder()).asIntBuffer();
189190 cursorDelays = ByteBuffer.allocateDirect(cursorImageCount*4).order(ByteOrder.nativeOrder()).asIntBuffer();
190191 cursorDelays.put(
191 new int[] {
192 new int[] {
192193 100, 100, 100, 100, 100,
193194 100, 100, 100, 100, 100,
194195 100, 100, 100, 100, 100,
195196 100, 100, 100, 100, 100
196197 });
197
198
198199 float step = 0xffffffff / 20.0f;
199200 for(int i=0; i<cursorImageCount; i++) {
200201 for(int j=0; j<cursorWidth; j++) {
206207 }
207208 cursorImages.flip();
208209 cursorDelays.flip();
209 cursor[2] = new Cursor(cursorWidth, cursorHeight, cursorWidth/2, cursorHeight/2, cursorImageCount, cursorImages, cursorDelays);
210 cursors[2] = new Cursor(cursorWidth, cursorHeight, cursorWidth/2, cursorHeight/2, cursorImageCount, cursorImages, cursorDelays);
210211 // ----------------------------------
211
212 Mouse.setNativeCursor(cursor[0]);
213 }
214
212
213 Mouse.setNativeCursor(cursors[0]);
214 }
215
215216 /**
216217 * Runs the main loop of the "test"
217218 */
220221 && !Display.isCloseRequested()) {
221222 // allow subsystem to get a chance to run too
222223 Display.update();
223
224
224225 if (Display.isVisible()) {
225226 // check keyboard input
226227 processKeyboard();
227228 processMouse();
228
229
229230 render();
230231 } else {
231
232
232233 // no need to render/paint if nothing has changed (ie. window dragged over)
233234 if (Display.isDirty()) {
234235 render();
235236 }
236
237
237238 // don't waste cpu time, sleep more
238239 try {
239240 Thread.sleep(100);
242243 }
243244 }
244245 }
245
246
246247 /**
247248 * Performs the logic
248249 */
249250 private void render() {
250251 //clear background
251 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
252
252 glClear(GL_COLOR_BUFFER_BIT);
253
253254 // draw white quad
254 GL11.glPushMatrix();
255 glPushMatrix();
255256 {
256 GL11.glTranslatef(mouse_x, mouse_y, 0);
257 GL11.glColor3f(1.0f, 1.0f, 1.0f);
258 GL11.glBegin(GL11.GL_QUADS);
257 glTranslatef(mouse_x, mouse_y, 0);
258 glColor3f(1.0f, 1.0f, 1.0f);
259 glBegin(GL_QUADS);
259260 {
260 GL11.glColor3f(1.0f, 0.0f, 0.0f); GL11.glVertex2i(-50, -50);
261 GL11.glColor3f(0.0f, 1.0f, 0.0f); GL11.glVertex2i(50, -50);
262 GL11.glColor3f(0.0f, 0.0f, 1.0f); GL11.glVertex2i(50, 50);
263 GL11.glColor3f(1.0f, 0.0f, 1.0f); GL11.glVertex2i(-50, 50);
264 }
265 GL11.glEnd();
266 }
267 GL11.glPopMatrix();
268 }
269
261 glColor3f(1.0f, 0.0f, 0.0f); glVertex2i(-50, -50);
262 glColor3f(0.0f, 1.0f, 0.0f); glVertex2i(50, -50);
263 glColor3f(0.0f, 0.0f, 1.0f); glVertex2i(50, 50);
264 glColor3f(1.0f, 0.0f, 1.0f); glVertex2i(-50, 50);
265 }
266 glEnd();
267 }
268 glPopMatrix();
269 }
270
270271 private void processMouse() {
271272 mouse_x = Mouse.getX();
272273 mouse_y = Mouse.getY();
273
274
274275 while(Mouse.next()) {
275276 int button = Mouse.getEventButton();
276277 if(button >= 0 && button < 3 && Mouse.getEventButtonState()) {
279280 }
280281 }
281282 }
282
283
283284 /**
284285 * Processes keyboard input
285286 */
286287 private void processKeyboard() {
287288 //check for fullscreen key
288289 if (Keyboard.isKeyDown(Keyboard.KEY_F)) {
289
290
290291 try {
291292 try {
292293 Mouse.setNativeCursor(null);
294295 e.printStackTrace();
295296 System.exit(1);
296297 }
297 for(int i=0; i<cursor.length; i++) {
298 cursor[i].destroy();
298 for ( Cursor aCursor : cursors ) {
299 aCursor.destroy();
299300 }
300301 Display.setFullscreen(true);
301
302
302303 glInit();
303
304
304305 initNativeCursors();
305306 } catch (Exception e) {
306307 e.printStackTrace();
307308 }
308309 }
309
310
310311 //check for window key
311312 if (Keyboard.isKeyDown(Keyboard.KEY_W)) {
312313 try {
316317 e.printStackTrace();
317318 System.exit(1);
318319 }
319 for(int i=0; i<cursor.length; i++) {
320 cursor[i].destroy();
320 for ( Cursor cursor : cursors ) {
321 cursor.destroy();
321322 }
322323 Display.setFullscreen(false);
323324 glInit();
324
325
325326 initNativeCursors();
326327 } catch (Exception e) {
327328 e.printStackTrace();
328329 }
329330 }
330
331
331332 if (Keyboard.isKeyDown(Keyboard.KEY_M)) {
332333 try {
333334 Mouse.setNativeCursor(null);
335336 e.printStackTrace();
336337 }
337338 }
338
339
339340 if (Keyboard.isKeyDown(Keyboard.KEY_N)) {
340341 switchCursor();
341342 }
342
343
343344 while(Keyboard.next()) {
344345 if(Keyboard.getEventKey() == Keyboard.KEY_SPACE && Keyboard.getEventKeyState()) {
345346 Mouse.setGrabbed(!Mouse.isGrabbed());
346 }
347 }
347348 }
348349 }
349350
350351 private void switchCursor() {
351352 try {
352 Mouse.setNativeCursor(cursor[mouse_btn]);
353 Mouse.setNativeCursor(cursors[mouse_btn]);
353354 } catch (Exception e) {
354355 e.printStackTrace();
355356 }
365366 e.printStackTrace();
366367 System.exit(1);
367368 }
368 for(int i=0; i<cursor.length; i++) {
369 cursor[i].destroy();
369 for ( Cursor cursor : cursors ) {
370 cursor.destroy();
370371 }
371372 Display.destroy();
372373 }
373
374
374375 /**
375376 * Initializes OGL
376377 */
377378 private void glInit() {
378379 // Go into orthographic projection mode.
379 GL11.glMatrixMode(GL11.GL_PROJECTION);
380 GL11.glLoadIdentity();
381 GLU.gluOrtho2D(0, Display.getDisplayMode().getWidth(), 0, Display.getDisplayMode().getHeight());
382 GL11.glMatrixMode(GL11.GL_MODELVIEW);
383 GL11.glLoadIdentity();
384 GL11.glViewport(0, 0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight());
385
380 glMatrixMode(GL_PROJECTION);
381 glLoadIdentity();
382 gluOrtho2D(0, Display.getDisplayMode().getWidth(), 0, Display.getDisplayMode().getHeight());
383 glMatrixMode(GL_MODELVIEW);
384 glLoadIdentity();
385 glViewport(0, 0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight());
386
386387 //set clear color to black
387 GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
388
388 glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
389
389390 //sync frame (only works on windows)
390391 Display.setVSyncEnabled(true);
391392 }
392
393
393394 /**
394395 * Test entry point
395396 */
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 */
3333 import org.lwjgl.input.Keyboard;
3434 import org.lwjgl.opengl.Display;
3535 import org.lwjgl.opengl.DisplayMode;
36 import org.lwjgl.opengl.GL11;
3736 import org.lwjgl.util.vector.Vector2f;
38 import org.lwjgl.util.glu.GLU;
37
38 import static org.lwjgl.opengl.GL11.*;
39 import static org.lwjgl.util.glu.GLU.*;
3940
4041 /**
4142 * <br>
4243 * Keyboard test
4344 *
4445 * @author Brian Matzon <brian@matzon.dk>
45 * @version $Revision: 3042 $
46 * $Id: KeyboardTest.java 3042 2008-04-22 21:26:39Z elias_naur $
46 * @version $Revision: 3418 $
47 * $Id: KeyboardTest.java 3418 2010-09-28 21:11:35Z spasi $
4748 */
4849 public class KeyboardTest {
4950
6869 System.exit(-1);
6970 }
7071 }
71
72
7273 /**
7374 * Sets the display mode for fullscreen mode
7475 */
8283 "height=" + 480,
8384 "freq=" + 60,
8485 "bpp=" + org.lwjgl.opengl.Display.getDisplayMode().getBitsPerPixel()
85 });
86 });
8687 return true;
8788 } catch (Exception e) {
8889 e.printStackTrace();
8990 }
9091
9192 return false;
92 }
93 }
9394
9495 private void setupDisplay(boolean fullscreen) {
9596 try {
104105 }
105106
106107 private void initializeOpenGL() {
107 GL11.glMatrixMode(GL11.GL_PROJECTION);
108 GL11.glLoadIdentity();
109 GLU.gluOrtho2D(0, Display.getDisplayMode().getWidth(), 0, Display.getDisplayMode().getHeight());
110 GL11.glMatrixMode(GL11.GL_MODELVIEW);
111 GL11.glLoadIdentity();
112 GL11.glViewport(0, 0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight());
113 GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
108 glMatrixMode(GL_PROJECTION);
109 glLoadIdentity();
110 gluOrtho2D(0, Display.getDisplayMode().getWidth(), 0, Display.getDisplayMode().getHeight());
111 glMatrixMode(GL_MODELVIEW);
112 glLoadIdentity();
113 glViewport(0, 0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight());
114 glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
114115 }
115116
116117 public void executeTest() {
158159 System.out.println("Key character code: 0x" + Integer.toHexString(character_code));
159160 System.out.println("Key character: " + Keyboard.getEventCharacter());
160161 System.out.println("Repeat event: " + Keyboard.isRepeatEvent());
161
162
162163 if (Keyboard.getEventKey() == Keyboard.KEY_R && Keyboard.getEventKeyState()) {
163164 Keyboard.enableRepeatEvents(!Keyboard.areRepeatEventsEnabled());
164165 }
208209 }
209210
210211 private void render() {
211 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
212
213 GL11.glBegin(GL11.GL_POLYGON);
212 glClear(GL_COLOR_BUFFER_BIT);
213
214 glBegin(GL_POLYGON);
214215 {
215216 float color = 1.0f;
216 GL11.glColor3f(color, color, color);
217
218 GL11.glVertex2f(position.x + 0.0f, position.y + 0.0f);
219 GL11.glVertex2f(position.x + 0.0f, position.y + 30.0f);
220 GL11.glVertex2f(position.x + 40.0f, position.y + 30.0f);
221 GL11.glVertex2f(position.x + 60.0f, position.y + 15.f);
222 GL11.glVertex2f(position.x + 40.0f, position.y + 0.0f);
223 }
224 GL11.glEnd();
217 glColor3f(color, color, color);
218
219 glVertex2f(position.x + 0.0f, position.y + 0.0f);
220 glVertex2f(position.x + 0.0f, position.y + 30.0f);
221 glVertex2f(position.x + 40.0f, position.y + 30.0f);
222 glVertex2f(position.x + 60.0f, position.y + 15.f);
223 glVertex2f(position.x + 40.0f, position.y + 0.0f);
224 }
225 glEnd();
225226 }
226227
227228 /**
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 */
3434 import org.lwjgl.input.Mouse;
3535 import org.lwjgl.opengl.Display;
3636 import org.lwjgl.opengl.DisplayMode;
37 import org.lwjgl.opengl.GL11;
3837 import org.lwjgl.util.vector.Vector2f;
38
39 import static org.lwjgl.opengl.GL11.*;
3940
4041 /**
4142 * <br>
4243 * Mouse test
4344 *
4445 * @author Brian Matzon <brian@matzon.dk>
45 * @version $Revision: 3108 $
46 * $Id: MouseCreationTest.java 3108 2008-07-02 20:00:49Z matzon $
46 * @version $Revision: 3418 $
47 * $Id: MouseCreationTest.java 3418 2010-09-28 21:11:35Z spasi $
4748 */
4849 public class MouseCreationTest {
4950 /** position of quad to draw */
5051 private Vector2f position = new Vector2f(320.0f, 240.0f);
51
52
5253 /** Creates a new instance of MouseTest */
5354 public MouseCreationTest() {
5455 }
6465 System.exit(-1);
6566 }
6667
67 initializeOpenGL();
68 }
69
68 initializeOpenGL();
69 }
70
7071 /**
7172 * Sets the display mode for fullscreen mode
7273 */
8081 "height=" + 480,
8182 "freq=" + 60,
8283 "bpp=" + org.lwjgl.opengl.Display.getDisplayMode().getBitsPerPixel()
83 });
84 });
8485 return true;
8586 } catch (Exception e) {
8687 e.printStackTrace();
8788 }
8889
8990 return false;
90 }
91
91 }
92
9293 private void initializeOpenGL() {
93 GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
94 glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
9495 // Put the window into orthographic projection mode with 1:1 pixel ratio.
9596 // We haven't used GLU here to do this to avoid an unnecessary dependency.
96 GL11.glMatrixMode(GL11.GL_PROJECTION);
97 GL11.glLoadIdentity();
98 GL11.glOrtho(0.0, Display.getDisplayMode().getWidth(), 0.0, Display.getDisplayMode().getHeight(), -1.0, 1.0);
99 GL11.glMatrixMode(GL11.GL_MODELVIEW);
100 GL11.glLoadIdentity();
101 GL11.glViewport(0, 0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight());
97 glMatrixMode(GL_PROJECTION);
98 glLoadIdentity();
99 glOrtho(0.0, Display.getDisplayMode().getWidth(), 0.0, Display.getDisplayMode().getHeight(), -1.0, 1.0);
100 glMatrixMode(GL_MODELVIEW);
101 glLoadIdentity();
102 glViewport(0, 0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight());
102103 }
103104
104105 public void executeTest() {
105106 initialize(false);
106107
107108 System.out.println("Test ready:\n");
108
109
109110 // windowed mode
110111 System.out.println("=========== WINDOWED MODE ==============");
111112 for(int i=0; i<2; i++) {
113114 wiggleMouse();
114115 System.out.println("");
115116 }
116
117
117118 // recreate display in fullscreen mode
118119 System.out.print("Destroying display...");
119
120
120121 System.out.println("success");
121
122
122123 System.out.print("Entering fullscreen mode...");
123124 try {
124125 Display.destroy();
127128 e.printStackTrace();
128129 }
129130 System.out.println("success");
130
131
131
132
132133 // fullscreen mode
133134 System.out.println("=========== FULLSCREEN MODE ==============");
134135 for(int i=0; i<2; i++) {
136137 wiggleMouse();
137138 System.out.println("");
138139 }
139
140
140141 System.out.println("Test completed successfully!");
141142 System.out.print("Shutting down...");
142143 Display.destroy();
148149
149150 long statustime = Sys.getTime();
150151 long endtime = Sys.getTime() + Sys.getTimerResolution() * 5;
151
152
152153 while (Sys.getTime() < endtime) {
153154 Display.update();
154155
155156 // empty mouse buffer
156157 while(Mouse.next());
157
158
158159 position.x += Mouse.getDX();
159160 position.y += Mouse.getDY();
160
161
161162 if(position.x<0) {
162163 position.x = 0;
163164 } else if (position.x>640-60) {
164165 position.x = 640-60;
165166 }
166
167
167168 if(position.y < 0) {
168169 position.y = 0;
169170 } else if (position.y>480-30) {
170171 position.y = 480-30;
171 }
172 }
172173
173174 render();
174175
179180 }
180181 System.out.println("thank you");
181182 }
182
183
183184 private void render() {
184 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
185
186 GL11.glBegin(GL11.GL_POLYGON);
185 glClear(GL_COLOR_BUFFER_BIT);
186
187 glBegin(GL_POLYGON);
187188 {
188189 float color = 1.0f;
189190 int buttonDown = 0;
190
191
191192 for(int i=0;i<Mouse.getButtonCount(); i++) {
192193 if(Mouse.isButtonDown(i)) {
193 color = (1.0f / Mouse.getButtonCount()) * (i+1);
194 break;
194 color = (1.0f / Mouse.getButtonCount()) * (i+1);
195 break;
195196 }
196197 }
197 GL11.glColor3f(color, color, color);
198
199 GL11.glVertex2f(position.x + 0.0f, position.y + 0.0f);
200 GL11.glVertex2f(position.x + 0.0f, position.y + 30.0f);
201 GL11.glVertex2f(position.x + 40.0f, position.y + 30.0f);
202 GL11.glVertex2f(position.x + 60.0f, position.y + 15.f);
203 GL11.glVertex2f(position.x + 40.0f, position.y + 0.0f);
204 }
205 GL11.glEnd();
198 glColor3f(color, color, color);
199
200 glVertex2f(position.x + 0.0f, position.y + 0.0f);
201 glVertex2f(position.x + 0.0f, position.y + 30.0f);
202 glVertex2f(position.x + 40.0f, position.y + 30.0f);
203 glVertex2f(position.x + 60.0f, position.y + 15.f);
204 glVertex2f(position.x + 40.0f, position.y + 0.0f);
205 }
206 glEnd();
206207 }
207208
208209 /**
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 */
3434 import org.lwjgl.input.Mouse;
3535 import org.lwjgl.opengl.Display;
3636 import org.lwjgl.opengl.DisplayMode;
37 import org.lwjgl.opengl.GL11;
38 import org.lwjgl.util.glu.GLU;
3937 import org.lwjgl.util.vector.Vector2f;
4038 import org.lwjgl.util.vector.Vector3f;
39
40 import static org.lwjgl.opengl.GL11.*;
41 import static org.lwjgl.util.glu.GLU.*;
4142
4243 /**
4344 * <br>
4445 * Mouse test
4546 *
4647 * @author Brian Matzon <brian@matzon.dk>
47 * @version $Revision: 3240 $
48 * $Id: MouseTest.java 3240 2009-09-12 22:15:21Z matzon $
48 * @version $Revision: 3418 $
49 * $Id: MouseTest.java 3418 2010-09-28 21:11:35Z spasi $
4950 */
5051 public class MouseTest {
5152 /** Direction mouse has moved */
5253 private int direction;
53
54
5455 /** Last button pressed */
55 private int lastButton = 0;
56
56 private int lastButton;
57
5758 /** Last direction we scrolled in */
5859 private int lastScrollDirection = -1;
59
60
6061 /** Width of window */
6162 private static int WINDOW_WIDTH = 640;
62
63
6364 /** Height of window */
6465 private static int WINDOW_HEIGHT = 640;
65
66
6667 /** Triangle size */
6768 private Vector2f triangleSize = new Vector2f(120, 100);
68
69
6970 /** Triangle color */
70 private Vector3f triangleColor[] = new Vector3f[] {
71 private Vector3f triangleColors[] = new Vector3f[] {
7172 new Vector3f(1,1,1),
7273 new Vector3f(1,0,0),
7374 new Vector3f(0,1,0),
7475 new Vector3f(0,0,1)
7576 };
76
77 private Vector3f quadColor[] = new Vector3f[] {
77
78 private Vector3f quadColors[] = new Vector3f[] {
7879 new Vector3f(1,1,1),
7980 new Vector3f(1,0,0),
8081 new Vector3f(0,1,0),
8182 new Vector3f(0,0,1)
8283 };
83
84
8485 /** Triangles to paint */
85 private Vector2f[] triangles = {
86 private Vector2f[] triangles = {
8687 new Vector2f(WINDOW_WIDTH/2, WINDOW_HEIGHT - triangleSize.y),
8788 new Vector2f(triangleSize.y, WINDOW_HEIGHT/2),
8889 new Vector2f(WINDOW_WIDTH/2, triangleSize.y),
9091 };
9192
9293 /** Whether the test is closing */
93 private boolean closing = false;
94
94 private boolean closing;
95
9596 /** Fullscreen or not */
9697 public static final boolean FULLSCREEN = false;
97
98
9899 /** Creates a new instance of MouseTest */
99100 public MouseTest() {
100101 }
106107 setupMouse();
107108 setupKeyboard();
108109 }
109
110
110111 /**
111112 * Setup display
112113 */
122123 System.exit(-1);
123124 }
124125
125 initializeOpenGL();
126 }
127
126 initializeOpenGL();
127 }
128
128129 /**
129130 * Sets the display mode for fullscreen mode
130131 */
131132 protected boolean setDisplayMode() {
132133 // get modes
133134 DisplayMode dm = new DisplayMode(WINDOW_WIDTH, WINDOW_HEIGHT);
134
135
135136 try {
136137 Display.setDisplayMode(dm);
137138 return true;
140141 }
141142
142143 return false;
143 }
144 }
144145
145146 /**
146147 * Initializes OpenGL
147148 *
148149 */
149150 private void initializeOpenGL() {
150 GL11.glMatrixMode(GL11.GL_PROJECTION);
151 GL11.glLoadIdentity();
152 GLU.gluOrtho2D(0, Display.getDisplayMode().getWidth(), 0, Display.getDisplayMode().getHeight());
153 GL11.glMatrixMode(GL11.GL_MODELVIEW);
154 GL11.glLoadIdentity();
155 GL11.glViewport(0, 0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight());
156 GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
151 glMatrixMode(GL_PROJECTION);
152 glLoadIdentity();
153 gluOrtho2D(0, Display.getDisplayMode().getWidth(), 0, Display.getDisplayMode().getHeight());
154 glMatrixMode(GL_MODELVIEW);
155 glLoadIdentity();
156 glViewport(0, 0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight());
157 glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
157158 }
158159
159160 /**
172173 */
173174 private void setupMouse() {
174175 }
175
176
176177 /**
177178 * Creates the keyboard
178179 */
186187 // while not exiting
187188 while (!closing) {
188189 handleWindow();
189
190
190191 // secondary check
191192 if(!closing) {
192
193
193194 // poll and check keyboard and mouse
194195 handleKeyboard();
195196 handleMouse();
196
197
197198 // pause and continue if minimized
198199 if(!Display.isVisible()) {
199200 if(Display.isDirty()) {
200201 render();
201 }
202 }
202203 pause(100);
203204 continue;
204205 }
213214
214215 /**
215216 * Pauses the current thread for a specified time
216 *
217 *
217218 * @param time milliseconds to pause
218219 */
219220 private void pause(long time) {
231232 Display.update();
232233 closing = Display.isCloseRequested();
233234 }
234
235
235236 /**
236237 * handles the mouse
237238 */
238239 private void handleMouse() {
239240 readBufferedMouse();
240
241
241242 Display.setTitle("x: " + Mouse.getX() + ", y: " + Mouse.getY() + ", [0]: " + Mouse.isButtonDown(0) + ", [1]: " + Mouse.isButtonDown(1) + ", [2]: " + Mouse.isButtonDown(2) + ", inside: " + Mouse.isInsideWindow());
242243 }
243
244
244245 /**
245246 * reads a mouse in buffered mode
246247 */
250251 if(Mouse.getEventButton() != -1 && Mouse.getEventButtonState()) {
251252 lastButton = Mouse.getEventButton();
252253 }
253 }
254
254 }
255
255256 updateState();
256257 }
257
258
258259 /**
259260 * Updates our "model"
260261 *
265266 int dx = Mouse.getDX();
266267 int dy = Mouse.getDY();
267268 int dw = Mouse.getDWheel();
268
269
269
270
270271 // get out if no movement
271272 if (dx == dy && dx == 0 && dw == 0) {
272273 return;
273274 }
274
275
275276 // determine direction moved
276277 // ============================
277278 if(dx > 0) {
278279 direction = 3;
279280 }
280
281
281282 if(dx < 0) {
282283 direction = 1;
283284 }
284
285
285286 if(dy > 0) {
286287 direction = 0;
287288 }
288
289
289290 if(dy < 0) {
290291 direction = 2;
291292 }
292
293
293294 // ----------------------------
294295 if(direction > -1) {
295296
298299 case -1:
299300 break;
300301 case 1:
301 triangleColor[direction].y = 1;
302 triangleColors[direction].y = 1;
302303 break;
303304 case 2:
304 triangleColor[direction].z = 1;
305 triangleColors[direction].z = 1;
305306 break;
306307 case 3:
307 triangleColor[direction].x = 1;
308 triangleColor[direction].y = 1;
309 triangleColor[direction].z = 1;
308 triangleColors[direction].x = 1;
309 triangleColors[direction].y = 1;
310 triangleColors[direction].z = 1;
310311 break;
311312 case 0: // fall through
312313 default:
313 triangleColor[direction].x = 1;
314 triangleColors[direction].x = 1;
314315 break;
315316 }
316317 }
317
318
318319 // get direction to update in
319320 if (dw > 0) {
320321 lastScrollDirection++;
323324 } else if (dw == 0) {
324325 return;
325326 }
326
327
327328 // over/underflow
328329 if(lastScrollDirection < 0) {
329330 lastScrollDirection = 3;
333334 }
334335
335336 // update colors
336 quadColor[lastScrollDirection].x = (float) Math.random();
337 quadColor[lastScrollDirection].y = (float) Math.random();
338 quadColor[lastScrollDirection].z = (float) Math.random();
339 }
340
337 quadColors[lastScrollDirection].x = (float) Math.random();
338 quadColors[lastScrollDirection].y = (float) Math.random();
339 quadColors[lastScrollDirection].z = (float) Math.random();
340 }
341
341342 /**
342343 * Handles the keyboard
343344 */
344345 private void handleKeyboard() {
345
346
346347 while(Keyboard.next()) {
347348 // closing on ESCAPE
348349 if(Keyboard.getEventKey() == Keyboard.KEY_ESCAPE && Keyboard.getEventKeyState()) {
349350 closing = true;
350351 }
351
352
352353 if(Keyboard.getEventKey() == Keyboard.KEY_SPACE && Keyboard.getEventKeyState()) {
353354 Mouse.setGrabbed(!Mouse.isGrabbed());
354355 }
355356 }
356357 }
357
358
358359 /**
359360 * Does the "model logic"
360361 */
361362 private void logic() {
362363 // "we fade to black"
363364 // ===========================================
364 for(int i=0; i<triangleColor.length; i++) {
365 triangleColor[i].x -= 0.01;
366 triangleColor[i].y -= 0.01;
367 triangleColor[i].z -= 0.01;
368 }
369
370 for(int i=0; i<quadColor.length; i++) {
371 quadColor[i].x -= 0.01;
372 quadColor[i].y -= 0.01;
373 quadColor[i].z -= 0.01;
374 }
365 for ( Vector3f color : triangleColors ) {
366 color.x -= 0.01;
367 color.y -= 0.01;
368 color.z -= 0.01;
369 }
370
371 for ( Vector3f color : quadColors ) {
372 color.x -= 0.01;
373 color.y -= 0.01;
374 color.z -= 0.01;
375 }
375376 // -------------------------------------------
376377 }
377
378
378379 /**
379380 * Render our triangles
380381 */
381382 private void render() {
382 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
383 glClear(GL_COLOR_BUFFER_BIT);
383384
384385 // for each triangle, render it at position, rotating degrees for each
385386 for(int i=0; i<triangles.length; i++) {
386 GL11.glPushMatrix(); {
387 GL11.glTranslatef(triangles[i].x, triangles[i].y, 0);
388 GL11.glRotatef(i*90, 0, 0, 1);
389
390 GL11.glColor3f(triangleColor[i].x, triangleColor[i].y, triangleColor[i].z);
391
392 GL11.glBegin(GL11.GL_TRIANGLES); {
393 GL11.glVertex2f(0, triangleSize.y);
394 GL11.glVertex2f(-triangleSize.x, -triangleSize.y);
395 GL11.glVertex2f(+triangleSize.x, -triangleSize.y);
387 glPushMatrix(); {
388 glTranslatef(triangles[i].x, triangles[i].y, 0);
389 glRotatef(i*90, 0, 0, 1);
390
391 glColor3f(triangleColors[i].x, triangleColors[i].y, triangleColors[i].z);
392
393 glBegin(GL_TRIANGLES); {
394 glVertex2f(0, triangleSize.y);
395 glVertex2f(-triangleSize.x, -triangleSize.y);
396 glVertex2f(+triangleSize.x, -triangleSize.y);
396397 }
397 GL11.glEnd();
398 }
399 GL11.glPopMatrix();
400 }
401
398 glEnd();
399 }
400 glPopMatrix();
401 }
402
402403 // paint quad in the middle (yes, wasting cpu cycles by not precalculating)
403 GL11.glBegin(GL11.GL_QUADS); {
404 GL11.glColor3f(quadColor[0].x, quadColor[0].y, quadColor[0].z);
405 GL11.glVertex2f(WINDOW_WIDTH/2-triangleSize.x, WINDOW_HEIGHT/2-triangleSize.x);
406 GL11.glColor3f(quadColor[1].x, quadColor[1].y, quadColor[1].z);
407 GL11.glVertex2f(WINDOW_WIDTH/2+triangleSize.x, WINDOW_HEIGHT/2-triangleSize.x);
408 GL11.glColor3f(quadColor[2].x, quadColor[2].y, quadColor[2].z);
409 GL11.glVertex2f(WINDOW_WIDTH/2+triangleSize.x, WINDOW_HEIGHT/2+triangleSize.x);
410 GL11.glColor3f(quadColor[3].x, quadColor[3].y, quadColor[3].z);
411 GL11.glVertex2f(WINDOW_WIDTH/2-triangleSize.x, WINDOW_HEIGHT/2+triangleSize.x);
412 }
413 GL11.glEnd();
404 glBegin(GL_QUADS); {
405 glColor3f(quadColors[0].x, quadColors[0].y, quadColors[0].z);
406 glVertex2f(WINDOW_WIDTH/2-triangleSize.x, WINDOW_HEIGHT/2-triangleSize.x);
407 glColor3f(quadColors[1].x, quadColors[1].y, quadColors[1].z);
408 glVertex2f(WINDOW_WIDTH/2+triangleSize.x, WINDOW_HEIGHT/2-triangleSize.x);
409 glColor3f(quadColors[2].x, quadColors[2].y, quadColors[2].z);
410 glVertex2f(WINDOW_WIDTH/2+triangleSize.x, WINDOW_HEIGHT/2+triangleSize.x);
411 glColor3f(quadColors[3].x, quadColors[3].y, quadColors[3].z);
412 glVertex2f(WINDOW_WIDTH/2-triangleSize.x, WINDOW_HEIGHT/2+triangleSize.x);
413 }
414 glEnd();
414415 }
415416
416417 /**
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 */
4444
4545 /**
4646 * Oops. Forgot to document this one.
47 *
47 *
4848 * @author Kevin Glass
4949 */
5050 public class TestControllers extends JPanel {
51 public static int total = 0;
52
51 public static int total;
52
5353 private JTextField[] values;
5454 private JTextField[] names;
5555 private Controller controller;
5656 private int buttonCount;
5757 private int itemCount;
58
58
5959 public TestControllers(int index) {
6060 controller = Controllers.getController(index);
6161 setLayout(null);
62
62
6363 buttonCount = controller.getButtonCount();
6464 itemCount = controller.getButtonCount() + controller.getAxisCount() + 2;
6565 values = new JTextField[itemCount];
6666 names = new JTextField[itemCount];
67
67
6868 for (int i=0;i<controller.getButtonCount();i++) {
6969 names[i] = new JTextField();
7070 names[i].setEditable(false);
8787 values[i].setBounds(100,i*30,100,30);
8888 add(values[i]);
8989 }
90
90
9191 int i = itemCount - 2;
9292 names[i] = new JTextField();
9393 names[i].setEditable(false);
109109 values[i].setEditable(false);
110110 values[i].setBounds(100,i*30,100,30);
111111 add(values[i]);
112
112
113113 total++;
114
114
115115 setPreferredSize(new Dimension(200,30*itemCount));
116116 JFrame frame = new JFrame(controller.getName());
117117 frame.setContentPane(new JScrollPane(this));
127127 frame.setLocation(index*30,index*30);
128128 frame.setVisible(true);
129129 }
130
130
131131 public void updateDetails() {
132132 for (int i=0;i<controller.getButtonCount();i++) {
133133 values[i].setText(""+controller.isButtonPressed(i));
135135 for (int i=buttonCount;i<buttonCount+controller.getAxisCount();i++) {
136136 values[i].setText(""+controller.getAxisValue(i-buttonCount));
137137 }
138
138
139139 values[itemCount-2].setText(""+controller.getPovX());
140140 values[itemCount-1].setText(""+controller.getPovY());
141141 }
142
142
143143 public static void main(String[] argv) {
144144 try {
145145 Controllers.create();
147147 e.printStackTrace();
148148 System.exit(0);
149149 }
150
150
151151 int count = Controllers.getControllerCount();
152152 System.out.println(count+" Controllers Found");
153153 for (int i=0;i<count;i++) {
154154 Controller controller = Controllers.getController(i);
155155 System.out.println(controller.getName());
156156 }
157
157
158158 if (count == 0) {
159159 System.exit(0);
160160 }
161
161
162162 TestControllers[] controllerWindows = new TestControllers[count];
163163 for (int i=0;i<count;i++) {
164164 controllerWindows[i] = new TestControllers(i);
165165 }
166
166
167167 boolean running = true;
168168 while (running) {
169169 try { Thread.sleep(100); } catch (Exception e) {};
170
170
171171 Controllers.poll();
172172
173173 while (Controllers.next()) {
176176 System.out.println("\t"+Controllers.getEventSource()+":"+Controllers.getEventControlIndex()+":"+Controllers.isEventButton());
177177 System.out.println("\t"+Controllers.isEventXAxis()+":"+Controllers.isEventYAxis());
178178 }
179
179
180180 for (int i=0;i<count;i++) {
181181 controllerWindows[i].updateDetails();
182182 }
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 */
4343 * This is a basic test, which contains the most used stuff
4444 *
4545 * @author Brian Matzon <brian@matzon.dk>
46 * @version $Revision: 2983 $
47 * $Id: BasicTest.java 2983 2008-04-07 18:36:09Z matzon $
46 * @version $Revision: 3418 $
47 * $Id: BasicTest.java 3418 2010-09-28 21:11:35Z spasi $
4848 */
4949 public abstract class BasicTest {
5050
5151 /**
5252 * Creates an instance of PlayTest
5353 */
54 public BasicTest() {
54 protected BasicTest() {
5555 try {
5656 AL.create();
57
57
5858 System.out.println("Default device: " + ALC10.alcGetString(null, ALC10.ALC_DEFAULT_DEVICE_SPECIFIER));
59
59
6060 if(ALC10.alcIsExtensionPresent(null, "ALC_ENUMERATION_EXT")) {
6161 String[] devices = ALC10.alcGetString(null, ALC10.ALC_DEVICE_SPECIFIER).split("\0");
6262 System.out.println("Available devices: ");
7878 AL.destroy();
7979 }
8080 }
81
81
8282 /**
8383 * Creates a float buffer to hold specified float array
8484 * - strictly a utility method
9090 FloatBuffer temp = BufferUtils.createFloatBuffer(data.length).put(data);
9191 temp.flip();
9292 return temp;
93 }
94
93 }
94
9595 /**
9696 * Pauses the invoking thread for specified milliseconds
97 *
97 *
9898 * @param time Milliseconds to sleep
9999 */
100100 protected void pause(long time) {
101101 try {
102 Thread.sleep(time);
102 Thread.sleep(time);
103103 } catch (InterruptedException inte) {
104104 }
105105 }
114114 alExit();
115115 System.exit(-1);
116116 }
117
117
118118 /**
119119 * Sets the display mode for fullscreen mode
120120 */
128128 "height=" + 480,
129129 "freq=" + 60,
130130 "bpp=" + org.lwjgl.opengl.Display.getDisplayMode().getBitsPerPixel()
131 });
131 });
132132 return true;
133133 } catch (Exception e) {
134134 e.printStackTrace();
135135 }
136136
137137 return false;
138 }
138 }
139139 }
289289 // Create a source and buffer audio data
290290 final int source = AL10.alGenSources();
291291 final int buffer = AL10.alGenBuffers();
292 WaveData waveFile = WaveData.create(WaveData.class.getClassLoader().getResourceAsStream("Footsteps.wav"));
292 WaveData waveFile = WaveData.create("Footsteps.wav");
293293 if (waveFile == null) {
294294 System.out.println("Failed to load Footsteps.wav! Skipping playback test.");
295295 AL.destroy();
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 */
7373 } catch (LWJGLException le) {
7474 die("Init", le.getMessage());
7575 }
76
76
7777 printALCInfo();
7878 printALInfo();
7979 printEFXInfo();
80
80
8181 checkForErrors();
82
82
8383 AL.destroy();
8484 }
85
85
8686 private void printALCInfo() {
8787 IntBuffer version = BufferUtils.createIntBuffer(2);
8888 ALCdevice device;
89
89
9090 if(ALC10.alcIsExtensionPresent(null, "ALC_ENUMERATION_EXT")) {
9191 if(ALC10.alcIsExtensionPresent(null, "ALC_ENUMERATE_ALL_EXT")) {
9292 printDevices(ALC11.ALC_ALL_DEVICES_SPECIFIER, "playback");
9797 } else {
9898 System.out.println("No device enumeration available");
9999 }
100
100
101101 device = ALC10.alcGetContextsDevice(ALC10.alcGetCurrentContext());
102102 checkForErrors();
103
103
104104 System.out.println("Default playback device: " + ALC10.alcGetString(device, ALC10.ALC_DEFAULT_DEVICE_SPECIFIER));
105105
106106 System.out.println("Default capture device: " + ALC10.alcGetString(device, ALC11.ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER));
109109 ALC10.alcGetInteger(AL.getDevice(), ALC10.ALC_MINOR_VERSION, (IntBuffer) version.position(1));
110110 checkForErrors();
111111
112 System.out.println("ALC version: " + (int)version.get(0) + "." + (int)version.get(1));
112 System.out.println("ALC version: " + version.get(0) + "." + version.get(1));
113113
114114 System.out.println("ALC extensions:");
115115 String[] extensions = ALC10.alcGetString(device, ALC10.ALC_EXTENSIONS).split(" ");
116 for(int i=0; i<extensions.length; i++) {
117 if(extensions[i].trim().length() == 0) {
116 for ( String extension : extensions ) {
117 if ( extension.trim().length() == 0 ) {
118118 continue;
119119 }
120 System.out.println(" " + extensions[i]);
120 System.out.println(" " + extension);
121121 }
122122 checkForErrors();
123123 }
124
124
125125 private void printALInfo() {
126126 System.out.println("OpenAL vendor string: " + AL10.alGetString(AL10.AL_VENDOR));
127127 System.out.println("OpenAL renderer string: " + AL10.alGetString(AL10.AL_RENDERER));
128128 System.out.println("OpenAL version string: " + AL10.alGetString(AL10.AL_VERSION));
129129 System.out.println("AL extensions:");
130130 String[] extensions = AL10.alGetString(AL10.AL_EXTENSIONS).split(" ");
131 for(int i=0; i<extensions.length; i++) {
132 if(extensions[i].trim().length() == 0) {
131 for ( String extension : extensions ) {
132 if ( extension.trim().length() == 0 ) {
133133 continue;
134134 }
135 System.out.println(" " + extensions[i]);
136 }
137 checkForErrors();
138 }
139
135 System.out.println(" " + extension);
136 }
137 checkForErrors();
138 }
139
140140 private void printEFXInfo() {
141141 if(!EFXUtil.isEfxSupported()) {
142142 System.out.println("EFX not available");
143143 return;
144144 }
145
146 ALCdevice device = AL.getDevice();
145
146 ALCdevice device = AL.getDevice();
147147 IntBuffer major = BufferUtils.createIntBuffer(1);
148148 IntBuffer minor = BufferUtils.createIntBuffer(1);
149149 IntBuffer sends = BufferUtils.createIntBuffer(1);
152152 if(ALC10.alcGetError(device) == ALC10.ALC_NO_ERROR) {
153153 System.out.println("EFX version: " + major.get() + "." + minor.get());
154154 }
155
155
156156 ALC10.alcGetInteger(device, EFX10.ALC_MAX_AUXILIARY_SENDS, sends);
157157 if(ALC10.alcGetError(device) == ALC10.ALC_NO_ERROR) {
158158 System.out.println("Max auxiliary sends: " + sends.get());
159159 }
160
160
161161 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
162 HashMap<String, Integer> filters = new HashMap<String, Integer>();
163 filters.put("Low-pass", EFX10.AL_FILTER_LOWPASS);
164 filters.put("High-pass", EFX10.AL_FILTER_HIGHPASS);
165 filters.put("Band-pass", EFX10.AL_FILTER_BANDPASS);
166
167 Set<Entry<String, Integer>> entries = filters.entrySet();
168 for ( final Entry<String, Integer> entry : entries ) {
169 String key = entry.getKey();
170 if ( EFXUtil.isFilterSupported(entry.getValue()) )
171 System.out.println(" " + entry.getKey());
172 }
173
177174 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));
175 HashMap<String, Integer> effects = new HashMap<String, Integer>();
176 effects.put("EAX Reverb", EFX10.AL_EFFECT_EAXREVERB);
177 effects.put("Reverb", EFX10.AL_EFFECT_REVERB);
178 effects.put("Chorus", EFX10.AL_EFFECT_CHORUS);
179 effects.put("Distortion", EFX10.AL_EFFECT_DISTORTION);
180 effects.put("Echo", EFX10.AL_EFFECT_ECHO);
181 effects.put("Flanger", EFX10.AL_EFFECT_FLANGER);
182 effects.put("Frequency Shifter", EFX10.AL_EFFECT_FREQUENCY_SHIFTER);
183 effects.put("Vocal Morpher", EFX10.AL_EFFECT_VOCAL_MORPHER);
184 effects.put("Pitch Shifter", EFX10.AL_EFFECT_PITCH_SHIFTER);
185 effects.put("Ring Modulator", EFX10.AL_EFFECT_RING_MODULATOR);
186 effects.put("Autowah", EFX10.AL_EFFECT_AUTOWAH);
187 effects.put("Compressor", EFX10.AL_EFFECT_COMPRESSOR);
188 effects.put("Equalizer", EFX10.AL_EFFECT_EQUALIZER);
192189
193190 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
191 for ( final Entry<String, Integer> entry : entries ) {
192 if ( EFXUtil.isEffectSupported(entry.getValue()) )
193 System.out.println(" " + entry.getKey());
194 }
195 }
196
204197 private void printDevices(int which, String kind) {
205198 String[] devices = ALC10.alcGetString(null, which).split("\0");
206199 checkForErrors();
207
200
208201 System.out.println("Available " + kind + " devices: ");
209 for(int i=0; i<devices.length; i++) {
210 System.out.println(" " + devices[i]);
202 for ( String device : devices ) {
203 System.out.println(" " + device);
211204 }
212205 }
213206
214207 private void die(String kind, String description) {
215208 System.out.println(kind + " error " + description + " occured");
216209 }
217
210
218211 private void checkForErrors() {
219212 {
220213 ALCdevice device = ALC10.alcGetContextsDevice(ALC10.alcGetCurrentContext());
228221 if(error != AL10.AL_NO_ERROR) {
229222 die("AL", AL10.alGetString(error));
230223 }
231 }
232 }
233
224 }
225 }
226
234227 /**
235228 * main entry point
236229 *
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 */
3838 import org.lwjgl.input.Keyboard;
3939 import org.lwjgl.input.Mouse;
4040 import org.lwjgl.openal.AL;
41 import org.lwjgl.openal.AL10;
4241 import org.lwjgl.opengl.Display;
43 import org.lwjgl.opengl.GL11;
44 import org.lwjgl.util.glu.GLU;
4542 import org.lwjgl.util.WaveData;
43
44 import static org.lwjgl.openal.AL10.*;
45 import static org.lwjgl.opengl.GL11.*;
46 import static org.lwjgl.util.glu.GLU.*;
4647
4748 /**
4849 * <br>
49 * This test demonstrates OpenAL positioning Based on the example by Chad Armstrong
50 * This test demonstrates OpenAL positioning Based on the example by Chad Armstrong
5051 * (http://www.edenwaith.com/products/pige/tutorials/openal.php)
51 *
52 *
5253 * @author Brian Matzon <brian@matzon.dk>
53 * @version $Revision: 2983 $
54 * $Id: PositionTest.java 2983 2008-04-07 18:36:09Z matzon $
54 * @version $Revision: 3418 $
55 * $Id: PositionTest.java 3418 2010-09-28 21:11:35Z spasi $
5556 */
5657 public class PositionTest extends BasicTest {
5758
7475 public static final int RIGHT = 2;
7576
7677 /** Whether the demo is done */
77 private boolean finished = false;
78
78 private boolean finished;
79
7980 /** Whether in pause mode */
80 private boolean pauseMode = false;
81 private boolean pauseMode;
8182
8283 // OpenAL stuff
8384 // ===================================================
159160 // =====================================================
160161 LWJGLUtil.log("Setting up OpenGL");
161162
162 GL11.glViewport(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT);
163 GL11.glMatrixMode(GL11.GL_PROJECTION);
164 GL11.glLoadIdentity();
165 GLU.gluPerspective(50.0f, (float) WINDOW_WIDTH / WINDOW_HEIGHT, 0.0f, 50.0f);
166 GL11.glMatrixMode(GL11.GL_MODELVIEW);
167 GL11.glLoadIdentity();
168 GL11.glTranslatef(0.0f, 0.0f, -6.6f);
169 GL11.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
163 glViewport(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT);
164 glMatrixMode(GL_PROJECTION);
165 glLoadIdentity();
166 gluPerspective(50.0f, (float) WINDOW_WIDTH / WINDOW_HEIGHT, 0.0f, 50.0f);
167 glMatrixMode(GL_MODELVIEW);
168 glLoadIdentity();
169 glTranslatef(0.0f, 0.0f, -6.6f);
170 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
170171 glut = this.new GLUT();
171172
172173 Display.setVSyncEnabled(true);
176177 // =====================================================
177178 LWJGLUtil.log("Setting up OpenAL");
178179
179 AL10.alListener(AL10.AL_POSITION, listenerPosition);
180 AL10.alListener(AL10.AL_VELOCITY, listenerVelocity);
181 AL10.alListener(AL10.AL_ORIENTATION, listenerOrientation);
180 alListener(AL_POSITION, listenerPosition);
181 alListener(AL_VELOCITY, listenerVelocity);
182 alListener(AL_ORIENTATION, listenerOrientation);
182183
183184 // creating buffers
184185 LWJGLUtil.log("Creating buffers");
185 AL10.alGenBuffers(soundBuffers);
186 alGenBuffers(soundBuffers);
186187 soundBuffers.rewind();
187188
188189 // creating sources
189 AL10.alGenSources(soundSources);
190 alGenSources(soundSources);
190191 soundSources.rewind();
191192
192193 // load sound files (left, center, right).wav
194195
195196 LWJGLUtil.log("Loading left.wav");
196197 WaveData left = WaveData.create("left.wav");
197 AL10.alBufferData(soundBuffers.get(LEFT), left.format, left.data, left.samplerate);
198 AL10.alSourcef(soundSources.get(LEFT), AL10.AL_PITCH, 1.0f);
199 AL10.alSourcef(soundSources.get(LEFT), AL10.AL_GAIN, 1.0f);
200 AL10.alSource(soundSources.get(LEFT), AL10.AL_POSITION, leftPosition);
201 AL10.alSource(soundSources.get(LEFT), AL10.AL_VELOCITY, leftVelocity);
202 AL10.alSourcei(soundSources.get(LEFT), AL10.AL_BUFFER, soundBuffers.get(LEFT));
203 AL10.alSourcei(soundSources.get(LEFT), AL10.AL_LOOPING, AL10.AL_TRUE);
198 alBufferData(soundBuffers.get(LEFT), left.format, left.data, left.samplerate);
199 alSourcef(soundSources.get(LEFT), AL_PITCH, 1.0f);
200 alSourcef(soundSources.get(LEFT), AL_GAIN, 1.0f);
201 alSource(soundSources.get(LEFT), AL_POSITION, leftPosition);
202 alSource(soundSources.get(LEFT), AL_VELOCITY, leftVelocity);
203 alSourcei(soundSources.get(LEFT), AL_BUFFER, soundBuffers.get(LEFT));
204 alSourcei(soundSources.get(LEFT), AL_LOOPING, AL_TRUE);
204205
205206 LWJGLUtil.log("Loading center.wav");
206207 WaveData center = WaveData.create("center.wav");
207 AL10.alBufferData(soundBuffers.get(CENTER), center.format, center.data, center.samplerate);
208 AL10.alSourcef(soundSources.get(CENTER), AL10.AL_PITCH, 1.0f);
209 AL10.alSourcef(soundSources.get(CENTER), AL10.AL_GAIN, 1.0f);
210 AL10.alSource(soundSources.get(CENTER), AL10.AL_POSITION, centerPosition);
211 AL10.alSource(soundSources.get(CENTER), AL10.AL_VELOCITY, centerVelocity);
212 AL10.alSourcei(soundSources.get(CENTER), AL10.AL_BUFFER, soundBuffers.get(CENTER));
213 AL10.alSourcei(soundSources.get(CENTER), AL10.AL_LOOPING, AL10.AL_TRUE);
208 alBufferData(soundBuffers.get(CENTER), center.format, center.data, center.samplerate);
209 alSourcef(soundSources.get(CENTER), AL_PITCH, 1.0f);
210 alSourcef(soundSources.get(CENTER), AL_GAIN, 1.0f);
211 alSource(soundSources.get(CENTER), AL_POSITION, centerPosition);
212 alSource(soundSources.get(CENTER), AL_VELOCITY, centerVelocity);
213 alSourcei(soundSources.get(CENTER), AL_BUFFER, soundBuffers.get(CENTER));
214 alSourcei(soundSources.get(CENTER), AL_LOOPING, AL_TRUE);
214215
215216 LWJGLUtil.log("Loading right.wav");
216217 WaveData right = WaveData.create("right.wav");
217 AL10.alBufferData(soundBuffers.get(RIGHT), right.format, right.data, right.samplerate);
218 AL10.alSourcef(soundSources.get(RIGHT), AL10.AL_PITCH, 1.0f);
219 AL10.alSourcef(soundSources.get(RIGHT), AL10.AL_GAIN, 1.0f);
220 AL10.alSource(soundSources.get(RIGHT), AL10.AL_POSITION, rightPosition);
221 AL10.alSource(soundSources.get(RIGHT), AL10.AL_VELOCITY, rightVelocity);
222 AL10.alSourcei(soundSources.get(RIGHT), AL10.AL_BUFFER, soundBuffers.get(RIGHT));
223 AL10.alSourcei(soundSources.get(RIGHT), AL10.AL_LOOPING, AL10.AL_TRUE);
218 alBufferData(soundBuffers.get(RIGHT), right.format, right.data, right.samplerate);
219 alSourcef(soundSources.get(RIGHT), AL_PITCH, 1.0f);
220 alSourcef(soundSources.get(RIGHT), AL_GAIN, 1.0f);
221 alSource(soundSources.get(RIGHT), AL_POSITION, rightPosition);
222 alSource(soundSources.get(RIGHT), AL_VELOCITY, rightVelocity);
223 alSourcei(soundSources.get(RIGHT), AL_BUFFER, soundBuffers.get(RIGHT));
224 alSourcei(soundSources.get(RIGHT), AL_LOOPING, AL_TRUE);
224225
225226 LWJGLUtil.log("Soundfiles loaded successfully");
226227 // -----------------------------------------------------
227
228
228229 Mouse.setGrabbed(true);
229230 }
230231
259260
260261 // allow window to process internal messages
261262 Display.update();
262
263
263264 // render and paint if !minimized and not dirty
264265 if(Display.isVisible()) {
265266 render();
267268 // sleeeeeep
268269 pause(100);
269270 }
270
271
271272 // act on pause mode
272273 paused(!(Display.isVisible() || Display.isActive()));
273
274
274275 // start sound after first paint, since we don't want
275276 // the delay before something is painted on the screen
276277 if (firstRun && !pauseMode) {
281282 }
282283 }
283284 }
284
285
285286 /**
286287 * Starts playing the sounds at different times
287288 */
288289 private void startSounds() {
289 AL10.alSourcePlay(soundSources.get(LEFT));
290 alSourcePlay(soundSources.get(LEFT));
290291 pause(300);
291 AL10.alSourcePlay(soundSources.get(CENTER));
292 alSourcePlay(soundSources.get(CENTER));
292293 pause(500);
293 AL10.alSourcePlay(soundSources.get(RIGHT));
294 }
295
294 alSourcePlay(soundSources.get(RIGHT));
295 }
296
296297 /**
297298 * Handles any changes in pause mode
298 *
299 *
299300 * @param paused Which pause mode to enter
300301 */
301302 private void paused(boolean paused) {
302303 // if requesting pause, and not paused - pause and stop sound
303304 if(paused && !pauseMode) {
304305 pauseMode = true;
305 AL10.alSourcePause(soundSources);
306 alSourcePause(soundSources);
306307 System.out.println("pauseMode = true");
307 }
308
308 }
309
309310 // else go out of pause mode and start sounds
310311 else if(!paused && pauseMode) {
311312 pauseMode = false;
312313 startSounds();
313314 System.out.println("pauseMode = false");
314 }
315 }
315316 }
316317
317318 /**
329330 // Test for play
330331 // ============================================
331332 if (Keyboard.isKeyDown(Keyboard.KEY_1)) {
332 AL10.alSourcePlay(soundSources.get(LEFT));
333 alSourcePlay(soundSources.get(LEFT));
333334 LWJGLUtil.log("Playing left.wav");
334335 }
335336
336337 if (Keyboard.isKeyDown(Keyboard.KEY_2)) {
337 AL10.alSourcePlay(soundSources.get(CENTER));
338 alSourcePlay(soundSources.get(CENTER));
338339 LWJGLUtil.log("Playing center.wav");
339340 }
340341
341342 if (Keyboard.isKeyDown(Keyboard.KEY_3)) {
342 AL10.alSourcePlay(soundSources.get(RIGHT));
343 alSourcePlay(soundSources.get(RIGHT));
343344 LWJGLUtil.log("Playing right.wav");
344345 }
345346 // --------------------------------------------
347348 // Test for stop
348349 // ============================================
349350 if (Keyboard.isKeyDown(Keyboard.KEY_4)) {
350 AL10.alSourceStop(soundSources.get(LEFT));
351 alSourceStop(soundSources.get(LEFT));
351352 LWJGLUtil.log("Stopped left.wav");
352353 }
353354
354355 if (Keyboard.isKeyDown(Keyboard.KEY_5)) {
355 AL10.alSourceStop(soundSources.get(CENTER));
356 alSourceStop(soundSources.get(CENTER));
356357 LWJGLUtil.log("Stopped center.wav");
357358 }
358359
359360 if (Keyboard.isKeyDown(Keyboard.KEY_6)) {
360 AL10.alSourceStop(soundSources.get(RIGHT));
361 alSourceStop(soundSources.get(RIGHT));
361362 LWJGLUtil.log("Stopped right.wav");
362363 }
363364 // --------------------------------------------
366367 // ============================================
367368 if (Keyboard.isKeyDown(Keyboard.KEY_LEFT)) {
368369 listenerPosition.put(0, listenerPosition.get(0) - 0.1f);
369 AL10.alListener(AL10.AL_POSITION, listenerPosition);
370 alListener(AL_POSITION, listenerPosition);
370371 }
371372
372373 if (Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) {
373374 listenerPosition.put(0, listenerPosition.get(0) + 0.1f);
374 AL10.alListener(AL10.AL_POSITION, listenerPosition);
375 alListener(AL_POSITION, listenerPosition);
375376 }
376377
377378 if (Keyboard.isKeyDown(Keyboard.KEY_UP)) {
380381 } else {
381382 listenerPosition.put(2, listenerPosition.get(2) - 0.1f);
382383 }
383 AL10.alListener(AL10.AL_POSITION, listenerPosition);
384 alListener(AL_POSITION, listenerPosition);
384385 }
385386
386387 if (Keyboard.isKeyDown(Keyboard.KEY_DOWN)) {
389390 } else {
390391 listenerPosition.put(2, listenerPosition.get(2) + 0.1f);
391392 }
392 AL10.alListener(AL10.AL_POSITION, listenerPosition);
393 alListener(AL_POSITION, listenerPosition);
393394 }
394395 // --------------------------------------------
395
396
396397 // Test for movement with Mouse
397398 // ============================================
398399 listenerPosition.put(0, listenerPosition.get(0) + (0.01f * Mouse.getDX()));
403404 if (Mouse.isButtonDown(1)) {
404405 listenerPosition.put(2, listenerPosition.get(2) + 0.1f);
405406 }
406
407 AL10.alListener(AL10.AL_POSITION, listenerPosition);
408
407
408 alListener(AL_POSITION, listenerPosition);
409
409410 // empty mouse buffer
410411 while(Mouse.next());
411412 }
414415 * Render the scene
415416 */
416417 private void render() {
417 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
418 GL11.glPushMatrix();
418 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
419 glPushMatrix();
419420 {
420 GL11.glRotatef(20.0f, 1.0f, 1.0f, 0.0f);
421 glRotatef(20.0f, 1.0f, 1.0f, 0.0f);
421422
422423 // left
423 GL11.glPushMatrix();
424 glPushMatrix();
424425 {
425 GL11.glTranslatef(leftPosition.get(0), leftPosition.get(1), leftPosition.get(2));
426 GL11.glColor3f(1.0f, 0.0f, 0.0f);
426 glTranslatef(leftPosition.get(0), leftPosition.get(1), leftPosition.get(2));
427 glColor3f(1.0f, 0.0f, 0.0f);
427428 glut.glutWireCube(0.5f);
428429 }
429 GL11.glPopMatrix();
430 glPopMatrix();
430431
431432 // center
432 GL11.glPushMatrix();
433 glPushMatrix();
433434 {
434 GL11.glTranslatef(centerPosition.get(0), centerPosition.get(1), centerPosition.get(2));
435 GL11.glColor3f(0.0f, 0.0f, 1.0f);
435 glTranslatef(centerPosition.get(0), centerPosition.get(1), centerPosition.get(2));
436 glColor3f(0.0f, 0.0f, 1.0f);
436437 glut.glutWireCube(0.5f);
437438 }
438 GL11.glPopMatrix();
439 glPopMatrix();
439440
440441 // right
441 GL11.glPushMatrix();
442 glPushMatrix();
442443 {
443 GL11.glTranslatef(rightPosition.get(0), rightPosition.get(1), rightPosition.get(2));
444 GL11.glColor3f(0.0f, 1.0f, 0.0f);
444 glTranslatef(rightPosition.get(0), rightPosition.get(1), rightPosition.get(2));
445 glColor3f(0.0f, 1.0f, 0.0f);
445446 glut.glutWireCube(0.5f);
446447 }
447 GL11.glPopMatrix();
448 glPopMatrix();
448449
449450 // listener
450 GL11.glPushMatrix();
451 glPushMatrix();
451452 {
452 GL11.glTranslatef(listenerPosition.get(0), listenerPosition.get(1), listenerPosition.get(2));
453 GL11.glColor3f(1.0f, 1.0f, 1.0f);
453 glTranslatef(listenerPosition.get(0), listenerPosition.get(1), listenerPosition.get(2));
454 glColor3f(1.0f, 1.0f, 1.0f);
454455 glut.glutSolidCube(0.5f);
455456 }
456 GL11.glPopMatrix();
457 }
458 GL11.glPopMatrix();
457 glPopMatrix();
458 }
459 glPopMatrix();
459460 }
460461
461462 /**
463464 */
464465 private void shutdown() {
465466 LWJGLUtil.log("Shutting down OpenAL");
466 AL10.alSourceStop(soundSources);
467 AL10.alDeleteSources(soundSources);
468 AL10.alDeleteBuffers(soundBuffers);
467 alSourceStop(soundSources);
468 alDeleteSources(soundSources);
469 alDeleteBuffers(soundBuffers);
469470 AL.destroy();
470471
471472 LWJGLUtil.log("Shutting down Window");
474475
475476 /**
476477 * main entry point
477 *
478 *
478479 * @param args
479480 * String array containing arguments
480481 */
486487
487488 /**
488489 * Minute implementation of GLUT: <br>COPYRIGHT:
489 *
490 *
490491 * The OpenGL Utility Toolkit distribution for Win32 (Windows NT & Windows
491492 * 95) contains source code modified from the original source code for GLUT
492493 * version 3.3 which was developed by Mark J. Kilgard. The original source
495496 * freely distributable without licensing fees. It is provided without
496497 * guarantee or warrantee expressed or implied. It was ported with the
497498 * permission of Mark J. Kilgard by Nate Robins.
498 *
499 *
499500 * THIS SOURCE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
500501 * EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
501502 * OR MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
520521 float v[][] = new float[8][3];
521522
522523 public void glutWireCube(float size) {
523 drawBox(size, GL11.GL_LINE_LOOP);
524 drawBox(size, GL_LINE_LOOP);
524525 }
525526
526527 public void glutSolidCube(float size) {
527 drawBox(size, GL11.GL_QUADS);
528 drawBox(size, GL_QUADS);
528529 }
529530
530531 private void drawBox(float size, int type) {
537538 v[1][2] = v[2][2] = v[5][2] = v[6][2] = size / 2;
538539
539540 for (int i = 5; i >= 0; i--) {
540 GL11.glBegin(type);
541 GL11.glNormal3f(n[i][0], n[i][1], n[i][2]);
542 GL11.glVertex3f(v[faces[i][0]][0], v[faces[i][0]][1], v[faces[i][0]][2]);
543 GL11.glVertex3f(v[faces[i][1]][0], v[faces[i][1]][1], v[faces[i][1]][2]);
544 GL11.glVertex3f(v[faces[i][2]][0], v[faces[i][2]][1], v[faces[i][2]][2]);
545 GL11.glVertex3f(v[faces[i][3]][0], v[faces[i][3]][1], v[faces[i][3]][2]);
546 GL11.glEnd();
541 glBegin(type);
542 glNormal3f(n[i][0], n[i][1], n[i][2]);
543 glVertex3f(v[faces[i][0]][0], v[faces[i][0]][1], v[faces[i][0]][2]);
544 glVertex3f(v[faces[i][1]][0], v[faces[i][1]][1], v[faces[i][1]][2]);
545 glVertex3f(v[faces[i][2]][0], v[faces[i][2]][1], v[faces[i][2]][2]);
546 glVertex3f(v[faces[i][3]][0], v[faces[i][3]][1], v[faces[i][3]][2]);
547 glEnd();
547548 }
548549
549550 }
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.opencl;
32
33 import org.lwjgl.BufferUtils;
34 import org.lwjgl.LWJGLException;
35 import org.lwjgl.LWJGLUtil;
36 import org.lwjgl.PointerBuffer;
37 import org.lwjgl.opencl.*;
38 import org.lwjgl.opencl.api.CLBufferRegion;
39
40 import java.nio.ByteBuffer;
41 import java.util.List;
42
43 import static org.lwjgl.opencl.CL10.*;
44 import static org.lwjgl.opencl.CL11.*;
45
46 /** Basic OpenCL test. */
47 public class HelloOpenCL {
48
49 public HelloOpenCL() {
50 }
51
52 protected static void execute() {
53 try {
54 CL.create();
55
56 final List<CLPlatform> platforms = CLPlatform.getPlatforms();
57 if ( platforms == null )
58 throw new RuntimeException("No OpenCL platforms found.");
59
60 for ( CLPlatform platform : platforms ) {
61 System.out.println("\n-------------------------");
62 System.out.println("NEW PLATFORM: " + platform.getPointer());
63 System.out.println(CLCapabilities.getPlatformCapabilities(platform));
64 System.out.println("-------------------------");
65 printPlatformInfo(platform, "CL_PLATFORM_PROFILE", CL_PLATFORM_PROFILE);
66 printPlatformInfo(platform, "CL_PLATFORM_VERSION", CL_PLATFORM_VERSION);
67 printPlatformInfo(platform, "CL_PLATFORM_NAME", CL_PLATFORM_NAME);
68 printPlatformInfo(platform, "CL_PLATFORM_VENDOR", CL_PLATFORM_VENDOR);
69 printPlatformInfo(platform, "CL_PLATFORM_EXTENSIONS", CL_PLATFORM_EXTENSIONS);
70 System.out.println("");
71
72 final PointerBuffer ctxProps = BufferUtils.createPointerBuffer(3);
73 ctxProps.put(CL_CONTEXT_PLATFORM).put(platform.getPointer()).put(0).flip();
74
75 final List<CLDevice> devices = platform.getDevices(CL_DEVICE_TYPE_ALL);
76 for ( CLDevice device : devices ) {
77 final CLDeviceCapabilities caps = CLCapabilities.getDeviceCapabilities(device);
78
79 System.out.println("\n\tNEW DEVICE: " + device.getPointer());
80 System.out.println(caps);
81 System.out.println("\t-------------------------");
82
83 System.out.println("\tCL_DEVICE_TYPE = " + device.getInfoInt(CL_DEVICE_TYPE));
84 System.out.println("\tCL_DEVICE_VENDOR_ID = " + device.getInfoInt(CL_DEVICE_VENDOR_ID));
85 System.out.println("\tCL_DEVICE_MAX_COMPUTE_UNITS = " + device.getInfoInt(CL_DEVICE_MAX_COMPUTE_UNITS));
86 System.out.println("\tCL_DEVICE_MAX_WORK_ITEM_DIMENSIONS = " + device.getInfoInt(CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS));
87 //CL10.clGetDeviceInfo(device, CL10.CL_DEVICE_MAX_WORK_ITEM_SIZES, info, size_ret);
88 //System.out.println("\tCL_DEVICE_MAX_WORK_ITEM_SIZES = " + info.getInt(0));
89 System.out.println("\tCL_DEVICE_MAX_WORK_GROUP_SIZE = " + device.getInfoSize(CL_DEVICE_MAX_WORK_GROUP_SIZE));
90 System.out.println("\tCL_DEVICE_MAX_CLOCK_FREQUENCY = " + device.getInfoInt(CL_DEVICE_MAX_CLOCK_FREQUENCY));
91 System.out.println("\tCL_DEVICE_ADDRESS_BITS = " + device.getInfoInt(CL_DEVICE_ADDRESS_BITS));
92 System.out.println("\tCL_DEVICE_AVAILABLE = " + device.getInfoBoolean(CL_DEVICE_AVAILABLE));
93 System.out.println("\tCL_DEVICE_COMPILER_AVAILABLE = " + device.getInfoBoolean(CL_DEVICE_COMPILER_AVAILABLE));
94
95 printDeviceInfo(device, "CL_DEVICE_NAME", CL_DEVICE_NAME);
96 printDeviceInfo(device, "CL_DEVICE_VENDOR", CL_DEVICE_VENDOR);
97 printDeviceInfo(device, "CL_DRIVER_VERSION", CL_DRIVER_VERSION);
98 printDeviceInfo(device, "CL_DEVICE_PROFILE", CL_DEVICE_PROFILE);
99 printDeviceInfo(device, "CL_DEVICE_VERSION", CL_DEVICE_VERSION);
100 printDeviceInfo(device, "CL_DEVICE_EXTENSIONS", CL_DEVICE_EXTENSIONS);
101 if ( caps.OpenCL11 )
102 printDeviceInfo(device, "CL_DEVICE_OPENCL_C_VERSION", CL_DEVICE_OPENCL_C_VERSION);
103
104 CLContext context = clCreateContext(ctxProps, device, new CLContextCallback() {
105 protected void handleMessage(final String errinfo, final ByteBuffer private_info) {
106 System.out.println("IN CLContextCallback :: " + errinfo);
107 }
108 }, null);
109
110 CLMem buffer = clCreateBuffer(context, CL_MEM_READ_ONLY, 128, null);
111
112 if ( caps.OpenCL11 ) {
113 clSetMemObjectDestructorCallback(buffer, new CLMemObjectDestructorCallback() {
114 protected void handleMessage(final long memobj) {
115 System.out.println("FIRST Buffer destructed: " + memobj);
116 }
117 });
118
119 clSetMemObjectDestructorCallback(buffer, new CLMemObjectDestructorCallback() {
120 protected void handleMessage(final long memobj) {
121 System.out.println("SECOND Buffer destructed: " + memobj);
122 }
123 });
124 }
125
126 if ( caps.OpenCL11 ) {
127 CLMem subbuffer = buffer.createSubBuffer(CL_MEM_READ_ONLY, CL_BUFFER_CREATE_TYPE_REGION, new CLBufferRegion(0, 64), null);
128
129 clSetMemObjectDestructorCallback(subbuffer, new CLMemObjectDestructorCallback() {
130 protected void handleMessage(final long memobj) {
131 System.out.println("Sub Buffer destructed: " + memobj);
132 }
133 });
134 }
135
136 clRetainMemObject(buffer);
137
138 if ( LWJGLUtil.getPlatform() != LWJGLUtil.PLATFORM_MACOSX ) {
139 // TODO: Native kernels crash on MacOSX, disable this until we can debug properly.
140 final long exec_caps = device.getInfoLong(CL_DEVICE_EXECUTION_CAPABILITIES);
141 if ( (exec_caps & CL_EXEC_NATIVE_KERNEL) == CL_EXEC_NATIVE_KERNEL ) {
142 System.out.println("-TRYING TO EXEC NATIVE KERNEL-");
143 final CLCommandQueue queue = clCreateCommandQueue(context, device, 0, null);
144
145 clEnqueueNativeKernel(queue, new CLNativeKernel() {
146 protected void execute(final ByteBuffer[] memobjs) {
147 if ( memobjs == null )
148 System.out.println("OK, it's null");
149 else {
150 System.out.println("memobjs = " + memobjs.length);
151 for ( int k = 0; k < memobjs.length; k++ ) {
152 System.out.println("memobjs[" + k + "].remaining() = " + memobjs[k].remaining());
153 for ( int l = memobjs[k].position(); l < memobjs[k].limit(); l++ ) {
154 memobjs[k].put(l, (byte)l);
155 }
156 }
157 }
158 }
159 }, new CLMem[] { buffer }, new long[] { 128 }, null, null);
160
161 clFinish(queue);
162 }
163 }
164
165 clReleaseMemObject(buffer);
166 clReleaseContext(context);
167 }
168 }
169 } catch (LWJGLException le) {
170 die("Init", le.getMessage());
171 }
172
173 CL.destroy();
174 }
175
176 private static void printPlatformInfo(final CLPlatform platform, final String param_name, final int param) {
177 System.out.println("\t" + param_name + " = " + platform.getInfoString(param));
178 }
179
180 private static void printDeviceInfo(final CLDevice device, final String param_name, final int param) {
181 System.out.println("\t" + param_name + " = " + device.getInfoString(param));
182 }
183
184 private static void die(String kind, String description) {
185 System.out.println(kind + " error " + description + " occured");
186 }
187
188 /**
189 * main entry point
190 *
191 * @param args String array containing arguments
192 */
193 public static void main(String[] args) {
194 new HelloOpenCL().execute();
195 }
196
197 }
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.opencl.gl;
32
33 import org.lwjgl.BufferUtils;
34 import org.lwjgl.LWJGLException;
35 import org.lwjgl.PointerBuffer;
36 import org.lwjgl.input.Keyboard;
37 import org.lwjgl.input.Mouse;
38 import org.lwjgl.opencl.*;
39 import org.lwjgl.opencl.api.Filter;
40 import org.lwjgl.opengl.*;
41 import org.lwjgl.util.Color;
42 import org.lwjgl.util.ReadableColor;
43
44 import java.io.*;
45 import java.net.URL;
46 import java.nio.ByteBuffer;
47 import java.nio.IntBuffer;
48 import java.util.HashSet;
49 import java.util.List;
50 import java.util.Set;
51
52 import static java.lang.Math.*;
53 import static org.lwjgl.opencl.CL10.*;
54 import static org.lwjgl.opencl.CL10GL.*;
55 import static org.lwjgl.opencl.KHRGLEvent.*;
56 import static org.lwjgl.opengl.AMDDebugOutput.*;
57 import static org.lwjgl.opengl.ARBCLEvent.*;
58 import static org.lwjgl.opengl.ARBDebugOutput.*;
59 import static org.lwjgl.opengl.ARBSync.*;
60 import static org.lwjgl.opengl.GL11.*;
61 import static org.lwjgl.opengl.GL15.*;
62 import static org.lwjgl.opengl.GL20.*;
63 import static org.lwjgl.opengl.GL21.*;
64
65 /*
66 THIS DEMO USES CODE PORTED FROM JogAmp.org
67 Original code: http://github.com/mbien/jocl-demos
68 Original author: Michael Bien
69
70 ___ ___ ___
71 / /\ / /\ ___ / /\ http://jocl.jogamp.org/
72 / /:/ / /::\ /__/\ / /::\ a http://jogamp.org/ project.
73 /__/::\ / /:/\:\ \ \:\ / /:/\:\
74 \__\/\:\ / /:/~/::\ \ \:\ / /:/~/::\
75 \ \:\ /__/:/ /:/\:\ ___ \__\:\/__/:/ /:/\:\
76 \__\:\\ \:\/:/__\//__/\ | |:|\ \:\/:/__\/
77 / /:/ \ \::/ \ \:\| |:| \ \::/
78 /__/:/ \ \:\ \ \:\__|:| \ \:\
79 \__\/ \ \:\ \__\::::/ \ \:\
80 \__\/ ~~~~ \__\/
81 ___ ___ ___ ___ ___
82 / /\ / /\ / /\ /__/\ / /\
83 / /::\ / /::\ / /:/_ \ \:\ / /:/
84 / /:/\:\ / /:/\:\ / /:/ /\ \ \:\ / /:/ ___ ___
85 / /:/ \:\ / /:/~/:// /:/ /:/_ _____\__\:\ / /:/ ___ /__/\ / /\
86 /__/:/ \__\:\/__/:/ /://__/:/ /:/ /\/__/::::::::\/__/:/ / /\\ \:\ / /:/
87 \ \:\ / /:/\ \:\/:/ \ \:\/:/ /:/\ \:\~~\~~\/\ \:\ / /:/ \ \:\ /:/
88 \ \:\ /:/ \ \::/ \ \::/ /:/ \ \:\ ~~~ \ \:\ /:/ \ \:\/:/
89 \ \:\/:/ \ \:\ \ \:\/:/ \ \:\ \ \:\/:/ \ \::/
90 \ \::/ \ \:\ \ \::/ \ \:\ \ \::/ \__\/
91 \__\/ \__\/ \__\/ \__\/ \__\/
92
93 _____ ___ ___ ___ ___
94 / /::\ / /\ /__/\ / /\ / /\
95 / /:/\:\ / /:/_ | |::\ / /::\ / /:/_
96 / /:/ \:\ / /:/ /\ | |:|:\ / /:/\:\ / /:/ /\
97 /__/:/ \__\:| / /:/ /:/_ __|__|:|\:\ / /:/ \:\ / /:/ /::\
98 \ \:\ / /:/ /__/:/ /:/ /\ /__/::::| \:\ /__/:/ \__\:\ /__/:/ /:/\:\
99 \ \:\ /:/ \ \:\/:/ /:/ \ \:\~~\__\/ \ \:\ / /:/ \ \:\/:/~/:/
100 \ \:\/:/ \ \::/ /:/ \ \:\ \ \:\ /:/ \ \::/ /:/
101 \ \::/ \ \:\/:/ \ \:\ \ \:\/:/ \__\/ /:/
102 \__\/ \ \::/ \ \:\ \ \::/ /__/:/
103 \__\/ \__\/ \__\/ \__\/
104 */
105
106 /**
107 * Computes the Mandelbrot set with OpenCL using multiple GPUs and renders the result with OpenGL.
108 * A shared PBO is used as storage for the fractal image.<br/>
109 * http://en.wikipedia.org/wiki/Mandelbrot_set
110 * <p>
111 * controls:<br/>
112 * keys 1-9 control parallelism level<br/>
113 * space enables/disables slice seperator<br/>
114 * 'd' toggles between 32/64bit floatingpoint precision<br/>
115 * mouse/mousewheel to drag and zoom<br/>
116 * 'Home' to reset the viewport<br/>
117 * </p>
118 *
119 * @author Michael Bien, Spasi
120 */
121 public class DemoFractal {
122
123 // max number of used GPUs
124 private static final int MAX_PARALLELISM_LEVEL = 8;
125
126 private static final int COLOR_MAP_SIZE = 32 * 2 * 4;
127
128 private Set<String> params;
129
130 private CLContext clContext;
131 private CLCommandQueue[] queues;
132 private CLKernel[] kernels;
133 private CLProgram[] programs;
134
135 private CLMem[] glBuffers;
136 private IntBuffer glIDs;
137
138 private boolean useTextures;
139
140 // Texture rendering
141 private int dlist;
142 private int vsh;
143 private int fsh;
144 private int program;
145
146 private CLMem[] colorMap;
147
148 private final PointerBuffer kernel2DGlobalWorkSize;
149
150 // max per pixel iterations to compute the fractal
151 private int maxIterations = 500;
152
153 private int width = 512;
154 private int height = 512;
155
156 private double minX = -2f;
157 private double minY = -1.2f;
158 private double maxX = 0.6f;
159 private double maxY = 1.3f;
160
161 private boolean dragging;
162 private double dragX;
163 private double dragY;
164 private double dragMinX;
165 private double dragMinY;
166 private double dragMaxX;
167 private double dragMaxY;
168
169 private int mouseX;
170 private int mouseY;
171
172 private int slices;
173
174 private boolean drawSeparator;
175 private boolean doublePrecision = true;
176 private boolean buffersInitialized;
177 private boolean rebuild;
178
179 private boolean run = true;
180
181 // EVENT SYNCING
182
183 private final PointerBuffer syncBuffer = BufferUtils.createPointerBuffer(1);
184
185 private boolean syncGLtoCL; // true if we can make GL wait on events generated from CL queues.
186 private CLEvent[] clEvents;
187 private GLSync[] clSyncs;
188
189 private boolean syncCLtoGL; // true if we can make CL wait on sync objects generated from GL.
190 private GLSync glSync;
191 private CLEvent glEvent;
192
193 public DemoFractal(final String[] args) {
194 params = new HashSet<String>();
195
196 for ( int i = 0; i < args.length; i++ ) {
197 final String arg = args[i];
198
199 if ( arg.charAt(0) != '-' && arg.charAt(0) != '/' )
200 throw new IllegalArgumentException("Invalid command-line argument: " + args[i]);
201
202 final String param = arg.substring(1);
203
204 if ( "forcePBO".equalsIgnoreCase(param) )
205 params.add("forcePBO");
206 else if ( "forceCPU".equalsIgnoreCase(param) )
207 params.add("forceCPU");
208 else if ( "debugGL".equalsIgnoreCase(param) )
209 params.add("debugGL");
210 else if ( "iterations".equalsIgnoreCase(param) ) {
211 if ( args.length < i + 1 + 1 )
212 throw new IllegalArgumentException("Invalid iterations argument specified.");
213
214 try {
215 this.maxIterations = Integer.parseInt(args[++i]);
216 } catch (NumberFormatException e) {
217 throw new IllegalArgumentException("Invalid number of iterations specified.");
218 }
219 } else if ( "res".equalsIgnoreCase(param) ) {
220 if ( args.length < i + 2 + 1 )
221 throw new IllegalArgumentException("Invalid res argument specified.");
222
223 try {
224 this.width = Integer.parseInt(args[++i]);
225 this.height = Integer.parseInt(args[++i]);
226
227 if ( width < 1 || height < 1 )
228 throw new IllegalArgumentException("Invalid res dimensions specified.");
229 } catch (NumberFormatException e) {
230 throw new IllegalArgumentException("Invalid res dimensions specified.");
231 }
232 }
233 }
234
235 kernel2DGlobalWorkSize = BufferUtils.createPointerBuffer(2);
236 }
237
238 public static void main(String args[]) {
239 DemoFractal demo = new DemoFractal(args);
240 demo.init();
241 demo.run();
242 }
243
244 public void init() {
245 try {
246 CL.create();
247 Display.setDisplayMode(new DisplayMode(width, height));
248 Display.setTitle("OpenCL Fractal Demo");
249 Display.setSwapInterval(0);
250 Display.create(new PixelFormat(), new ContextAttribs().withDebug(params.contains("debugGL")));
251 } catch (LWJGLException e) {
252 throw new RuntimeException(e);
253 }
254
255 try {
256 initCL(Display.getDrawable());
257 } catch (Exception e) {
258 if ( clContext != null )
259 clReleaseContext(clContext);
260 Display.destroy();
261 throw new RuntimeException(e);
262 }
263
264 glDisable(GL_DEPTH_TEST);
265 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
266
267 initView(Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight());
268
269 initGLObjects();
270 glFinish();
271
272 setKernelConstants();
273 }
274
275 private void initCL(Drawable drawable) throws Exception {
276 // Find a platform
277 List<CLPlatform> platforms = CLPlatform.getPlatforms();
278 if ( platforms == null )
279 throw new RuntimeException("No OpenCL platforms found.");
280
281 final CLPlatform platform = platforms.get(0); // just grab the first one
282
283 // Find devices with GL sharing support
284 final Filter<CLDevice> glSharingFilter = new Filter<CLDevice>() {
285 public boolean accept(final CLDevice device) {
286 final CLDeviceCapabilities caps = CLCapabilities.getDeviceCapabilities(device);
287 return caps.CL_KHR_gl_sharing;
288 }
289 };
290 int device_type = params.contains("forceCPU") ? CL_DEVICE_TYPE_CPU : CL_DEVICE_TYPE_GPU;
291 List<CLDevice> devices = platform.getDevices(device_type, glSharingFilter);
292 if ( devices == null ) {
293 device_type = CL_DEVICE_TYPE_CPU;
294 devices = platform.getDevices(device_type, glSharingFilter);
295 if ( devices == null )
296 throw new RuntimeException("No OpenCL devices found with KHR_gl_sharing support.");
297 }
298
299 // Create the context
300 clContext = CLContext.create(platform, devices, new CLContextCallback() {
301 protected void handleMessage(final String errinfo, final ByteBuffer private_info) {
302 System.out.println("[CONTEXT MESSAGE] " + errinfo);
303 }
304 }, drawable, null);
305
306 slices = min(devices.size(), MAX_PARALLELISM_LEVEL);
307
308 // create command queues for every GPU, setup colormap and init kernels
309 queues = new CLCommandQueue[slices];
310 kernels = new CLKernel[slices];
311 colorMap = new CLMem[slices];
312
313 for ( int i = 0; i < slices; i++ ) {
314 colorMap[i] = clCreateBuffer(clContext, CL_MEM_READ_ONLY, COLOR_MAP_SIZE, null);
315 colorMap[i].checkValid();
316
317 // create command queue and upload color map buffer on each used device
318 queues[i] = clCreateCommandQueue(clContext, devices.get(i), CL_QUEUE_PROFILING_ENABLE, null);
319 queues[i].checkValid();
320
321 final ByteBuffer colorMapBuffer = clEnqueueMapBuffer(queues[i], colorMap[i], CL_TRUE, CL_MAP_WRITE, 0, COLOR_MAP_SIZE, null, null, null);
322 initColorMap(colorMapBuffer.asIntBuffer(), 32, Color.BLUE, Color.GREEN, Color.RED);
323 clEnqueueUnmapMemObject(queues[i], colorMap[i], colorMapBuffer, null, null);
324 }
325
326 // check if we have 64bit FP support on all devices
327 // if yes we can use only one program for all devices + one kernel per device.
328 // if not we will have to create (at least) one program for 32 and one for 64bit devices.
329 // since there are different vendor extensions for double FP we use one program per device.
330 // (OpenCL spec is not very clear about this usecases)
331 boolean all64bit = true;
332 for ( CLDevice device : devices ) {
333 if ( !isDoubleFPAvailable(device) ) {
334 all64bit = false;
335 break;
336 }
337 }
338
339 // load program(s)
340 programs = new CLProgram[all64bit ? 1 : slices];
341
342 final ContextCapabilities caps = GLContext.getCapabilities();
343
344 if ( !caps.OpenGL20 )
345 throw new RuntimeException("OpenGL 2.0 is required to run this demo.");
346 else if ( device_type == CL_DEVICE_TYPE_CPU && !caps.OpenGL21 )
347 throw new RuntimeException("OpenGL 2.1 is required to run this demo.");
348
349 if ( params.contains("debugGL") ) {
350 if ( caps.GL_ARB_debug_output )
351 glDebugMessageCallbackARB(new ARBDebugOutputCallback());
352 else if ( caps.GL_AMD_debug_output )
353 glDebugMessageCallbackAMD(new AMDDebugOutputCallback());
354 }
355
356 if ( device_type == CL_DEVICE_TYPE_GPU )
357 System.out.println("OpenCL Device Type: GPU (Use -forceCPU to use CPU)");
358 else
359 System.out.println("OpenCL Device Type: CPU");
360 for ( int i = 0; i < devices.size(); i++ )
361 System.out.println("OpenCL Device #" + (i + 1) + " supports KHR_gl_event = " + CLCapabilities.getDeviceCapabilities(devices.get(i)).CL_KHR_gl_event);
362
363 System.out.println("\nMax Iterations: " + maxIterations + " (Use -iterations <count> to change)");
364 System.out.println("Display resolution: " + width + "x" + height + " (Use -res <width> <height> to change)");
365
366 System.out.println("\nOpenGL caps.GL_ARB_sync = " + caps.GL_ARB_sync);
367 System.out.println("OpenGL caps.GL_ARB_cl_event = " + caps.GL_ARB_cl_event);
368
369 // Use PBO if we're on a CPU implementation
370 useTextures = device_type == CL_DEVICE_TYPE_GPU && (!caps.OpenGL21 || !params.contains("forcePBO"));
371 if ( useTextures ) {
372 System.out.println("\nCL/GL Sharing method: TEXTURES (use -forcePBO to use PBO + DrawPixels)");
373 System.out.println("Rendering method: Shader on a fullscreen quad");
374 } else {
375 System.out.println("\nCL/GL Sharing method: PIXEL BUFFER OBJECTS");
376 System.out.println("Rendering method: DrawPixels");
377 }
378
379 buildPrograms();
380
381 // Detect GLtoCL synchronization method
382 syncGLtoCL = caps.GL_ARB_cl_event; // GL3.2 or ARB_sync implied
383 if ( syncGLtoCL ) {
384 clEvents = new CLEvent[slices];
385 clSyncs = new GLSync[slices];
386 System.out.println("\nGL to CL sync: Using OpenCL events");
387 } else
388 System.out.println("\nGL to CL sync: Using clFinish");
389
390 // Detect CLtoGL synchronization method
391 syncCLtoGL = caps.OpenGL32 || caps.GL_ARB_sync;
392 if ( syncCLtoGL ) {
393 for ( CLDevice device : devices ) {
394 if ( !CLCapabilities.getDeviceCapabilities(device).CL_KHR_gl_event ) {
395 syncCLtoGL = false;
396 break;
397 }
398 }
399 }
400 if ( syncCLtoGL ) {
401 System.out.println("CL to GL sync: Using OpenGL sync objects");
402 } else
403 System.out.println("CL to GL sync: Using glFinish");
404
405 if ( useTextures ) {
406 dlist = glGenLists(1);
407
408 glNewList(dlist, GL_COMPILE);
409 glBegin(GL_QUADS);
410 {
411 glTexCoord2f(0.0f, 0.0f);
412 glVertex2f(0, 0);
413
414 glTexCoord2f(0.0f, 1.0f);
415 glVertex2i(0, height);
416
417 glTexCoord2f(1.0f, 1.0f);
418 glVertex2f(width, height);
419
420 glTexCoord2f(1.0f, 0.0f);
421 glVertex2f(width, 0);
422 }
423 glEnd();
424 glEndList();
425
426 vsh = glCreateShader(GL_VERTEX_SHADER);
427 glShaderSource(vsh, "varying vec2 texCoord;\n" +
428 "\n" +
429 "void main(void) {\n" +
430 "\tgl_Position = ftransform();\n" +
431 "\ttexCoord = gl_MultiTexCoord0.xy;\n" +
432 "}");
433 glCompileShader(vsh);
434
435 fsh = glCreateShader(GL_FRAGMENT_SHADER);
436 glShaderSource(fsh, "uniform sampler2D mandelbrot;\n" +
437 "\n" +
438 "varying vec2 texCoord;\n" +
439 "\n" +
440 "void main(void) {\n" +
441 "\tgl_FragColor = texture2D(mandelbrot, texCoord);" +
442 "}");
443 glCompileShader(fsh);
444
445 program = glCreateProgram();
446 glAttachShader(program, vsh);
447 glAttachShader(program, fsh);
448 glLinkProgram(program);
449
450 glUseProgram(program);
451 glUniform1i(glGetUniformLocation(program, "mandelbrot"), 0);
452 }
453
454 System.out.println("");
455 }
456
457 private void buildPrograms() {
458 /*
459 * workaround: The driver keeps using the old binaries for some reason.
460 * to solve this we simple create a new program and release the old.
461 * however rebuilding programs should be possible -> remove when drivers are fixed.
462 * (again: the spec is not very clear about this kind of usages)
463 */
464 if ( programs[0] != null ) {
465 for ( CLProgram program : programs )
466 clReleaseProgram(program);
467 }
468
469 try {
470 createPrograms();
471 } catch (IOException e) {
472 throw new RuntimeException(e);
473 }
474
475 // disable 64bit floating point math if not available
476 for ( int i = 0; i < programs.length; i++ ) {
477 final CLDevice device = queues[i].getCLDevice();
478
479 final StringBuilder options = new StringBuilder(useTextures ? "-D USE_TEXTURE" : "");
480 final CLDeviceCapabilities caps = CLCapabilities.getDeviceCapabilities(device);
481 if ( doublePrecision && isDoubleFPAvailable(device) ) {
482 //cl_khr_fp64
483 options.append(" -D DOUBLE_FP");
484
485 //amd's verson of double precision floating point math
486 if ( !caps.CL_KHR_fp64 && caps.CL_AMD_fp64 )
487 options.append(" -D AMD_FP");
488 }
489
490 System.out.println("\nOpenCL COMPILER OPTIONS: " + options);
491
492 try {
493 clBuildProgram(programs[i], device, options, null);
494 } finally {
495 System.out.println("BUILD LOG: " + programs[i].getBuildInfoString(device, CL_PROGRAM_BUILD_LOG));
496 }
497 }
498
499 rebuild = false;
500
501 // init kernel with constants
502 for ( int i = 0; i < kernels.length; i++ )
503 kernels[i] = clCreateKernel(programs[min(i, programs.length)], "mandelbrot", null);
504 }
505
506 private void initGLObjects() {
507 if ( glBuffers == null ) {
508 glBuffers = new CLMem[slices];
509 glIDs = BufferUtils.createIntBuffer(slices);
510 } else {
511 for ( CLMem mem : glBuffers )
512 clReleaseMemObject(mem);
513
514 if ( useTextures )
515 glDeleteTextures(glIDs);
516 else
517 glDeleteBuffers(glIDs);
518 }
519
520 if ( useTextures )
521 glGenTextures(glIDs);
522 else
523 glGenBuffers(glIDs);
524
525 if ( useTextures ) {
526 // Init textures
527 for ( int i = 0; i < slices; i++ ) {
528 glBindTexture(GL_TEXTURE_2D, glIDs.get(i));
529 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width / slices, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (ByteBuffer)null);
530 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
531 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
532
533 glBuffers[i] = clCreateFromGLTexture2D(clContext, CL_MEM_WRITE_ONLY, GL_TEXTURE_2D, 0, glIDs.get(i), null);
534 }
535 glBindTexture(GL_TEXTURE_2D, 0);
536 } else {
537 // setup one empty PBO per slice
538 for ( int i = 0; i < slices; i++ ) {
539 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, glIDs.get(i));
540 glBufferData(GL_PIXEL_UNPACK_BUFFER, width * height * 4 / slices, GL_STREAM_DRAW);
541
542 glBuffers[i] = clCreateFromGLBuffer(clContext, CL_MEM_WRITE_ONLY, glIDs.get(i), null);
543 }
544 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
545 }
546
547 buffersInitialized = true;
548 }
549
550 // init kernels with constants
551
552 private void setKernelConstants() {
553 for ( int i = 0; i < slices; i++ ) {
554 kernels[i]
555 .setArg(6, glBuffers[i])
556 .setArg(7, colorMap[i])
557 .setArg(8, COLOR_MAP_SIZE)
558 .setArg(9, maxIterations);
559 }
560 }
561
562 // rendering cycle
563
564 private void run() {
565 long startTime = System.currentTimeMillis() + 5000;
566 long fps = 0;
567
568 while ( run ) {
569 if ( !Display.isVisible() )
570 Thread.yield();
571
572 handleIO();
573 display();
574
575 Display.update();
576 if ( Display.isCloseRequested() )
577 break;
578
579 if ( startTime > System.currentTimeMillis() ) {
580 fps++;
581 } else {
582 long timeUsed = 5000 + (startTime - System.currentTimeMillis());
583 startTime = System.currentTimeMillis() + 5000;
584 System.out.println(fps + " frames in 5 seconds = " + (fps / (timeUsed / 1000f)));
585 fps = 0;
586 }
587 }
588
589 clReleaseContext(clContext);
590
591 if ( useTextures ) {
592 glDeleteProgram(program);
593 glDeleteShader(fsh);
594 glDeleteShader(vsh);
595
596 glDeleteLists(dlist, 1);
597 }
598
599 CL.destroy();
600 Display.destroy();
601 }
602
603 public void display() {
604 // TODO: Need to clean-up events, test when ARB_cl_events & KHR_gl_event are implemented.
605
606 // make sure GL does not use our objects before we start computing
607 if ( syncCLtoGL && glEvent != null ) {
608 for ( final CLCommandQueue queue : queues )
609 clEnqueueWaitForEvents(queue, glEvent);
610 } else
611 glFinish();
612
613 if ( !buffersInitialized ) {
614 initGLObjects();
615 setKernelConstants();
616 }
617
618 if ( rebuild ) {
619 buildPrograms();
620 setKernelConstants();
621 }
622 compute(doublePrecision);
623
624 render();
625 }
626
627 // OpenCL
628
629 private void compute(final boolean is64bit) {
630 int sliceWidth = (int)(width / (float)slices);
631 double rangeX = (maxX - minX) / slices;
632 double rangeY = (maxY - minY);
633
634 kernel2DGlobalWorkSize.put(0, sliceWidth).put(1, height);
635
636 // start computation
637 for ( int i = 0; i < slices; i++ ) {
638 kernels[i].setArg(0, sliceWidth).setArg(1, height);
639 if ( !is64bit || !isDoubleFPAvailable(queues[i].getCLDevice()) ) {
640 kernels[i]
641 .setArg(2, (float)(minX + rangeX * i)).setArg(3, (float)minY)
642 .setArg(4, (float)rangeX).setArg(5, (float)rangeY);
643 } else {
644 kernels[i]
645 .setArg(2, minX + rangeX * i).setArg(3, minY)
646 .setArg(4, rangeX).setArg(5, rangeY);
647 }
648
649 // acquire GL objects, and enqueue a kernel with a probe from the list
650 clEnqueueAcquireGLObjects(queues[i], glBuffers[i], null, null);
651
652 clEnqueueNDRangeKernel(queues[i], kernels[i], 2,
653 null,
654 kernel2DGlobalWorkSize,
655 null,
656 null, null);
657
658 clEnqueueReleaseGLObjects(queues[i], glBuffers[i], null, syncGLtoCL ? syncBuffer : null);
659 if ( syncGLtoCL ) {
660 clEvents[i] = queues[i].getCLEvent(syncBuffer.get(0));
661 clSyncs[i] = glCreateSyncFromCLeventARB(queues[i].getParent(), clEvents[i], 0);
662 }
663 }
664
665 // block until done (important: finish before doing further gl work)
666 if ( !syncGLtoCL ) {
667 for ( int i = 0; i < slices; i++ )
668 clFinish(queues[i]);
669 }
670 }
671
672 // OpenGL
673
674 private void render() {
675 glClear(GL_COLOR_BUFFER_BIT);
676
677 if ( syncGLtoCL ) {
678 for ( int i = 0; i < slices; i++ )
679 glWaitSync(clSyncs[i], 0, 0);
680 }
681
682 //draw slices
683 int sliceWidth = width / slices;
684
685 if ( useTextures ) {
686 for ( int i = 0; i < slices; i++ ) {
687 int seperatorOffset = drawSeparator ? i : 0;
688
689 glBindTexture(GL_TEXTURE_2D, glIDs.get(i));
690 glCallList(dlist);
691 }
692 } else {
693 for ( int i = 0; i < slices; i++ ) {
694 int seperatorOffset = drawSeparator ? i : 0;
695
696 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, glIDs.get(i));
697 glRasterPos2i(sliceWidth * i + seperatorOffset, 0);
698
699 glDrawPixels(sliceWidth, height, GL_RGBA, GL_UNSIGNED_BYTE, 0);
700 }
701 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
702 }
703
704 if ( syncCLtoGL ) {
705 glSync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
706 glEvent = clCreateEventFromGLsyncKHR(clContext, glSync, null);
707 }
708
709 //draw info text
710 /*
711 textRenderer.beginRendering(width, height, false);
712
713 textRenderer.draw("device/time/precision", 10, height - 15);
714
715 for ( int i = 0; i < slices; i++ ) {
716 CLDevice device = queues[i].getDevice();
717 boolean doubleFP = doublePrecision && isDoubleFPAvailable(device);
718 CLEvent event = probes.getEvent(i);
719 long start = event.getProfilingInfo(START);
720 long end = event.getProfilingInfo(END);
721 textRenderer.draw(device.getType().toString() + i + " "
722 + (int)((end - start) / 1000000.0f) + "ms @"
723 + (doubleFP ? "64bit" : "32bit"), 10, height - (20 + 16 * (slices - i)));
724 }
725
726 textRenderer.endRendering();
727 */
728 }
729
730 private void handleIO() {
731 if ( Keyboard.getNumKeyboardEvents() != 0 ) {
732 while ( Keyboard.next() ) {
733 if ( Keyboard.getEventKeyState() )
734 continue;
735
736 final int key = Keyboard.getEventKey();
737
738 if ( Keyboard.KEY_1 <= key && key <= Keyboard.KEY_8 ) {
739 int number = key - Keyboard.KEY_1 + 1;
740 slices = min(number, min(queues.length, MAX_PARALLELISM_LEVEL));
741 System.out.println("NEW PARALLELISM LEVEL: " + slices);
742 buffersInitialized = false;
743 } else {
744 switch ( Keyboard.getEventKey() ) {
745 case Keyboard.KEY_SPACE:
746 drawSeparator = !drawSeparator;
747 System.out.println("SEPARATOR DRAWING IS NOW: " + (drawSeparator ? "ON" : "OFF"));
748 break;
749 case Keyboard.KEY_D:
750 doublePrecision = !doublePrecision;
751 System.out.println("DOUBLE PRECISION IS NOW: " + (doublePrecision ? "ON" : "OFF"));
752 rebuild = true;
753 break;
754 case Keyboard.KEY_HOME:
755 minX = -2f;
756 minY = -1.2f;
757 maxX = 0.6f;
758 maxY = 1.3f;
759 break;
760 case Keyboard.KEY_ESCAPE:
761 run = false;
762 break;
763 }
764 }
765 }
766 }
767
768 while ( Mouse.next() ) {
769 final int eventBtn = Mouse.getEventButton();
770
771 final int x = Mouse.getX();
772 final int y = Mouse.getY();
773
774 if ( Mouse.isButtonDown(0) && (x != mouseX || y != mouseY) ) {
775 if ( !dragging ) {
776 dragging = true;
777
778 dragX = mouseX;
779 dragY = mouseY;
780
781 dragMinX = minX;
782 dragMinY = minY;
783 dragMaxX = maxX;
784 dragMaxY = maxY;
785 }
786
787 double offsetX = (x - dragX) * (maxX - minX) / width;
788 double offsetY = (y - dragY) * (maxY - minY) / height;
789
790 minX = dragMinX - offsetX;
791 minY = dragMinY - offsetY;
792
793 maxX = dragMaxX - offsetX;
794 maxY = dragMaxY - offsetY;
795 } else {
796 if ( dragging )
797 dragging = false;
798
799 if ( eventBtn == -1 ) {
800 final int dwheel = Mouse.getEventDWheel();
801 if ( dwheel != 0 ) {
802 double scaleFactor = Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL) ? 0.25 : 0.05;
803 double scale = dwheel > 0 ? scaleFactor : -scaleFactor;
804
805 double deltaX = scale * (maxX - minX);
806 double deltaY = scale * (maxY - minY);
807
808 // offset for "zoom to cursor"
809 double offsetX = (x / (double)width - 0.5) * deltaX * 2.0;
810 double offsetY = (y / (double)height - 0.5) * deltaY * 2.0;
811
812 minX += deltaX + offsetX;
813 minY += deltaY - offsetY;
814
815 maxX += -deltaX + offsetX;
816 maxY += -deltaY - offsetY;
817 }
818 }
819 }
820
821 mouseX = x;
822 mouseY = y;
823 }
824 }
825
826 private static boolean isDoubleFPAvailable(CLDevice device) {
827 final CLDeviceCapabilities caps = CLCapabilities.getDeviceCapabilities(device);
828 return caps.CL_KHR_fp64 || caps.CL_AMD_fp64;
829 }
830
831 private void createPrograms() throws IOException {
832 final String source = getProgramSource("org/lwjgl/test/opencl/gl/Mandelbrot.cl");
833 for ( int i = 0; i < programs.length; i++ )
834 programs[i] = clCreateProgramWithSource(clContext, source, null);
835 }
836
837 private String getProgramSource(final String file) throws IOException {
838 InputStream source = null;
839 URL sourceURL = Thread.currentThread().getContextClassLoader().getResource(file);
840 if(sourceURL != null) {
841 source = sourceURL.openStream();
842 }
843 if ( source == null ) // dev-mode
844 source = new FileInputStream("src/java/" + file);
845 final BufferedReader reader = new BufferedReader(new InputStreamReader(source));
846
847 final StringBuilder sb = new StringBuilder();
848 String line;
849 try {
850 while ( (line = reader.readLine()) != null )
851 sb.append(line).append("\n");
852 } finally {
853 source.close();
854 }
855
856 return sb.toString();
857 }
858
859 private static void initColorMap(IntBuffer colorMap, int stepSize, ReadableColor... colors) {
860 for ( int n = 0; n < colors.length - 1; n++ ) {
861 ReadableColor color = colors[n];
862 int r0 = color.getRed();
863 int g0 = color.getGreen();
864 int b0 = color.getBlue();
865
866 color = colors[n + 1];
867 int r1 = color.getRed();
868 int g1 = color.getGreen();
869 int b1 = color.getBlue();
870
871 int deltaR = r1 - r0;
872 int deltaG = g1 - g0;
873 int deltaB = b1 - b0;
874
875 for ( int step = 0; step < stepSize; step++ ) {
876 float alpha = (float)step / (stepSize - 1);
877 int r = (int)(r0 + alpha * deltaR);
878 int g = (int)(g0 + alpha * deltaG);
879 int b = (int)(b0 + alpha * deltaB);
880 colorMap.put((r << 0) | (g << 8) | (b << 16));
881 }
882 }
883 }
884
885 private static void initView(int width, int height) {
886 glViewport(0, 0, width, height);
887
888 glMatrixMode(GL_MODELVIEW);
889 glLoadIdentity();
890
891 glMatrixMode(GL_PROJECTION);
892 glLoadIdentity();
893 glOrtho(0.0, width, 0.0, height, 0.0, 1.0);
894 }
895
896 }
0 #ifdef DOUBLE_FP
1 #ifdef AMD_FP
2 #pragma OPENCL EXTENSION cl_amd_fp64 : enable
3 #else
4 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
5 #endif
6 #define varfloat double
7 #define _255 255.0
8 #else
9 #define varfloat float
10 #define _255 255.0f
11 #endif
12
13 #ifdef USE_TEXTURE
14 #define OUTPUT_TYPE __write_only image2d_t
15 #else
16 #define OUTPUT_TYPE global uint *
17 #endif
18
19 /**
20 * For a description of this algorithm please refer to
21 * http://en.wikipedia.org/wiki/Mandelbrot_set
22 * @author Michael Bien
23 */
24 kernel void mandelbrot(
25 const int width, const int height,
26 const varfloat x0, const varfloat y0,
27 const varfloat rangeX, const varfloat rangeY,
28 OUTPUT_TYPE output, global uint *colorMap,
29 const int colorMapSize, const int maxIterations
30 ) {
31 unsigned int ix = get_global_id(0);
32 unsigned int iy = get_global_id(1);
33
34 varfloat r = x0 + ix * rangeX / width;
35 varfloat i = y0 + iy * rangeY / height;
36
37 varfloat x = 0;
38 varfloat y = 0;
39
40 varfloat magnitudeSquared = 0;
41 int iteration = 0;
42
43 while ( magnitudeSquared < 4 && iteration < maxIterations ) {
44 varfloat x2 = x*x;
45 varfloat y2 = y*y;
46 y = 2 * x * y + i;
47 x = x2 - y2 + r;
48 magnitudeSquared = x2+y2;
49 iteration++;
50 }
51
52 if ( iteration == maxIterations ) {
53 #ifdef USE_TEXTURE
54 write_imagef(output, (int2)(ix, iy), (float4)0);
55 #else
56 output[iy * width + ix] = 0;
57 #endif
58 } else {
59 varfloat alpha = (varfloat)iteration / maxIterations;
60 int colorIndex = (int)(alpha * colorMapSize);
61 #ifdef USE_TEXTURE
62 // We could have changed colorMap to a texture + sampler, but the
63 // unpacking below has minimal overhead and it's kinda interesting.
64 // We could also use an R32UI texture and do the unpacking in GLSL,
65 // but then we'd require OpenGL 3.0 (GLSL 1.30).
66 uint c = colorMap[colorIndex];
67 float4 oc = (float4)(
68 (c & 0xFF) >> 0,
69 (c & 0xFF00) >> 8,
70 (c & 0xFF0000) >> 16,
71 _255
72 );
73 write_imagef(output, (int2)(ix, iy), oc / _255);
74 #else
75 output[iy * width + ix] = colorMap[colorIndex];
76 #endif
77 // monochrom
78 //output[iy * width + ix] = 255*iteration/maxIterations;
79 }
80 }
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 */
3535 import org.lwjgl.input.Mouse;
3636 import org.lwjgl.opengl.Display;
3737 import org.lwjgl.opengl.DisplayMode;
38 import org.lwjgl.opengl.GL11;
39 import org.lwjgl.util.glu.GLU;
4038 import org.lwjgl.util.vector.Vector2f;
4139
40 import static org.lwjgl.opengl.GL11.*;
41 import static org.lwjgl.util.glu.GLU.*;
42
4243 /**
43 *
44 *
4445 * Tests switching between windowed and fullscreen
45 *
46 *
4647 * @author Brian Matzon <brian@matzon.dk>
47 * @version $Revision: 3365 $
48 * $Id: FullScreenWindowedTest.java 3365 2010-07-04 18:24:53Z spasi $
48 * @version $Revision: 3418 $
49 * $Id: FullScreenWindowedTest.java 3418 2010-09-28 21:11:35Z spasi $
4950 */
5051 public class FullScreenWindowedTest {
5152 /** Intended deiplay mode */
144145 }
145146 private void render() {
146147 //clear background
147 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
148 glClear(GL_COLOR_BUFFER_BIT);
148149 // draw white quad
149 GL11.glPushMatrix();
150 glPushMatrix();
150151 {
151 GL11.glTranslatef(quadPosition.x, quadPosition.y, 0);
152 GL11.glRotatef(angle, 0.0f, 0.0f, 1.0f);
153 GL11.glColor3f(1.0f, 1.0f, 1.0f);
154 GL11.glBegin(GL11.GL_QUADS);
152 glTranslatef(quadPosition.x, quadPosition.y, 0);
153 glRotatef(angle, 0.0f, 0.0f, 1.0f);
154 glColor3f(1.0f, 1.0f, 1.0f);
155 glBegin(GL_QUADS);
155156 {
156 GL11.glVertex2i(-50, -50);
157 GL11.glVertex2i(50, -50);
158 GL11.glVertex2i(50, 50);
159 GL11.glVertex2i(-50, 50);
160 }
161 GL11.glEnd();
162 }
163 GL11.glPopMatrix();
157 glVertex2i(-50, -50);
158 glVertex2i(50, -50);
159 glVertex2i(50, 50);
160 glVertex2i(-50, 50);
161 }
162 glEnd();
163 }
164 glPopMatrix();
164165 }
165166 /**
166167 * Processes keyboard input
234235
235236 /**
236237 * Retrieves a displaymode, if one such is available
237 *
238 *
238239 * @param width
239240 * Required width
240241 * @param height
245246 */
246247 private DisplayMode findDisplayMode(int width, int height, int bpp) throws LWJGLException {
247248 DisplayMode[] modes = Display.getAvailableDisplayModes();
248 for (int i = 0; i < modes.length; i++) {
249 if (modes[i].getWidth() == width && modes[i].getHeight() == height && modes[i].getBitsPerPixel() >= bpp && modes[i].getFrequency() <= 60) {
250 return modes[i];
249 for ( DisplayMode mode : modes ) {
250 if ( mode.getWidth() == width && mode.getHeight() == height && mode.getBitsPerPixel() >= bpp && mode.getFrequency() <= 60 ) {
251 return mode;
251252 }
252253 }
253254 return Display.getDesktopDisplayMode();
257258 */
258259 private void glInit() {
259260 // Go into orthographic projection mode.
260 GL11.glMatrixMode(GL11.GL_PROJECTION);
261 GL11.glLoadIdentity();
262 GLU.gluOrtho2D(0, mode.getWidth(), 0, mode.getHeight());
263 GL11.glMatrixMode(GL11.GL_MODELVIEW);
264 GL11.glLoadIdentity();
265 GL11.glViewport(0, 0, mode.getWidth(), mode.getHeight());
261 glMatrixMode(GL_PROJECTION);
262 glLoadIdentity();
263 gluOrtho2D(0, mode.getWidth(), 0, mode.getHeight());
264 glMatrixMode(GL_MODELVIEW);
265 glLoadIdentity();
266 glViewport(0, 0, mode.getWidth(), mode.getHeight());
266267 //set clear color to black
267 GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
268 glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
268269 //sync frame (only works on windows)
269270 Display.setVSyncEnabled(true);
270271 }
3838
3939 import org.lwjgl.BufferUtils;
4040 import org.lwjgl.LWJGLException;
41 import org.lwjgl.opengl.ARBTransposeMatrix;
41 import org.lwjgl.LWJGLUtil;
42 import org.lwjgl.Sys;
4243 import org.lwjgl.opengl.Display;
4344 import org.lwjgl.opengl.DisplayMode;
44 import org.lwjgl.opengl.GL11;
4545 import org.lwjgl.opengl.GLContext;
46
47 import static org.lwjgl.opengl.ARBTransposeMatrix.*;
48 import static org.lwjgl.opengl.GL11.*;
4649
4750 /**
4851 * <p>
4952 * This is the OpenGL "standard" Gears demo, originally by Brian Paul
5053 * </p>
5154 * @author Brian Matzon <brian@matzon.dk>
52 * @version $Revision: 3276 $
53 * $Id: Gears.java 3276 2010-02-21 21:18:17Z matzon $
55 * @version $Revision: 3418 $
56 * $Id: Gears.java 3418 2010-09-28 21:11:35Z spasi $
5457 */
5558 public class Gears {
5659
5861
5962 private float view_roty = 30.0f;
6063
61 private float view_rotz = 0.0f;
64 private float view_rotz;
6265
6366 private int gear1;
6467
6669
6770 private int gear3;
6871
69 private float angle = 0.0f;
72 private float angle;
7073
7174 public static void main(String[] args) {
7275 new Gears().execute();
7477 }
7578
7679 /**
77 *
80 *
7881 */
7982 private void execute() {
8083 try {
9194 }
9295
9396 /**
94 *
97 *
9598 */
9699 private void destroy() {
97100 Display.destroy();
98101 }
99102
100103 /**
101 *
104 *
102105 */
103106 private void loop() {
104107 long startTime = System.currentTimeMillis() + 5000;
107110 while (!Display.isCloseRequested()) {
108111 angle += 2.0f;
109112
110 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
111
112 GL11.glPushMatrix();
113 GL11.glRotatef(view_rotx, 1.0f, 0.0f, 0.0f);
114 GL11.glRotatef(view_roty, 0.0f, 1.0f, 0.0f);
115 GL11.glRotatef(view_rotz, 0.0f, 0.0f, 1.0f);
116
117 GL11.glPushMatrix();
118 GL11.glTranslatef(-3.0f, -2.0f, 0.0f);
119 GL11.glRotatef(angle, 0.0f, 0.0f, 1.0f);
120 GL11.glCallList(gear1);
121 GL11.glPopMatrix();
122
123 GL11.glPushMatrix();
124 GL11.glTranslatef(3.1f, -2.0f, 0.0f);
125 GL11.glRotatef(-2.0f * angle - 9.0f, 0.0f, 0.0f, 1.0f);
126 GL11.glCallList(gear2);
127 GL11.glPopMatrix();
128
129 GL11.glPushMatrix();
130 GL11.glTranslatef(-3.1f, 4.2f, 0.0f);
131 GL11.glRotatef(-2.0f * angle - 25.0f, 0.0f, 0.0f, 1.0f);
132 GL11.glCallList(gear3);
133 GL11.glPopMatrix();
134
135 GL11.glPopMatrix();
113 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
114
115 glPushMatrix();
116 glRotatef(view_rotx, 1.0f, 0.0f, 0.0f);
117 glRotatef(view_roty, 0.0f, 1.0f, 0.0f);
118 glRotatef(view_rotz, 0.0f, 0.0f, 1.0f);
119
120 glPushMatrix();
121 glTranslatef(-3.0f, -2.0f, 0.0f);
122 glRotatef(angle, 0.0f, 0.0f, 1.0f);
123 glCallList(gear1);
124 glPopMatrix();
125
126 glPushMatrix();
127 glTranslatef(3.1f, -2.0f, 0.0f);
128 glRotatef(-2.0f * angle - 9.0f, 0.0f, 0.0f, 1.0f);
129 glCallList(gear2);
130 glPopMatrix();
131
132 glPushMatrix();
133 glTranslatef(-3.1f, 4.2f, 0.0f);
134 glRotatef(-2.0f * angle - 25.0f, 0.0f, 0.0f, 1.0f);
135 glCallList(gear3);
136 glPopMatrix();
137
138 glPopMatrix();
136139
137140 Display.update();
138141 if (startTime > System.currentTimeMillis()) {
140143 } else {
141144 long timeUsed = 5000 + (startTime - System.currentTimeMillis());
142145 startTime = System.currentTimeMillis() + 5000;
143 System.out.println(fps + " frames in " + (float) (timeUsed / 1000f) + " seconds = "
146 System.out.println(fps + " frames in " + timeUsed / 1000f + " seconds = "
144147 + (fps / (timeUsed / 1000f)));
145148 fps = 0;
146149 }
148151 }
149152
150153 /**
151 *
154 *
152155 */
153156 private void init() throws LWJGLException {
154157 // create Window of size 300x300
163166 FloatBuffer red = BufferUtils.createFloatBuffer(4).put(new float[] { 0.8f, 0.1f, 0.0f, 1.0f});
164167 FloatBuffer green = BufferUtils.createFloatBuffer(4).put(new float[] { 0.0f, 0.8f, 0.2f, 1.0f});
165168 FloatBuffer blue = BufferUtils.createFloatBuffer(4).put(new float[] { 0.2f, 0.2f, 1.0f, 1.0f});
166
169
167170 pos.flip();
168171 red.flip();
169172 green.flip();
170173 blue.flip();
171174
172 GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, pos);
173 GL11.glEnable(GL11.GL_CULL_FACE);
174 GL11.glEnable(GL11.GL_LIGHTING);
175 GL11.glEnable(GL11.GL_LIGHT0);
176 GL11.glEnable(GL11.GL_DEPTH_TEST);
175 glLight(GL_LIGHT0, GL_POSITION, pos);
176 glEnable(GL_CULL_FACE);
177 glEnable(GL_LIGHTING);
178 glEnable(GL_LIGHT0);
179 glEnable(GL_DEPTH_TEST);
177180
178181 /* make the gears */
179 gear1 = GL11.glGenLists(1);
180 GL11.glNewList(gear1, GL11.GL_COMPILE);
181 GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE, red);
182 gear1 = glGenLists(1);
183 glNewList(gear1, GL_COMPILE);
184 glMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red);
182185 gear(1.0f, 4.0f, 1.0f, 20, 0.7f);
183 GL11.glEndList();
184
185 gear2 = GL11.glGenLists(1);
186 GL11.glNewList(gear2, GL11.GL_COMPILE);
187 GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE, green);
186 glEndList();
187
188 gear2 = glGenLists(1);
189 glNewList(gear2, GL_COMPILE);
190 glMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green);
188191 gear(0.5f, 2.0f, 2.0f, 10, 0.7f);
189 GL11.glEndList();
190
191 gear3 = GL11.glGenLists(1);
192 GL11.glNewList(gear3, GL11.GL_COMPILE);
193 GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE, blue);
192 glEndList();
193
194 gear3 = glGenLists(1);
195 glNewList(gear3, GL_COMPILE);
196 glMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue);
194197 gear(1.3f, 2.0f, 0.5f, 10, 0.7f);
195 GL11.glEndList();
196
197 GL11.glEnable(GL11.GL_NORMALIZE);
198
199 GL11.glMatrixMode(GL11.GL_PROJECTION);
200
201 System.err.println("GL_VENDOR: " + GL11.glGetString(GL11.GL_VENDOR));
202 System.err.println("GL_RENDERER: " + GL11.glGetString(GL11.GL_RENDERER));
203 System.err.println("GL_VERSION: " + GL11.glGetString(GL11.GL_VERSION));
198 glEndList();
199
200 glEnable(GL_NORMALIZE);
201
202 glMatrixMode(GL_PROJECTION);
203
204 System.err.println("LWJGL: " + Sys.getVersion() + " / " + LWJGLUtil.getPlatformName());
205 System.err.println("GL_VENDOR: " + glGetString(GL_VENDOR));
206 System.err.println("GL_RENDERER: " + glGetString(GL_RENDERER));
207 System.err.println("GL_VERSION: " + glGetString(GL_VERSION));
204208 System.err.println();
205209 System.err.println("glLoadTransposeMatrixfARB() supported: " + GLContext.getCapabilities().GL_ARB_transpose_matrix);
206210 if (!GLContext.getCapabilities().GL_ARB_transpose_matrix) {
207211 // --- not using extensions
208 GL11.glLoadIdentity();
212 glLoadIdentity();
209213 } else {
210214 // --- using extensions
211215 final FloatBuffer identityTranspose = BufferUtils.createFloatBuffer(16).put(
212216 new float[] { 1, 0, 0, 0, 0, 1, 0, 0,
213217 0, 0, 1, 0, 0, 0, 0, 1});
214218 identityTranspose.flip();
215 ARBTransposeMatrix.glLoadTransposeMatrixARB(identityTranspose);
219 glLoadTransposeMatrixARB(identityTranspose);
216220 }
217221
218222 float h = (float) 300 / (float) 300;
219 GL11.glFrustum(-1.0f, 1.0f, -h, h, 5.0f, 60.0f);
220 GL11.glMatrixMode(GL11.GL_MODELVIEW);
221 GL11.glLoadIdentity();
222 GL11.glTranslatef(0.0f, 0.0f, -40.0f);
223 glFrustum(-1.0f, 1.0f, -h, h, 5.0f, 60.0f);
224 glMatrixMode(GL_MODELVIEW);
225 glLoadIdentity();
226 glTranslatef(0.0f, 0.0f, -40.0f);
223227 }
224228
225229 /**
244248
245249 da = 2.0f * (float) Math.PI / teeth / 4.0f;
246250
247 GL11.glShadeModel(GL11.GL_FLAT);
248
249 GL11.glNormal3f(0.0f, 0.0f, 1.0f);
251 glShadeModel(GL_FLAT);
252
253 glNormal3f(0.0f, 0.0f, 1.0f);
250254
251255 /* draw front face */
252 GL11.glBegin(GL11.GL_QUAD_STRIP);
256 glBegin(GL_QUAD_STRIP);
253257 for (i = 0; i <= teeth; i++) {
254258 angle = i * 2.0f * (float) Math.PI / teeth;
255 GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f);
256 GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f);
259 glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f);
260 glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f);
257261 if (i < teeth) {
258 GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f);
259 GL11.glVertex3f(r1 * (float) Math.cos(angle + 3.0f * da), r1 * (float) Math.sin(angle + 3.0f * da),
262 glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f);
263 glVertex3f(r1 * (float) Math.cos(angle + 3.0f * da), r1 * (float) Math.sin(angle + 3.0f * da),
260264 width * 0.5f);
261265 }
262266 }
263 GL11.glEnd();
267 glEnd();
264268
265269 /* draw front sides of teeth */
266 GL11.glBegin(GL11.GL_QUADS);
270 glBegin(GL_QUADS);
267271 for (i = 0; i < teeth; i++) {
268272 angle = i * 2.0f * (float) Math.PI / teeth;
269 GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f);
270 GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), width * 0.5f);
271 GL11.glVertex3f(r2 * (float) Math.cos(angle + 2.0f * da), r2 * (float) Math.sin(angle + 2.0f * da), width * 0.5f);
272 GL11.glVertex3f(r1 * (float) Math.cos(angle + 3.0f * da), r1 * (float) Math.sin(angle + 3.0f * da), width * 0.5f);
273 }
274 GL11.glEnd();
273 glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f);
274 glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), width * 0.5f);
275 glVertex3f(r2 * (float) Math.cos(angle + 2.0f * da), r2 * (float) Math.sin(angle + 2.0f * da), width * 0.5f);
276 glVertex3f(r1 * (float) Math.cos(angle + 3.0f * da), r1 * (float) Math.sin(angle + 3.0f * da), width * 0.5f);
277 }
278 glEnd();
275279
276280 /* draw back face */
277 GL11.glBegin(GL11.GL_QUAD_STRIP);
281 glBegin(GL_QUAD_STRIP);
278282 for (i = 0; i <= teeth; i++) {
279283 angle = i * 2.0f * (float) Math.PI / teeth;
280 GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f);
281 GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f);
282 GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f);
283 GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f);
284 }
285 GL11.glEnd();
284 glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f);
285 glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f);
286 glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f);
287 glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f);
288 }
289 glEnd();
286290
287291 /* draw back sides of teeth */
288 GL11.glBegin(GL11.GL_QUADS);
292 glBegin(GL_QUADS);
289293 for (i = 0; i < teeth; i++) {
290294 angle = i * 2.0f * (float) Math.PI / teeth;
291 GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f);
292 GL11.glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), -width * 0.5f);
293 GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), -width * 0.5f);
294 GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f);
295 }
296 GL11.glEnd();
295 glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f);
296 glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), -width * 0.5f);
297 glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), -width * 0.5f);
298 glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f);
299 }
300 glEnd();
297301
298302 /* draw outward faces of teeth */
299 GL11.glBegin(GL11.GL_QUAD_STRIP);
303 glBegin(GL_QUAD_STRIP);
300304 for (i = 0; i < teeth; i++) {
301305 angle = i * 2.0f * (float) Math.PI / teeth;
302 GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f);
303 GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f);
306 glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f);
307 glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f);
304308 u = r2 * (float) Math.cos(angle + da) - r1 * (float) Math.cos(angle);
305309 v = r2 * (float) Math.sin(angle + da) - r1 * (float) Math.sin(angle);
306310 len = (float) Math.sqrt(u * u + v * v);
307311 u /= len;
308312 v /= len;
309 GL11.glNormal3f(v, -u, 0.0f);
310 GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), width * 0.5f);
311 GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), -width * 0.5f);
312 GL11.glNormal3f((float) Math.cos(angle), (float) Math.sin(angle), 0.0f);
313 GL11.glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), width * 0.5f);
314 GL11.glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), -width * 0.5f);
313 glNormal3f(v, -u, 0.0f);
314 glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), width * 0.5f);
315 glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), -width * 0.5f);
316 glNormal3f((float) Math.cos(angle), (float) Math.sin(angle), 0.0f);
317 glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), width * 0.5f);
318 glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), -width * 0.5f);
315319 u = r1 * (float) Math.cos(angle + 3 * da) - r2 * (float) Math.cos(angle + 2 * da);
316320 v = r1 * (float) Math.sin(angle + 3 * da) - r2 * (float) Math.sin(angle + 2 * da);
317 GL11.glNormal3f(v, -u, 0.0f);
318 GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), width * 0.5f);
319 GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f);
320 GL11.glNormal3f((float) Math.cos(angle), (float) Math.sin(angle), 0.0f);
321 }
322 GL11.glVertex3f(r1 * (float) Math.cos(0), r1 * (float) Math.sin(0), width * 0.5f);
323 GL11.glVertex3f(r1 * (float) Math.cos(0), r1 * (float) Math.sin(0), -width * 0.5f);
324 GL11.glEnd();
325
326 GL11.glShadeModel(GL11.GL_SMOOTH);
321 glNormal3f(v, -u, 0.0f);
322 glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), width * 0.5f);
323 glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f);
324 glNormal3f((float) Math.cos(angle), (float) Math.sin(angle), 0.0f);
325 }
326 glVertex3f(r1 * (float) Math.cos(0), r1 * (float) Math.sin(0), width * 0.5f);
327 glVertex3f(r1 * (float) Math.cos(0), r1 * (float) Math.sin(0), -width * 0.5f);
328 glEnd();
329
330 glShadeModel(GL_SMOOTH);
327331
328332 /* draw inside radius cylinder */
329 GL11.glBegin(GL11.GL_QUAD_STRIP);
333 glBegin(GL_QUAD_STRIP);
330334 for (i = 0; i <= teeth; i++) {
331335 angle = i * 2.0f * (float) Math.PI / teeth;
332 GL11.glNormal3f(-(float) Math.cos(angle), -(float) Math.sin(angle), 0.0f);
333 GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f);
334 GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f);
335 }
336 GL11.glEnd();
336 glNormal3f(-(float) Math.cos(angle), -(float) Math.sin(angle), 0.0f);
337 glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f);
338 glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f);
339 }
340 glEnd();
337341 }
338342 }
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 */
3838 import org.lwjgl.input.Keyboard;
3939 import org.lwjgl.opengl.Display;
4040 import org.lwjgl.opengl.DisplayMode;
41 import org.lwjgl.opengl.GL11;
4241 import org.lwjgl.opengl.Pbuffer;
4342 import org.lwjgl.opengl.PixelFormat;
44 import org.lwjgl.util.glu.GLU;
4543 import org.lwjgl.util.vector.Vector2f;
4644
45 import static org.lwjgl.opengl.GL11.*;
46 import static org.lwjgl.util.glu.GLU.*;
47
4748 /**
4849 *
4950 * Tests Pbuffers
5051 *
5152 * @author elias_naur <elias_naur@users.sourceforge.net>
52 * @version $Revision: 2983 $
53 * $Id: PbufferTest.java 2983 2008-04-07 18:36:09Z matzon $
53 * @version $Revision: 3418 $
54 * $Id: PbufferTest.java 3418 2010-09-28 21:11:35Z spasi $
5455 */
5556 public class PbufferTest {
5657
188189 }
189190 // Pbuffer rendering
190191 //clear background
191 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
192 glClear(GL_COLOR_BUFFER_BIT);
192193
193194 // draw white quad
194 GL11.glPushMatrix();
195 glPushMatrix();
195196 {
196 GL11.glTranslatef(quadPosition.x, quadPosition.y, 0);
197 GL11.glRotatef(angle, 0.0f, 0.0f, 1.0f);
198 GL11.glColor3f(1.0f, 1.0f, 1.0f);
199 GL11.glBegin(GL11.GL_QUADS);
197 glTranslatef(quadPosition.x, quadPosition.y, 0);
198 glRotatef(angle, 0.0f, 0.0f, 1.0f);
199 glColor3f(1.0f, 1.0f, 1.0f);
200 glBegin(GL_QUADS);
200201 {
201 GL11.glVertex2i(-50, -50);
202 GL11.glVertex2i(50, -50);
203 GL11.glVertex2i(50, 50);
204 GL11.glVertex2i(-50, 50);
205 }
206 GL11.glEnd();
207 }
208 GL11.glPopMatrix();
209 GL11.glCopyTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB, 0, 0, 512, 512, 0);
202 glVertex2i(-50, -50);
203 glVertex2i(50, -50);
204 glVertex2i(50, 50);
205 glVertex2i(-50, 50);
206 }
207 glEnd();
208 }
209 glPopMatrix();
210 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, 512, 512, 0);
210211 try {
211212 Display.makeCurrent();
212213 } catch (LWJGLException e) {
214215 }
215216
216217 // OpenGL window rendering
217 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
218 glClear(GL_COLOR_BUFFER_BIT);
218219 // draw white quad
219 GL11.glPushMatrix();
220 glPushMatrix();
220221 {
221 GL11.glTranslatef(quadPosition.x, quadPosition.y, 0);
222 GL11.glRotatef(angle, 0.0f, 0.0f, 1.0f);
223 GL11.glColor3f(1.0f, 1.0f, 0.0f);
224 GL11.glBegin(GL11.GL_QUADS);
222 glTranslatef(quadPosition.x, quadPosition.y, 0);
223 glRotatef(angle, 0.0f, 0.0f, 1.0f);
224 glColor3f(1.0f, 1.0f, 0.0f);
225 glBegin(GL_QUADS);
225226 {
226 GL11.glTexCoord2f(0f, 0f);
227 GL11.glVertex2i(-50, -50);
228 GL11.glTexCoord2f(1f, 0f);
229 GL11.glVertex2i(50, -50);
230 GL11.glTexCoord2f(1f, 1f);
231 GL11.glVertex2i(50, 50);
232 GL11.glTexCoord2f(0f, 1f);
233 GL11.glVertex2i(-50, 50);
234 }
235 GL11.glEnd();
236 }
237 GL11.glPopMatrix();
227 glTexCoord2f(0f, 0f);
228 glVertex2i(-50, -50);
229 glTexCoord2f(1f, 0f);
230 glVertex2i(50, -50);
231 glTexCoord2f(1f, 1f);
232 glVertex2i(50, 50);
233 glTexCoord2f(0f, 1f);
234 glVertex2i(-50, 50);
235 }
236 glEnd();
237 }
238 glPopMatrix();
238239 }
239240
240241 private void initPbuffer() {
241242 try {
242243 pbuffer.makeCurrent();
243244 initGLState(256, 256, 0.5f);
244 GL11.glBindTexture(GL11.GL_TEXTURE_2D, tex_handle);
245 glBindTexture(GL_TEXTURE_2D, tex_handle);
245246 Display.makeCurrent();
246247 } catch (Exception e) {
247248 e.printStackTrace();
320321 private void destroyTexture() {
321322 IntBuffer buffer = ByteBuffer.allocateDirect(4).order(ByteOrder.nativeOrder()).asIntBuffer();
322323 buffer.put(0, tex_handle);
323 GL11.glDeleteTextures(buffer);
324 glDeleteTextures(buffer);
324325 }
325326
326327 /**
342343 */
343344 private DisplayMode findDisplayMode(int width, int height, int bpp) throws LWJGLException {
344345 DisplayMode[] modes = Display.getAvailableDisplayModes();
345 for (int i = 0; i < modes.length; i++) {
346 if (modes[i].getWidth() == width
347 && modes[i].getHeight() == height
348 && modes[i].getBitsPerPixel() >= bpp) {
349 return modes[i];
350 }
351 }
346 for ( DisplayMode mode : modes ) {
347 if ( mode.getWidth() == width && mode.getHeight() == height && mode.getBitsPerPixel() >= bpp )
348 return mode;
349 }
352350 return null;
353351 }
354352
355353 private void initGLState(int width, int height, float color) {
356 GL11.glMatrixMode(GL11.GL_PROJECTION);
357 GL11.glLoadIdentity();
358 GLU.gluOrtho2D(0, mode.getWidth(), 0, mode.getHeight());
359 GL11.glMatrixMode(GL11.GL_MODELVIEW);
360 GL11.glLoadIdentity();
361 GL11.glViewport(0, 0, width, height);
354 glMatrixMode(GL_PROJECTION);
355 glLoadIdentity();
356 gluOrtho2D(0, mode.getWidth(), 0, mode.getHeight());
357 glMatrixMode(GL_MODELVIEW);
358 glLoadIdentity();
359 glViewport(0, 0, width, height);
362360
363361 //set clear color to black
364 GL11.glClearColor(color, color, color, 0.0f);
362 glClearColor(color, color, color, 0.0f);
365363 }
366364
367365 /**
370368 private void glInit() {
371369 //sync frame (only works on windows)
372370 Display.setVSyncEnabled(true);
373
374 GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_REPLACE);
375 GL11.glEnable(GL11.GL_TEXTURE_2D);
371
372 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
373 glEnable(GL_TEXTURE_2D);
376374 // Create shared texture
377375 IntBuffer buffer = ByteBuffer.allocateDirect(4).order(ByteOrder.nativeOrder()).asIntBuffer();
378 GL11.glGenTextures(buffer);
376 glGenTextures(buffer);
379377 tex_handle = buffer.get(0);
380 GL11.glBindTexture(GL11.GL_TEXTURE_2D, tex_handle);
381 GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP);
382 GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP);
383 GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
384 GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
378 glBindTexture(GL_TEXTURE_2D, tex_handle);
379 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
380 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
381 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
382 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
385383 initGLState(mode.getWidth(), mode.getHeight(), 0f);
386384 }
387385
3535 import org.lwjgl.opengl.*;
3636
3737 import java.util.Random;
38
39 import static org.lwjgl.opengl.GL11.*;
40 import static org.lwjgl.opengl.GL32.*;
3841
3942 /** @author spasi <spasi@users.sourceforge.net> */
4043 public final class SyncTest {
8487
8588 System.out.println("\n---------\n");
8689
87 final String version = GL11.glGetString(GL11.GL_VERSION);
90 final String version = glGetString(GL_VERSION);
8891
8992 System.out.println("GL Version: " + version);
9093 System.out.println("ARB_sync: " + GLContext.getCapabilities().GL_ARB_sync);
98101
99102 Random rand = new Random(System.currentTimeMillis());
100103 for ( int i = 0; i < clears; i++ ) {
101 GL11.glClearColor(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), 1.0f);
102 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
104 glClearColor(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), 1.0f);
105 glClear(GL_COLOR_BUFFER_BIT);
103106 }
104107
105 GLSync sync = GL32.glFenceSync(GL32.GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
108 GLSync sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
106109
107110 System.out.println("\nWaiting on fence...");
108111 long time = Sys.getTime();
109 int status = GL32.glClientWaitSync(sync, 0, timeout < 0 ? GL32.GL_TIMEOUT_IGNORED : timeout * 1000 * 1000);
112 int status = glClientWaitSync(sync, 0, timeout < 0 ? GL_TIMEOUT_IGNORED : timeout * 1000 * 1000);
110113 System.out.println("\nFence sync complete after: " + ((Sys.getTime() - time) / (double)Sys.getTimerResolution()) + " seconds.");
111114 System.out.print("\nWait Status: ");
112115 switch ( status ) {
113 case GL32.GL_ALREADY_SIGNALED:
116 case GL_ALREADY_SIGNALED:
114117 System.out.println("ALREADY_SIGNALED");
115118 break;
116 case GL32.GL_CONDITION_SATISFIED:
119 case GL_CONDITION_SATISFIED:
117120 System.out.println("CONDITION_SATISFIED");
118121 break;
119 case GL32.GL_TIMEOUT_EXPIRED:
122 case GL_TIMEOUT_EXPIRED:
120123 System.out.println("TIMEOUT_EXPIRED");
121124 break;
122 case GL32.GL_WAIT_FAILED:
125 case GL_WAIT_FAILED:
123126 System.out.println("WAIT_FAILED");
124127 break;
125128 default:
126129 System.out.println("Unexpected wait status: 0x" + Integer.toHexString(status));
127130 }
128131
129 System.out.println("Sync Status: " + (GL32.glGetSync(sync, GL32.GL_SYNC_STATUS) == GL32.GL_UNSIGNALED ? "UNSIGNALED" : "SIGNALED"));
132 System.out.println("Sync Status: " + (glGetSync(sync, GL_SYNC_STATUS) == GL_UNSIGNALED ? "UNSIGNALED" : "SIGNALED"));
130133
131 GL32.glDeleteSync(sync);
134 glDeleteSync(sync);
132135
133 int error = GL11.glGetError();
136 int error = glGetError();
134137 if ( error != 0 )
135138 System.out.println("\nTest failed with OpenGL error: " + error);
136139 else
140143 private static DisplayMode chooseMode(DisplayMode[] modes, int width, int height) {
141144 DisplayMode bestMode = null;
142145
143 for ( int i = 0; i < modes.length; i++ ) {
144 DisplayMode mode = modes[i];
146 for ( DisplayMode mode : modes ) {
145147 if ( mode.getWidth() == width && mode.getHeight() == height && mode.getFrequency() <= 85 ) {
146148 if ( bestMode == null || (mode.getBitsPerPixel() >= bestMode.getBitsPerPixel() && mode.getFrequency() > bestMode.getFrequency()) )
147149 bestMode = mode;
3030 */
3131
3232 /**
33 * $Id: VBOIndexTest.java 3344 2010-05-22 16:53:49Z spasi $
33 * $Id: VBOIndexTest.java 3418 2010-09-28 21:11:35Z spasi $
3434 *
3535 * Simple java test program.
3636 *
3737 * @author elias_naur <elias_naur@users.sourceforge.net>
38 * @version $Revision: 3344 $
38 * @version $Revision: 3418 $
3939 */
4040
4141 package org.lwjgl.test.opengl;
4848 import org.lwjgl.Sys;
4949 import org.lwjgl.input.Keyboard;
5050 import org.lwjgl.input.Mouse;
51 import org.lwjgl.opengl.ARBBufferObject;
52 import org.lwjgl.opengl.ARBVertexBufferObject;
5351 import org.lwjgl.opengl.Display;
5452 import org.lwjgl.opengl.DisplayMode;
55 import org.lwjgl.opengl.GL11;
5653 import org.lwjgl.opengl.GLContext;
57 import org.lwjgl.util.glu.GLU;
54
55 import static org.lwjgl.opengl.ARBBufferObject.*;
56 import static org.lwjgl.opengl.ARBVertexBufferObject.*;
57 import static org.lwjgl.opengl.GL11.*;
58 import static org.lwjgl.util.glu.GLU.*;
5859
5960 public final class VBOIndexTest {
6061
104105 private static int buffer_id;
105106 private static int indices_buffer_id;
106107 private static FloatBuffer vertices;
107 private static ByteBuffer mapped_buffer = null;
108 private static FloatBuffer mapped_float_buffer = null;
108 private static ByteBuffer mapped_buffer;
109 private static FloatBuffer mapped_float_buffer;
109110 private static IntBuffer indices;
110 private static ByteBuffer mapped_indices_buffer = null;
111 private static IntBuffer mapped_indices_int_buffer = null;
111 private static ByteBuffer mapped_indices_buffer;
112 private static IntBuffer mapped_indices_int_buffer;
112113
113114 public static void main(String[] arguments) {
114115 try {
160161 * All rendering is done in here
161162 */
162163 private static void render() {
163 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
164 GL11.glPushMatrix();
165 GL11.glTranslatef(Display.getDisplayMode().getWidth() / 2, Display.getDisplayMode().getHeight() / 2, 0.0f);
166 GL11.glRotatef(angle, 0, 0, 1.0f);
167
168
169 ByteBuffer new_mapped_buffer = ARBBufferObject.glMapBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB,
170 ARBBufferObject.GL_WRITE_ONLY_ARB,
164 glClear(GL_COLOR_BUFFER_BIT);
165 glPushMatrix();
166 glTranslatef(Display.getDisplayMode().getWidth() / 2, Display.getDisplayMode().getHeight() / 2, 0.0f);
167 glRotatef(angle, 0, 0, 1.0f);
168
169
170 ByteBuffer new_mapped_buffer = glMapBufferARB(GL_ARRAY_BUFFER_ARB,
171 GL_WRITE_ONLY_ARB,
171172 mapped_buffer);
172173 if ( new_mapped_buffer != mapped_buffer )
173174 mapped_float_buffer = new_mapped_buffer.order(ByteOrder.nativeOrder()).asFloatBuffer();
174175 mapped_buffer = new_mapped_buffer;
175176
176 new_mapped_buffer = ARBBufferObject.glMapBufferARB(ARBVertexBufferObject.GL_ELEMENT_ARRAY_BUFFER_ARB,
177 ARBBufferObject.GL_WRITE_ONLY_ARB,
177 new_mapped_buffer = glMapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB,
178 GL_WRITE_ONLY_ARB,
178179 mapped_indices_buffer);
179180 if ( new_mapped_buffer != mapped_indices_buffer )
180181 mapped_indices_int_buffer = new_mapped_buffer.order(ByteOrder.nativeOrder()).asIntBuffer();
187188 mapped_indices_int_buffer.rewind();
188189 indices.rewind();
189190 mapped_indices_int_buffer.put(indices);
190 if ( ARBBufferObject.glUnmapBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB) &&
191 ARBBufferObject.glUnmapBufferARB(ARBVertexBufferObject.GL_ELEMENT_ARRAY_BUFFER_ARB) ) {
192 GL11.glDrawElements(GL11.GL_QUADS, 4, GL11.GL_UNSIGNED_INT, 0);
193 }
194 GL11.glPopMatrix();
191 if ( glUnmapBufferARB(GL_ARRAY_BUFFER_ARB) &&
192 glUnmapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB) ) {
193 glDrawElements(GL_QUADS, 4, GL_UNSIGNED_INT, 0);
194 }
195 glPopMatrix();
195196 }
196197
197198 /**
201202
202203 System.out.println("Timer resolution: " + Sys.getTimerResolution());
203204 // Go into orthographic projection mode.
204 GL11.glMatrixMode(GL11.GL_PROJECTION);
205 GL11.glLoadIdentity();
206 GLU.gluOrtho2D(0, Display.getDisplayMode().getWidth(), 0, Display.getDisplayMode().getHeight());
207 GL11.glMatrixMode(GL11.GL_MODELVIEW);
208 GL11.glLoadIdentity();
209 GL11.glViewport(0, 0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight());
205 glMatrixMode(GL_PROJECTION);
206 glLoadIdentity();
207 gluOrtho2D(0, Display.getDisplayMode().getWidth(), 0, Display.getDisplayMode().getHeight());
208 glMatrixMode(GL_MODELVIEW);
209 glLoadIdentity();
210 glViewport(0, 0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight());
210211 if ( !GLContext.getCapabilities().GL_ARB_vertex_buffer_object ) {
211212 System.out.println("ARB VBO not supported!");
212213 System.exit(1);
213214 }
214215 IntBuffer int_buffer = ByteBuffer.allocateDirect(8).order(ByteOrder.nativeOrder()).asIntBuffer();
215 ARBBufferObject.glGenBuffersARB(int_buffer);
216 glGenBuffersARB(int_buffer);
216217 buffer_id = int_buffer.get(0);
217218 indices_buffer_id = int_buffer.get(1);
218 ARBBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, buffer_id);
219 ARBBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ELEMENT_ARRAY_BUFFER_ARB, indices_buffer_id);
219 glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffer_id);
220 glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, indices_buffer_id);
220221 vertices = ByteBuffer.allocateDirect(2 * 4 * 4).order(ByteOrder.nativeOrder()).asFloatBuffer();
221222 vertices.put(-50).put(-50).put(50).put(-50).put(50).put(50).put(-50).put(50);
222223 vertices.rewind();
223224 indices = ByteBuffer.allocateDirect(4 * 4).order(ByteOrder.nativeOrder()).asIntBuffer();
224225 indices.put(0).put(1).put(2).put(3);
225226 indices.rewind();
226 ARBBufferObject.glBufferDataARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, 2 * 4 * 4, ARBBufferObject.GL_STREAM_DRAW_ARB);
227 ARBBufferObject.glBufferDataARB(ARBVertexBufferObject.GL_ELEMENT_ARRAY_BUFFER_ARB, 4 * 4, ARBBufferObject.GL_STREAM_DRAW_ARB);
228 GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
229 GL11.glVertexPointer(2, GL11.GL_FLOAT, 0, 0);
227 glBufferDataARB(GL_ARRAY_BUFFER_ARB, 2 * 4 * 4, GL_STREAM_DRAW_ARB);
228 glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 4 * 4, GL_STREAM_DRAW_ARB);
229 glEnableClientState(GL_VERTEX_ARRAY);
230 glVertexPointer(2, GL_FLOAT, 0, 0);
230231 }
231232
232233 /**
236237 IntBuffer int_buffer = ByteBuffer.allocateDirect(8).order(ByteOrder.nativeOrder()).asIntBuffer();
237238 int_buffer.put(0, buffer_id);
238239 int_buffer.put(1, indices_buffer_id);
239 ARBBufferObject.glDeleteBuffersARB(int_buffer);
240 glDeleteBuffersARB(int_buffer);
240241 Display.destroy();
241242 }
242243 }
3030 */
3131
3232 /**
33 * $Id: VBOTest.java 3287 2010-03-14 23:24:40Z spasi $
33 * $Id: VBOTest.java 3418 2010-09-28 21:11:35Z spasi $
3434 *
3535 * Simple java test program.
3636 *
3737 * @author elias_naur <elias_naur@users.sourceforge.net>
38 * @version $Revision: 3287 $
38 * @version $Revision: 3418 $
3939 */
4040
4141 package org.lwjgl.test.opengl;
4747 import org.lwjgl.Sys;
4848 import org.lwjgl.input.Keyboard;
4949 import org.lwjgl.input.Mouse;
50 import org.lwjgl.opengl.ARBBufferObject;
51 import org.lwjgl.opengl.ARBVertexBufferObject;
5250 import org.lwjgl.opengl.Display;
5351 import org.lwjgl.opengl.DisplayMode;
54 import org.lwjgl.opengl.GL11;
5552 import org.lwjgl.opengl.GLContext;
56 import org.lwjgl.util.glu.GLU;
53
54 import static org.lwjgl.opengl.ARBBufferObject.*;
55 import static org.lwjgl.opengl.ARBVertexBufferObject.*;
56 import static org.lwjgl.opengl.GL11.*;
57 import static org.lwjgl.util.glu.GLU.*;
5758
5859 public final class VBOTest {
5960
102103 private static float angle;
103104 private static int buffer_id;
104105 private static FloatBuffer vertices;
105 private static ByteBuffer mapped_buffer = null;
106 private static FloatBuffer mapped_float_buffer = null;
106 private static ByteBuffer mapped_buffer;
107 private static FloatBuffer mapped_float_buffer;
107108
108109 public static void main(String[] arguments) {
109110 try {
155156 * All rendering is done in here
156157 */
157158 private static void render() {
158 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
159 GL11.glPushMatrix();
160 GL11.glTranslatef(Display.getDisplayMode().getWidth() / 2, Display.getDisplayMode().getHeight() / 2, 0.0f);
161 GL11.glRotatef(angle, 0, 0, 1.0f);
162 ByteBuffer new_mapped_buffer = ARBBufferObject.glMapBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB,
163 ARBBufferObject.GL_WRITE_ONLY_ARB,
159 glClear(GL_COLOR_BUFFER_BIT);
160 glPushMatrix();
161 glTranslatef(Display.getDisplayMode().getWidth() / 2, Display.getDisplayMode().getHeight() / 2, 0.0f);
162 glRotatef(angle, 0, 0, 1.0f);
163 ByteBuffer new_mapped_buffer = glMapBufferARB(GL_ARRAY_BUFFER_ARB,
164 GL_WRITE_ONLY_ARB,
164165 mapped_buffer);
165166 if ( new_mapped_buffer != mapped_buffer )
166167 mapped_float_buffer = new_mapped_buffer.order(ByteOrder.nativeOrder()).asFloatBuffer();
168169 mapped_float_buffer.rewind();
169170 vertices.rewind();
170171 mapped_float_buffer.put(vertices);
171 if ( ARBBufferObject.glUnmapBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB) )
172 GL11.glDrawArrays(GL11.GL_QUADS, 0, 4);
173 GL11.glPopMatrix();
172 if ( glUnmapBufferARB(GL_ARRAY_BUFFER_ARB) )
173 glDrawArrays(GL_QUADS, 0, 4);
174 glPopMatrix();
174175 }
175176
176177 /**
179180 private static void init() throws Exception {
180181 System.out.println("Timer resolution: " + Sys.getTimerResolution());
181182 // Go into orthographic projection mode.
182 GL11.glMatrixMode(GL11.GL_PROJECTION);
183 GL11.glLoadIdentity();
184 GLU.gluOrtho2D(0, Display.getDisplayMode().getWidth(), 0, Display.getDisplayMode().getHeight());
185 GL11.glMatrixMode(GL11.GL_MODELVIEW);
186 GL11.glLoadIdentity();
187 GL11.glViewport(0, 0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight());
183 glMatrixMode(GL_PROJECTION);
184 glLoadIdentity();
185 gluOrtho2D(0, Display.getDisplayMode().getWidth(), 0, Display.getDisplayMode().getHeight());
186 glMatrixMode(GL_MODELVIEW);
187 glLoadIdentity();
188 glViewport(0, 0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight());
188189 if ( !GLContext.getCapabilities().GL_ARB_vertex_buffer_object ) {
189190 System.out.println("ARB VBO not supported!");
190191 System.exit(1);
191192 }
192 buffer_id = ARBBufferObject.glGenBuffersARB();
193 ARBBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, buffer_id);
193 buffer_id = glGenBuffersARB();
194 glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffer_id);
194195 vertices = ByteBuffer.allocateDirect(2 * 4 * 4).order(ByteOrder.nativeOrder()).asFloatBuffer();
195196 vertices.put(-50).put(-50).put(50).put(-50).put(50).put(50).put(-50).put(50);
196 ARBBufferObject.glBufferDataARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, 2 * 4 * 4, ARBBufferObject.GL_STREAM_DRAW_ARB);
197 GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
198 GL11.glVertexPointer(2, GL11.GL_FLOAT, 0, 0);
197 glBufferDataARB(GL_ARRAY_BUFFER_ARB, 2 * 4 * 4, GL_STREAM_DRAW_ARB);
198 glEnableClientState(GL_VERTEX_ARRAY);
199 glVertexPointer(2, GL_FLOAT, 0, 0);
199200 }
200201
201202 /**
202203 * Cleanup
203204 */
204205 private static void cleanup() {
205 ARBBufferObject.glDeleteBuffersARB(buffer_id);
206 glDeleteBuffersARB(buffer_id);
206207 Display.destroy();
207208 }
208209 }
3636 import java.util.StringTokenizer;
3737 import java.util.regex.Pattern;
3838
39 import static org.lwjgl.opengl.GL11.*;
40 import static org.lwjgl.opengl.GL32.*;
41
3942 /**
4043 * Tests the ARB_create_context extension through the use of the ContextAttribs class.
4144 *
8083 ca = ca.withProfileCore(true);
8184 else if ( "compatibility".equalsIgnoreCase(args[i]) )
8285 ca = ca.withProfileCompatibility(true);
86 else if ( "es".equalsIgnoreCase(args[i]) )
87 ca = ca.withProfileES(true);
8388 else
8489 argsError("Unknown argument: \'" + args[i] + "\'");
8590 }
109114
110115 System.out.println("Requested " + ca);
111116
112 final String version = GL11.glGetString(GL11.GL_VERSION);
117 final String version = glGetString(GL_VERSION);
113118
114119 boolean deprecated = false;
115120 try {
116 GL11.glVertex3f(0.0f, 0.0f, 0.0f);
121 glVertex3f(0.0f, 0.0f, 0.0f);
117122 deprecated = true;
118123 } catch (Throwable t) {}
119124
126131 final boolean coreProfile;
127132
128133 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;
134 final int profileMask = glGetInteger(GL_CONTEXT_PROFILE_MASK);
135
136 compatibilityProfile = (profileMask & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT) != 0;
137 coreProfile = (profileMask & GL_CONTEXT_CORE_PROFILE_BIT) != 0;
133138 } else {
134139 compatibilityProfile = false;
135140 coreProfile = false;
212217 private static DisplayMode chooseMode(DisplayMode[] modes, int width, int height) {
213218 DisplayMode bestMode = null;
214219
215 for ( int i = 0; i < modes.length; i++ ) {
216 DisplayMode mode = modes[i];
220 for ( DisplayMode mode : modes ) {
217221 if ( mode.getWidth() == width && mode.getHeight() == height && mode.getFrequency() <= 85 ) {
218222 if ( bestMode == null || (mode.getBitsPerPixel() >= bestMode.getBitsPerPixel() && mode.getFrequency() > bestMode.getFrequency()) )
219223 bestMode = mode;
235239 System.out.println("majorVersion\t- Minor OpenGL version.");
236240 System.out.println("core\t- Sets the Core Profile bit (optional, requires 3.2+).");
237241 System.out.println("compatibility\t- Sets the Compatibility Profile bit (optional, requires 3.2+).");
242 System.out.println("ws\t- Sets the OpenGL ES Profile bit (optional, requires 2.0).");
238243 System.out.println("layer\t- Layer plane (optional).");
239244 System.out.println("debug\t- Enables debug mode (optional).");
240245 System.out.println("fc\t- Enables forward compatibility mode (optional, requires 3.0+).");
3838
3939 import org.lwjgl.BufferUtils;
4040 import org.lwjgl.LWJGLException;
41 import org.lwjgl.opengl.ARBTransposeMatrix;
41 import org.lwjgl.LWJGLUtil;
42 import org.lwjgl.Sys;
4243 import org.lwjgl.opengl.AWTGLCanvas;
43 import org.lwjgl.opengl.GL11;
4444 import org.lwjgl.opengl.GLContext;
45
46 import static org.lwjgl.opengl.ARBTransposeMatrix.*;
47 import static org.lwjgl.opengl.GL11.*;
4548
4649 /**
4750 * <p>
5255 * $Id$
5356 */
5457 public class AWTGears extends Frame {
55
58
5659 /** AWT GL canvas */
5760 private AWTGLCanvas canvas0;
58
61
5962 private float view_rotx = 20.0f;
6063
6164 private float view_roty = 30.0f;
6265
63 private float view_rotz = 0.0f;
66 private float view_rotz;
6467
6568 private int gear1;
6669
6871
6972 private int gear3;
7073
71 private float angle = 0.0f;
74 private float angle;
7275
7376 /**
7477 * C'tor
8992 pack();
9093 setVisible(true);
9194 }
92
95
9396 private void setup() {
9497 // setup ogl
9598 FloatBuffer pos = BufferUtils.createFloatBuffer(4).put(new float[] { 5.0f, 5.0f, 10.0f, 0.0f});
101104 green.flip();
102105 blue.flip();
103106
104 GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, pos);
105 GL11.glEnable(GL11.GL_CULL_FACE);
106 GL11.glEnable(GL11.GL_LIGHTING);
107 GL11.glEnable(GL11.GL_LIGHT0);
108 GL11.glEnable(GL11.GL_DEPTH_TEST);
107 glLight(GL_LIGHT0, GL_POSITION, pos);
108 glEnable(GL_CULL_FACE);
109 glEnable(GL_LIGHTING);
110 glEnable(GL_LIGHT0);
111 glEnable(GL_DEPTH_TEST);
109112
110113 /* make the gears */
111 gear1 = GL11.glGenLists(1);
112 GL11.glNewList(gear1, GL11.GL_COMPILE);
113 GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE, red);
114 gear1 = glGenLists(1);
115 glNewList(gear1, GL_COMPILE);
116 glMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red);
114117 gear(1.0f, 4.0f, 1.0f, 20, 0.7f);
115 GL11.glEndList();
116
117 gear2 = GL11.glGenLists(1);
118 GL11.glNewList(gear2, GL11.GL_COMPILE);
119 GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE, green);
118 glEndList();
119
120 gear2 = glGenLists(1);
121 glNewList(gear2, GL_COMPILE);
122 glMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green);
120123 gear(0.5f, 2.0f, 2.0f, 10, 0.7f);
121 GL11.glEndList();
122
123 gear3 = GL11.glGenLists(1);
124 GL11.glNewList(gear3, GL11.GL_COMPILE);
125 GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE, blue);
124 glEndList();
125
126 gear3 = glGenLists(1);
127 glNewList(gear3, GL_COMPILE);
128 glMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue);
126129 gear(1.3f, 2.0f, 0.5f, 10, 0.7f);
127 GL11.glEndList();
128
129 GL11.glEnable(GL11.GL_NORMALIZE);
130
131 GL11.glMatrixMode(GL11.GL_PROJECTION);
132
133 System.err.println("GL_VENDOR: " + GL11.glGetString(GL11.GL_VENDOR));
134 System.err.println("GL_RENDERER: " + GL11.glGetString(GL11.GL_RENDERER));
135 System.err.println("GL_VERSION: " + GL11.glGetString(GL11.GL_VERSION));
130 glEndList();
131
132 glEnable(GL_NORMALIZE);
133
134 glMatrixMode(GL_PROJECTION);
135
136 System.err.println("LWJGL: " + Sys.getVersion() + " / " + LWJGLUtil.getPlatformName());
137 System.err.println("GL_VENDOR: " + glGetString(GL_VENDOR));
138 System.err.println("GL_RENDERER: " + glGetString(GL_RENDERER));
139 System.err.println("GL_VERSION: " + glGetString(GL_VERSION));
136140 System.err.println();
137141 System.err.println("glLoadTransposeMatrixfARB() supported: " + GLContext.getCapabilities().GL_ARB_transpose_matrix);
138142 if (!GLContext.getCapabilities().GL_ARB_transpose_matrix) {
139143 // --- not using extensions
140 GL11.glLoadIdentity();
144 glLoadIdentity();
141145 } else {
142146 // --- using extensions
143147 final FloatBuffer identityTranspose = BufferUtils.createFloatBuffer(16).put(
144148 new float[] { 1, 0, 0, 0, 0, 1, 0, 0,
145149 0, 0, 1, 0, 0, 0, 0, 1});
146150 identityTranspose.flip();
147 ARBTransposeMatrix.glLoadTransposeMatrixARB(identityTranspose);
151 glLoadTransposeMatrixARB(identityTranspose);
148152 }
149153
150154 float h = (float) 300 / (float) 300;
151 GL11.glFrustum(-1.0f, 1.0f, -h, h, 5.0f, 60.0f);
152 GL11.glMatrixMode(GL11.GL_MODELVIEW);
153 GL11.glLoadIdentity();
154 GL11.glTranslatef(0.0f, 0.0f, -40.0f);
155 }
156
155 glFrustum(-1.0f, 1.0f, -h, h, 5.0f, 60.0f);
156 glMatrixMode(GL_MODELVIEW);
157 glLoadIdentity();
158 glTranslatef(0.0f, 0.0f, -40.0f);
159 }
160
157161 /**
158162 * Draw a gear wheel. You'll probably want to call this function when
159163 * building a display list since we do a lot of trig here.
176180
177181 da = 2.0f * (float) Math.PI / teeth / 4.0f;
178182
179 GL11.glShadeModel(GL11.GL_FLAT);
180
181 GL11.glNormal3f(0.0f, 0.0f, 1.0f);
183 glShadeModel(GL_FLAT);
184
185 glNormal3f(0.0f, 0.0f, 1.0f);
182186
183187 /* draw front face */
184 GL11.glBegin(GL11.GL_QUAD_STRIP);
188 glBegin(GL_QUAD_STRIP);
185189 for (i = 0; i <= teeth; i++) {
186190 angle = i * 2.0f * (float) Math.PI / teeth;
187 GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f);
188 GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f);
191 glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f);
192 glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f);
189193 if (i < teeth) {
190 GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f);
191 GL11.glVertex3f(r1 * (float) Math.cos(angle + 3.0f * da), r1 * (float) Math.sin(angle + 3.0f * da),
194 glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f);
195 glVertex3f(r1 * (float) Math.cos(angle + 3.0f * da), r1 * (float) Math.sin(angle + 3.0f * da),
192196 width * 0.5f);
193197 }
194198 }
195 GL11.glEnd();
199 glEnd();
196200
197201 /* draw front sides of teeth */
198 GL11.glBegin(GL11.GL_QUADS);
202 glBegin(GL_QUADS);
199203 for (i = 0; i < teeth; i++) {
200204 angle = i * 2.0f * (float) Math.PI / teeth;
201 GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f);
202 GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), width * 0.5f);
203 GL11.glVertex3f(r2 * (float) Math.cos(angle + 2.0f * da), r2 * (float) Math.sin(angle + 2.0f * da), width * 0.5f);
204 GL11.glVertex3f(r1 * (float) Math.cos(angle + 3.0f * da), r1 * (float) Math.sin(angle + 3.0f * da), width * 0.5f);
205 }
206 GL11.glEnd();
205 glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f);
206 glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), width * 0.5f);
207 glVertex3f(r2 * (float) Math.cos(angle + 2.0f * da), r2 * (float) Math.sin(angle + 2.0f * da), width * 0.5f);
208 glVertex3f(r1 * (float) Math.cos(angle + 3.0f * da), r1 * (float) Math.sin(angle + 3.0f * da), width * 0.5f);
209 }
210 glEnd();
207211
208212 /* draw back face */
209 GL11.glBegin(GL11.GL_QUAD_STRIP);
213 glBegin(GL_QUAD_STRIP);
210214 for (i = 0; i <= teeth; i++) {
211215 angle = i * 2.0f * (float) Math.PI / teeth;
212 GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f);
213 GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f);
214 GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f);
215 GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f);
216 }
217 GL11.glEnd();
216 glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f);
217 glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f);
218 glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f);
219 glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f);
220 }
221 glEnd();
218222
219223 /* draw back sides of teeth */
220 GL11.glBegin(GL11.GL_QUADS);
224 glBegin(GL_QUADS);
221225 for (i = 0; i < teeth; i++) {
222226 angle = i * 2.0f * (float) Math.PI / teeth;
223 GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f);
224 GL11.glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), -width * 0.5f);
225 GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), -width * 0.5f);
226 GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f);
227 }
228 GL11.glEnd();
227 glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f);
228 glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), -width * 0.5f);
229 glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), -width * 0.5f);
230 glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f);
231 }
232 glEnd();
229233
230234 /* draw outward faces of teeth */
231 GL11.glBegin(GL11.GL_QUAD_STRIP);
235 glBegin(GL_QUAD_STRIP);
232236 for (i = 0; i < teeth; i++) {
233237 angle = i * 2.0f * (float) Math.PI / teeth;
234 GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f);
235 GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f);
238 glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f);
239 glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f);
236240 u = r2 * (float) Math.cos(angle + da) - r1 * (float) Math.cos(angle);
237241 v = r2 * (float) Math.sin(angle + da) - r1 * (float) Math.sin(angle);
238242 len = (float) Math.sqrt(u * u + v * v);
239243 u /= len;
240244 v /= len;
241 GL11.glNormal3f(v, -u, 0.0f);
242 GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), width * 0.5f);
243 GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), -width * 0.5f);
244 GL11.glNormal3f((float) Math.cos(angle), (float) Math.sin(angle), 0.0f);
245 GL11.glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), width * 0.5f);
246 GL11.glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), -width * 0.5f);
245 glNormal3f(v, -u, 0.0f);
246 glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), width * 0.5f);
247 glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), -width * 0.5f);
248 glNormal3f((float) Math.cos(angle), (float) Math.sin(angle), 0.0f);
249 glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), width * 0.5f);
250 glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), -width * 0.5f);
247251 u = r1 * (float) Math.cos(angle + 3 * da) - r2 * (float) Math.cos(angle + 2 * da);
248252 v = r1 * (float) Math.sin(angle + 3 * da) - r2 * (float) Math.sin(angle + 2 * da);
249 GL11.glNormal3f(v, -u, 0.0f);
250 GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), width * 0.5f);
251 GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f);
252 GL11.glNormal3f((float) Math.cos(angle), (float) Math.sin(angle), 0.0f);
253 }
254 GL11.glVertex3f(r1 * (float) Math.cos(0), r1 * (float) Math.sin(0), width * 0.5f);
255 GL11.glVertex3f(r1 * (float) Math.cos(0), r1 * (float) Math.sin(0), -width * 0.5f);
256 GL11.glEnd();
257
258 GL11.glShadeModel(GL11.GL_SMOOTH);
253 glNormal3f(v, -u, 0.0f);
254 glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), width * 0.5f);
255 glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f);
256 glNormal3f((float) Math.cos(angle), (float) Math.sin(angle), 0.0f);
257 }
258 glVertex3f(r1 * (float) Math.cos(0), r1 * (float) Math.sin(0), width * 0.5f);
259 glVertex3f(r1 * (float) Math.cos(0), r1 * (float) Math.sin(0), -width * 0.5f);
260 glEnd();
261
262 glShadeModel(GL_SMOOTH);
259263
260264 /* draw inside radius cylinder */
261 GL11.glBegin(GL11.GL_QUAD_STRIP);
265 glBegin(GL_QUAD_STRIP);
262266 for (i = 0; i <= teeth; i++) {
263267 angle = i * 2.0f * (float) Math.PI / teeth;
264 GL11.glNormal3f(-(float) Math.cos(angle), -(float) Math.sin(angle), 0.0f);
265 GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f);
266 GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f);
267 }
268 GL11.glEnd();
269 }
268 glNormal3f(-(float) Math.cos(angle), -(float) Math.sin(angle), 0.0f);
269 glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f);
270 glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f);
271 }
272 glEnd();
273 }
270274
271275 public static void main(String[] args) throws LWJGLException {
272276 new AWTGears();
3434
3535 import org.lwjgl.BufferUtils;
3636 import org.lwjgl.LWJGLException;
37 import org.lwjgl.opengl.ARBTransposeMatrix;
3837 import org.lwjgl.opengl.AWTGLCanvas;
39 import org.lwjgl.opengl.GL11;
4038 import org.lwjgl.opengl.GLContext;
4139 import org.lwjgl.test.applet.Test;
40
41 import static org.lwjgl.opengl.ARBTransposeMatrix.*;
42 import static org.lwjgl.opengl.GL11.*;
4243
4344 /**
4445 * <p>
4950 * $Id$
5051 */
5152 public class AWTGearsCanvas extends AWTGLCanvas implements Test {
52
53
5354 private float view_rotx = 20.0f;
5455
5556 private float view_roty = 30.0f;
5657
57 private float view_rotz = 0.0f;
58 private float view_rotz;
5859
5960 private int gear1;
6061
6263
6364 private int gear3;
6465
65 private float angle = 0.0f;
66
67 long startTime = 0;
68 long fps = 0;
66 private float angle;
67
68 long startTime;
69 long fps;
6970 int current_width;
7071 int current_height;
7172
7778 }
7879
7980 public void paintGL() {
80
81
8182 if(startTime == 0) {
8283 setup();
8384 startTime = System.currentTimeMillis() + 5000;
8485 }
85
86
8687 try {
8788 angle += 2.0f;
8889 if (getWidth() != current_width || getHeight() != current_height) {
8990 current_width = getWidth();
9091 current_height = getHeight();
91 GL11.glViewport(0, 0, current_width, current_height);
92 glViewport(0, 0, current_width, current_height);
9293 }
93 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
94
95 GL11.glPushMatrix();
96 GL11.glRotatef(view_rotx, 1.0f, 0.0f, 0.0f);
97 GL11.glRotatef(view_roty, 0.0f, 1.0f, 0.0f);
98 GL11.glRotatef(view_rotz, 0.0f, 0.0f, 1.0f);
99
100 GL11.glPushMatrix();
101 GL11.glTranslatef(-3.0f, -2.0f, 0.0f);
102 GL11.glRotatef(angle, 0.0f, 0.0f, 1.0f);
103 GL11.glCallList(gear1);
104 GL11.glPopMatrix();
105
106 GL11.glPushMatrix();
107 GL11.glTranslatef(3.1f, -2.0f, 0.0f);
108 GL11.glRotatef(-2.0f * angle - 9.0f, 0.0f, 0.0f, 1.0f);
109 GL11.glCallList(gear2);
110 GL11.glPopMatrix();
111
112 GL11.glPushMatrix();
113 GL11.glTranslatef(-3.1f, 4.2f, 0.0f);
114 GL11.glRotatef(-2.0f * angle - 25.0f, 0.0f, 0.0f, 1.0f);
115 GL11.glCallList(gear3);
116 GL11.glPopMatrix();
117
118 GL11.glPopMatrix();
94 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
95
96 glPushMatrix();
97 glRotatef(view_rotx, 1.0f, 0.0f, 0.0f);
98 glRotatef(view_roty, 0.0f, 1.0f, 0.0f);
99 glRotatef(view_rotz, 0.0f, 0.0f, 1.0f);
100
101 glPushMatrix();
102 glTranslatef(-3.0f, -2.0f, 0.0f);
103 glRotatef(angle, 0.0f, 0.0f, 1.0f);
104 glCallList(gear1);
105 glPopMatrix();
106
107 glPushMatrix();
108 glTranslatef(3.1f, -2.0f, 0.0f);
109 glRotatef(-2.0f * angle - 9.0f, 0.0f, 0.0f, 1.0f);
110 glCallList(gear2);
111 glPopMatrix();
112
113 glPushMatrix();
114 glTranslatef(-3.1f, 4.2f, 0.0f);
115 glRotatef(-2.0f * angle - 25.0f, 0.0f, 0.0f, 1.0f);
116 glCallList(gear3);
117 glPopMatrix();
118
119 glPopMatrix();
119120 swapBuffers();
120121 repaint();
121122 } catch (LWJGLException e) {
126127 } else {
127128 long timeUsed = 5000 + (startTime - System.currentTimeMillis());
128129 startTime = System.currentTimeMillis() + 5000;
129 System.out.println(fps + " frames in " + (float) (timeUsed / 1000f) + " seconds = "
130 System.out.println(fps + " frames in " + timeUsed / 1000f + " seconds = "
130131 + (fps / (timeUsed / 1000f)));
131132 fps = 0;
132 }
133 }
134
133 }
134 }
135
135136 private void setup() {
136137 // setup ogl
137138 FloatBuffer pos = BufferUtils.createFloatBuffer(4).put(new float[] { 5.0f, 5.0f, 10.0f, 0.0f});
143144 green.flip();
144145 blue.flip();
145146
146 GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, pos);
147 GL11.glEnable(GL11.GL_CULL_FACE);
148 GL11.glEnable(GL11.GL_LIGHTING);
149 GL11.glEnable(GL11.GL_LIGHT0);
150 GL11.glEnable(GL11.GL_DEPTH_TEST);
147 glLight(GL_LIGHT0, GL_POSITION, pos);
148 glEnable(GL_CULL_FACE);
149 glEnable(GL_LIGHTING);
150 glEnable(GL_LIGHT0);
151 glEnable(GL_DEPTH_TEST);
151152
152153 /* make the gears */
153 gear1 = GL11.glGenLists(1);
154 GL11.glNewList(gear1, GL11.GL_COMPILE);
155 GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE, red);
154 gear1 = glGenLists(1);
155 glNewList(gear1, GL_COMPILE);
156 glMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red);
156157 gear(1.0f, 4.0f, 1.0f, 20, 0.7f);
157 GL11.glEndList();
158
159 gear2 = GL11.glGenLists(1);
160 GL11.glNewList(gear2, GL11.GL_COMPILE);
161 GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE, green);
158 glEndList();
159
160 gear2 = glGenLists(1);
161 glNewList(gear2, GL_COMPILE);
162 glMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green);
162163 gear(0.5f, 2.0f, 2.0f, 10, 0.7f);
163 GL11.glEndList();
164
165 gear3 = GL11.glGenLists(1);
166 GL11.glNewList(gear3, GL11.GL_COMPILE);
167 GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE, blue);
164 glEndList();
165
166 gear3 = glGenLists(1);
167 glNewList(gear3, GL_COMPILE);
168 glMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue);
168169 gear(1.3f, 2.0f, 0.5f, 10, 0.7f);
169 GL11.glEndList();
170
171 GL11.glEnable(GL11.GL_NORMALIZE);
172
173 GL11.glMatrixMode(GL11.GL_PROJECTION);
174
175 System.err.println("GL_VENDOR: " + GL11.glGetString(GL11.GL_VENDOR));
176 System.err.println("GL_RENDERER: " + GL11.glGetString(GL11.GL_RENDERER));
177 System.err.println("GL_VERSION: " + GL11.glGetString(GL11.GL_VERSION));
170 glEndList();
171
172 glEnable(GL_NORMALIZE);
173
174 glMatrixMode(GL_PROJECTION);
175
176 System.err.println("GL_VENDOR: " + glGetString(GL_VENDOR));
177 System.err.println("GL_RENDERER: " + glGetString(GL_RENDERER));
178 System.err.println("GL_VERSION: " + glGetString(GL_VERSION));
178179 System.err.println();
179180 System.err.println("glLoadTransposeMatrixfARB() supported: " + GLContext.getCapabilities().GL_ARB_transpose_matrix);
180181 if (!GLContext.getCapabilities().GL_ARB_transpose_matrix) {
181182 // --- not using extensions
182 GL11.glLoadIdentity();
183 glLoadIdentity();
183184 } else {
184185 // --- using extensions
185186 final FloatBuffer identityTranspose = BufferUtils.createFloatBuffer(16).put(
186187 new float[] { 1, 0, 0, 0, 0, 1, 0, 0,
187188 0, 0, 1, 0, 0, 0, 0, 1});
188189 identityTranspose.flip();
189 ARBTransposeMatrix.glLoadTransposeMatrixARB(identityTranspose);
190 glLoadTransposeMatrixARB(identityTranspose);
190191 }
191192
192193 float h = (float) 300 / (float) 300;
193 GL11.glFrustum(-1.0f, 1.0f, -h, h, 5.0f, 60.0f);
194 GL11.glMatrixMode(GL11.GL_MODELVIEW);
195 GL11.glLoadIdentity();
196 GL11.glTranslatef(0.0f, 0.0f, -40.0f);
197 }
198
194 glFrustum(-1.0f, 1.0f, -h, h, 5.0f, 60.0f);
195 glMatrixMode(GL_MODELVIEW);
196 glLoadIdentity();
197 glTranslatef(0.0f, 0.0f, -40.0f);
198 }
199
199200 /**
200201 * Draw a gear wheel. You'll probably want to call this function when
201202 * building a display list since we do a lot of trig here.
218219
219220 da = 2.0f * (float) Math.PI / teeth / 4.0f;
220221
221 GL11.glShadeModel(GL11.GL_FLAT);
222
223 GL11.glNormal3f(0.0f, 0.0f, 1.0f);
222 glShadeModel(GL_FLAT);
223
224 glNormal3f(0.0f, 0.0f, 1.0f);
224225
225226 /* draw front face */
226 GL11.glBegin(GL11.GL_QUAD_STRIP);
227 glBegin(GL_QUAD_STRIP);
227228 for (i = 0; i <= teeth; i++) {
228229 angle = i * 2.0f * (float) Math.PI / teeth;
229 GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f);
230 GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f);
230 glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f);
231 glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f);
231232 if (i < teeth) {
232 GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f);
233 GL11.glVertex3f(r1 * (float) Math.cos(angle + 3.0f * da), r1 * (float) Math.sin(angle + 3.0f * da),
233 glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f);
234 glVertex3f(r1 * (float) Math.cos(angle + 3.0f * da), r1 * (float) Math.sin(angle + 3.0f * da),
234235 width * 0.5f);
235236 }
236237 }
237 GL11.glEnd();
238 glEnd();
238239
239240 /* draw front sides of teeth */
240 GL11.glBegin(GL11.GL_QUADS);
241 glBegin(GL_QUADS);
241242 for (i = 0; i < teeth; i++) {
242243 angle = i * 2.0f * (float) Math.PI / teeth;
243 GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f);
244 GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), width * 0.5f);
245 GL11.glVertex3f(r2 * (float) Math.cos(angle + 2.0f * da), r2 * (float) Math.sin(angle + 2.0f * da), width * 0.5f);
246 GL11.glVertex3f(r1 * (float) Math.cos(angle + 3.0f * da), r1 * (float) Math.sin(angle + 3.0f * da), width * 0.5f);
247 }
248 GL11.glEnd();
244 glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f);
245 glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), width * 0.5f);
246 glVertex3f(r2 * (float) Math.cos(angle + 2.0f * da), r2 * (float) Math.sin(angle + 2.0f * da), width * 0.5f);
247 glVertex3f(r1 * (float) Math.cos(angle + 3.0f * da), r1 * (float) Math.sin(angle + 3.0f * da), width * 0.5f);
248 }
249 glEnd();
249250
250251 /* draw back face */
251 GL11.glBegin(GL11.GL_QUAD_STRIP);
252 glBegin(GL_QUAD_STRIP);
252253 for (i = 0; i <= teeth; i++) {
253254 angle = i * 2.0f * (float) Math.PI / teeth;
254 GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f);
255 GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f);
256 GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f);
257 GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f);
258 }
259 GL11.glEnd();
255 glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f);
256 glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f);
257 glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f);
258 glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f);
259 }
260 glEnd();
260261
261262 /* draw back sides of teeth */
262 GL11.glBegin(GL11.GL_QUADS);
263 glBegin(GL_QUADS);
263264 for (i = 0; i < teeth; i++) {
264265 angle = i * 2.0f * (float) Math.PI / teeth;
265 GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f);
266 GL11.glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), -width * 0.5f);
267 GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), -width * 0.5f);
268 GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f);
269 }
270 GL11.glEnd();
266 glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f);
267 glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), -width * 0.5f);
268 glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), -width * 0.5f);
269 glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f);
270 }
271 glEnd();
271272
272273 /* draw outward faces of teeth */
273 GL11.glBegin(GL11.GL_QUAD_STRIP);
274 glBegin(GL_QUAD_STRIP);
274275 for (i = 0; i < teeth; i++) {
275276 angle = i * 2.0f * (float) Math.PI / teeth;
276 GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f);
277 GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f);
277 glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f);
278 glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f);
278279 u = r2 * (float) Math.cos(angle + da) - r1 * (float) Math.cos(angle);
279280 v = r2 * (float) Math.sin(angle + da) - r1 * (float) Math.sin(angle);
280281 len = (float) Math.sqrt(u * u + v * v);
281282 u /= len;
282283 v /= len;
283 GL11.glNormal3f(v, -u, 0.0f);
284 GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), width * 0.5f);
285 GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), -width * 0.5f);
286 GL11.glNormal3f((float) Math.cos(angle), (float) Math.sin(angle), 0.0f);
287 GL11.glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), width * 0.5f);
288 GL11.glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), -width * 0.5f);
284 glNormal3f(v, -u, 0.0f);
285 glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), width * 0.5f);
286 glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), -width * 0.5f);
287 glNormal3f((float) Math.cos(angle), (float) Math.sin(angle), 0.0f);
288 glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), width * 0.5f);
289 glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), -width * 0.5f);
289290 u = r1 * (float) Math.cos(angle + 3 * da) - r2 * (float) Math.cos(angle + 2 * da);
290291 v = r1 * (float) Math.sin(angle + 3 * da) - r2 * (float) Math.sin(angle + 2 * da);
291 GL11.glNormal3f(v, -u, 0.0f);
292 GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), width * 0.5f);
293 GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f);
294 GL11.glNormal3f((float) Math.cos(angle), (float) Math.sin(angle), 0.0f);
295 }
296 GL11.glVertex3f(r1 * (float) Math.cos(0), r1 * (float) Math.sin(0), width * 0.5f);
297 GL11.glVertex3f(r1 * (float) Math.cos(0), r1 * (float) Math.sin(0), -width * 0.5f);
298 GL11.glEnd();
299
300 GL11.glShadeModel(GL11.GL_SMOOTH);
292 glNormal3f(v, -u, 0.0f);
293 glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), width * 0.5f);
294 glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f);
295 glNormal3f((float) Math.cos(angle), (float) Math.sin(angle), 0.0f);
296 }
297 glVertex3f(r1 * (float) Math.cos(0), r1 * (float) Math.sin(0), width * 0.5f);
298 glVertex3f(r1 * (float) Math.cos(0), r1 * (float) Math.sin(0), -width * 0.5f);
299 glEnd();
300
301 glShadeModel(GL_SMOOTH);
301302
302303 /* draw inside radius cylinder */
303 GL11.glBegin(GL11.GL_QUAD_STRIP);
304 glBegin(GL_QUAD_STRIP);
304305 for (i = 0; i <= teeth; i++) {
305306 angle = i * 2.0f * (float) Math.PI / teeth;
306 GL11.glNormal3f(-(float) Math.cos(angle), -(float) Math.sin(angle), 0.0f);
307 GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f);
308 GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f);
309 }
310 GL11.glEnd();
307 glNormal3f(-(float) Math.cos(angle), -(float) Math.sin(angle), 0.0f);
308 glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f);
309 glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f);
310 }
311 glEnd();
311312 }
312313
313314 /*
3737
3838 import org.lwjgl.LWJGLException;
3939 import org.lwjgl.opengl.AWTGLCanvas;
40 import org.lwjgl.opengl.GL11;
41 import org.lwjgl.util.glu.GLU;
40
41 import static org.lwjgl.opengl.GL11.*;
42 import static org.lwjgl.util.glu.GLU.*;
4243
4344 /**
4445 * <p>
4546 * Tests AWTGLCanvas functionality
4647 * <p>
47 * @version $Revision: 2983 $
48 * @author $Author: matzon $
49 * $Id: AWTTest.java 2983 2008-04-07 18:36:09Z matzon $
48 * @version $Revision: 3418 $
49 * @author $Author: spasi $
50 * $Id: AWTTest.java 3418 2010-09-28 21:11:35Z spasi $
5051 */
5152 public class AWTTest extends Frame {
5253
5354 /** AWT GL canvas */
5455 private AWTGLCanvas canvas0, canvas1;
55
56
5657 private volatile float angle;
5758
5859 /**
7071 if (getWidth() != current_width || getHeight() != current_height) {
7172 current_width = getWidth();
7273 current_height = getHeight();
73 GL11.glViewport(0, 0, current_width, current_height);
74 glViewport(0, 0, current_width, current_height);
7475 }
75 GL11.glViewport(0, 0, getWidth(), getHeight());
76 GL11.glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
77 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
78 GL11.glMatrixMode(GL11.GL_PROJECTION);
79 GL11.glLoadIdentity();
80 GLU.gluOrtho2D(0.0f, (float) getWidth(), 0.0f, (float) getHeight());
81 GL11.glMatrixMode(GL11.GL_MODELVIEW);
82 GL11.glPushMatrix();
83 GL11.glColor3f(1f, 1f, 0f);
84 GL11.glTranslatef(getWidth() / 2.0f, getHeight() / 2.0f, 0.0f);
85 GL11.glRotatef(angle, 0f, 0f, 1.0f);
86 GL11.glRectf(-50.0f, -50.0f, 50.0f, 50.0f);
87 GL11.glPopMatrix();
76 glViewport(0, 0, getWidth(), getHeight());
77 glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
78 glClear(GL_COLOR_BUFFER_BIT);
79 glMatrixMode(GL_PROJECTION);
80 glLoadIdentity();
81 gluOrtho2D(0.0f, (float) getWidth(), 0.0f, (float) getHeight());
82 glMatrixMode(GL_MODELVIEW);
83 glPushMatrix();
84 glColor3f(1f, 1f, 0f);
85 glTranslatef(getWidth() / 2.0f, getHeight() / 2.0f, 0.0f);
86 glRotatef(angle, 0f, 0f, 1.0f);
87 glRectf(-50.0f, -50.0f, 50.0f, 50.0f);
88 glPopMatrix();
8889 swapBuffers();
8990 repaint();
9091 } catch (LWJGLException e) {
101102 if (getWidth() != current_width || getHeight() != current_height) {
102103 current_width = getWidth();
103104 current_height = getHeight();
104 GL11.glViewport(0, 0, current_width, current_height);
105 glViewport(0, 0, current_width, current_height);
105106 }
106 GL11.glViewport(0, 0, getWidth(), getHeight());
107 GL11.glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
108 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
109 GL11.glMatrixMode(GL11.GL_PROJECTION);
110 GL11.glLoadIdentity();
111 GLU.gluOrtho2D(0.0f, (float) getWidth(), 0.0f, (float) getHeight());
112 GL11.glMatrixMode(GL11.GL_MODELVIEW);
113 GL11.glPushMatrix();
114 GL11.glTranslatef(getWidth() / 2.0f, getHeight() / 2.0f, 0.0f);
115 GL11.glRotatef(2*angle, 0f, 0f, -1.0f);
116 GL11.glRectf(-50.0f, -50.0f, 50.0f, 50.0f);
117 GL11.glPopMatrix();
107 glViewport(0, 0, getWidth(), getHeight());
108 glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
109 glClear(GL_COLOR_BUFFER_BIT);
110 glMatrixMode(GL_PROJECTION);
111 glLoadIdentity();
112 gluOrtho2D(0.0f, (float) getWidth(), 0.0f, (float) getHeight());
113 glMatrixMode(GL_MODELVIEW);
114 glPushMatrix();
115 glTranslatef(getWidth() / 2.0f, getHeight() / 2.0f, 0.0f);
116 glRotatef(2*angle, 0f, 0f, -1.0f);
117 glRectf(-50.0f, -50.0f, 50.0f, 50.0f);
118 glPopMatrix();
118119 swapBuffers();
119120 repaint();
120121 } catch (LWJGLException e) {
121122 throw new RuntimeException(e);
122123 }
123124 }
124 });
125 });
125126 addWindowListener(new WindowAdapter() {
126127 public void windowClosing(WindowEvent e) {
127128 dispose();
5050
5151 import org.lwjgl.BufferUtils;
5252 import org.lwjgl.LWJGLException;
53 import org.lwjgl.opengl.ARBTransposeMatrix;
5453 import org.lwjgl.opengl.AWTGLCanvas;
55 import org.lwjgl.opengl.GL11;
5654 import org.lwjgl.opengl.GLContext;
55
56 import static org.lwjgl.opengl.ARBTransposeMatrix.*;
57 import static org.lwjgl.opengl.GL11.*;
5758
5859 /**
5960 * <p>
7172 private Panel selectionPanel;
7273
7374 /** Hashtable of demos */
74 private Hashtable selectableDemos;
75 private Hashtable<String, Demo> selectableDemos;
7576
7677 /**
7778 * Creates a new demo box instance
7879 */
7980 public DemoBox() {
80 selectableDemos = new Hashtable();
81 selectableDemos = new Hashtable<String, Demo>();
8182 selectableDemos.put("default", new NullDemoBox());
8283 selectableDemos.put("clear_color", new ClearColorDemoBox());
8384 selectableDemos.put("gears", new GearsDemoBox());
159160 //demoSelected(demos.getSelectedItem());
160161 return true;
161162 }
162
163
163164 public void updateFPS(float fps) {
164165 if(fps != -1) {
165166 setTitle("LWJGL - Demo Box (FPS: " + fps + ")");
181182 */
182183 protected void demoSelected(String demo) {
183184 System.out.println("Selecting demo: " + demo);
184 demoCanvas.setActiveDemo((Demo) selectableDemos.get(demo));
185 demoCanvas.setActiveDemo(selectableDemos.get(demo));
185186 }
186187
187188 /**
198199 * Interface for a demo
199200 */
200201 public interface Demo {
201 public boolean isInitialized();
202 public boolean initialize();
203 public void render();
204 public void destroy();
202 boolean isInitialized();
203 boolean initialize();
204 void render();
205 void destroy();
205206 }
206207
207208 /**
208 *
209 *
209210 */
210211 private class DemoBoxGLCanvas extends AWTGLCanvas implements Runnable {
211212
212213 /** Parent demo box */
213214 DemoBox parent;
214
215
215216 /** Currently active demo */
216217 Demo activeDemo;
217218
220221
221222 /** Render thread */
222223 private Thread renderThread;
223
224 public DemoBoxGLCanvas(DemoBox parent) throws LWJGLException {
224
225 private DemoBoxGLCanvas(DemoBox parent) throws LWJGLException {
225226 super();
226 this.parent = parent;
227 this.parent = parent;
227228 }
228229
229230 // FPS
230 long startTime = 0;
231 long fps = 0;
231 long startTime;
232 long fps;
232233
233234 protected void paintGL() {
234235 synchronized (this) {
242243 parent.updateFPS(-1);
243244 }
244245 }
245
246
246247 if (activeDemo != null) {
247
248
248249 if(!activeDemo.isInitialized()) {
249250 activeDemo.initialize();
250251 }
251
252
252253 activeDemo.render();
253254 try {
254255 swapBuffers();
255256 } catch (LWJGLException le) {
256257 le.printStackTrace();
257258 }
258
259
259260 if (startTime > System.currentTimeMillis()) {
260261 fps++;
261262 } else {
263264 startTime = System.currentTimeMillis() + 5000;
264265 parent.updateFPS((fps / (timeUsed / 1000f)));
265266 fps = 0;
266 }
267 }
267268 }
268269 }
269270 }
294295 }
295296 }
296297
297 public DemoBoxGLCanvas() throws LWJGLException {
298 private DemoBoxGLCanvas() throws LWJGLException {
298299 super();
299300 }
300301
329330 // Demo box demo
330331 // ========================================================
331332 public class ClearColorDemoBox implements Demo {
332
333
333334 private boolean initialized;
334335
335336 int direction = 1;
336337
337338 float color;
338
339
339340 public boolean isInitialized() {
340341 return initialized;
341342 }
345346 }
346347
347348 public void render() {
348 GL11.glClearColor(color, color, color, 1f);
349 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
349 glClearColor(color, color, color, 1f);
350 glClear(GL_COLOR_BUFFER_BIT);
350351
351352 color += direction * .05f;
352353
369370 // Demo box demo
370371 // ========================================================
371372 public class NullDemoBox implements Demo {
372
373
373374 private boolean initialized;
374
375
375376 public boolean isInitialized() {
376377 return initialized;
377378 }
378379
379380 public boolean initialize() {
380 GL11.glClearColor(0, 0, 0, 1f);
381 glClearColor(0, 0, 0, 1f);
381382 return true;
382383 }
383384
384385 public void render() {
385 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
386 glClear(GL_COLOR_BUFFER_BIT);
386387 }
387388
388389 public void destroy() {
390391 }
391392 }
392393 // --------------------------------------------------------
393
394
394395 // Demo box demo
395396 // ========================================================
396397 public class GearsDemoBox implements Demo {
397
398
398399 private boolean initialized;
399
400
400401 private float view_rotx = 20.0f;
401402
402403 private float view_roty = 30.0f;
403404
404 private float view_rotz = 0.0f;
405 private float view_rotz;
405406
406407 private int gear1;
407408
409410
410411 private int gear3;
411412
412 private float angle = 0.0f;
413
413 private float angle;
414
414415 public boolean isInitialized() {
415416 return initialized;
416417 }
425426 red.flip();
426427 green.flip();
427428 blue.flip();
428
429 GL11.glClearColor(0, 0, 0, 1f);
430
431 GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, pos);
432 GL11.glEnable(GL11.GL_CULL_FACE);
433 GL11.glEnable(GL11.GL_LIGHTING);
434 GL11.glEnable(GL11.GL_LIGHT0);
435 GL11.glEnable(GL11.GL_DEPTH_TEST);
429
430 glClearColor(0, 0, 0, 1f);
431
432 glLight(GL_LIGHT0, GL_POSITION, pos);
433 glEnable(GL_CULL_FACE);
434 glEnable(GL_LIGHTING);
435 glEnable(GL_LIGHT0);
436 glEnable(GL_DEPTH_TEST);
436437
437438 /* make the gears */
438 gear1 = GL11.glGenLists(1);
439 GL11.glNewList(gear1, GL11.GL_COMPILE);
440 GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE, red);
439 gear1 = glGenLists(1);
440 glNewList(gear1, GL_COMPILE);
441 glMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red);
441442 gear(1.0f, 4.0f, 1.0f, 20, 0.7f);
442 GL11.glEndList();
443
444 gear2 = GL11.glGenLists(1);
445 GL11.glNewList(gear2, GL11.GL_COMPILE);
446 GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE, green);
443 glEndList();
444
445 gear2 = glGenLists(1);
446 glNewList(gear2, GL_COMPILE);
447 glMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green);
447448 gear(0.5f, 2.0f, 2.0f, 10, 0.7f);
448 GL11.glEndList();
449
450 gear3 = GL11.glGenLists(1);
451 GL11.glNewList(gear3, GL11.GL_COMPILE);
452 GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE, blue);
449 glEndList();
450
451 gear3 = glGenLists(1);
452 glNewList(gear3, GL_COMPILE);
453 glMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue);
453454 gear(1.3f, 2.0f, 0.5f, 10, 0.7f);
454 GL11.glEndList();
455
456 GL11.glEnable(GL11.GL_NORMALIZE);
457
458 GL11.glMatrixMode(GL11.GL_PROJECTION);
459
460 System.err.println("GL_VENDOR: " + GL11.glGetString(GL11.GL_VENDOR));
461 System.err.println("GL_RENDERER: " + GL11.glGetString(GL11.GL_RENDERER));
462 System.err.println("GL_VERSION: " + GL11.glGetString(GL11.GL_VERSION));
455 glEndList();
456
457 glEnable(GL_NORMALIZE);
458
459 glMatrixMode(GL_PROJECTION);
460
461 System.err.println("GL_VENDOR: " + glGetString(GL_VENDOR));
462 System.err.println("GL_RENDERER: " + glGetString(GL_RENDERER));
463 System.err.println("GL_VERSION: " + glGetString(GL_VERSION));
463464 System.err.println();
464465 System.err.println("glLoadTransposeMatrixfARB() supported: " + GLContext.getCapabilities().GL_ARB_transpose_matrix);
465466 if (!GLContext.getCapabilities().GL_ARB_transpose_matrix) {
466467 // --- not using extensions
467 GL11.glLoadIdentity();
468 glLoadIdentity();
468469 } else {
469470 // --- using extensions
470471 final FloatBuffer identityTranspose = BufferUtils.createFloatBuffer(16).put(
471472 new float[] { 1, 0, 0, 0, 0, 1, 0, 0,
472473 0, 0, 1, 0, 0, 0, 0, 1});
473474 identityTranspose.flip();
474 ARBTransposeMatrix.glLoadTransposeMatrixARB(identityTranspose);
475 glLoadTransposeMatrixARB(identityTranspose);
475476 }
476477
477478 float h = (float) 300 / (float) 300;
478 GL11.glFrustum(-1.0f, 1.0f, -h, h, 5.0f, 60.0f);
479 GL11.glMatrixMode(GL11.GL_MODELVIEW);
480 GL11.glLoadIdentity();
481 GL11.glTranslatef(0.0f, 0.0f, -40.0f);
479 glFrustum(-1.0f, 1.0f, -h, h, 5.0f, 60.0f);
480 glMatrixMode(GL_MODELVIEW);
481 glLoadIdentity();
482 glTranslatef(0.0f, 0.0f, -40.0f);
482483 return initialized = true;
483484 }
484485
485486 public void render() {
486487 angle += 2.0f;
487 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
488
489 GL11.glPushMatrix();
490 GL11.glRotatef(view_rotx, 1.0f, 0.0f, 0.0f);
491 GL11.glRotatef(view_roty, 0.0f, 1.0f, 0.0f);
492 GL11.glRotatef(view_rotz, 0.0f, 0.0f, 1.0f);
493
494 GL11.glPushMatrix();
495 GL11.glTranslatef(-3.0f, -2.0f, 0.0f);
496 GL11.glRotatef(angle, 0.0f, 0.0f, 1.0f);
497 GL11.glCallList(gear1);
498 GL11.glPopMatrix();
499
500 GL11.glPushMatrix();
501 GL11.glTranslatef(3.1f, -2.0f, 0.0f);
502 GL11.glRotatef(-2.0f * angle - 9.0f, 0.0f, 0.0f, 1.0f);
503 GL11.glCallList(gear2);
504 GL11.glPopMatrix();
505
506 GL11.glPushMatrix();
507 GL11.glTranslatef(-3.1f, 4.2f, 0.0f);
508 GL11.glRotatef(-2.0f * angle - 25.0f, 0.0f, 0.0f, 1.0f);
509 GL11.glCallList(gear3);
510 GL11.glPopMatrix();
511
512 GL11.glPopMatrix();
513 }
514
488 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
489
490 glPushMatrix();
491 glRotatef(view_rotx, 1.0f, 0.0f, 0.0f);
492 glRotatef(view_roty, 0.0f, 1.0f, 0.0f);
493 glRotatef(view_rotz, 0.0f, 0.0f, 1.0f);
494
495 glPushMatrix();
496 glTranslatef(-3.0f, -2.0f, 0.0f);
497 glRotatef(angle, 0.0f, 0.0f, 1.0f);
498 glCallList(gear1);
499 glPopMatrix();
500
501 glPushMatrix();
502 glTranslatef(3.1f, -2.0f, 0.0f);
503 glRotatef(-2.0f * angle - 9.0f, 0.0f, 0.0f, 1.0f);
504 glCallList(gear2);
505 glPopMatrix();
506
507 glPushMatrix();
508 glTranslatef(-3.1f, 4.2f, 0.0f);
509 glRotatef(-2.0f * angle - 25.0f, 0.0f, 0.0f, 1.0f);
510 glCallList(gear3);
511 glPopMatrix();
512
513 glPopMatrix();
514 }
515
515516 /**
516517 * Draw a gear wheel. You'll probably want to call this function when
517518 * building a display list since we do a lot of trig here.
534535
535536 da = 2.0f * (float) Math.PI / teeth / 4.0f;
536537
537 GL11.glShadeModel(GL11.GL_FLAT);
538
539 GL11.glNormal3f(0.0f, 0.0f, 1.0f);
538 glShadeModel(GL_FLAT);
539
540 glNormal3f(0.0f, 0.0f, 1.0f);
540541
541542 /* draw front face */
542 GL11.glBegin(GL11.GL_QUAD_STRIP);
543 glBegin(GL_QUAD_STRIP);
543544 for (i = 0; i <= teeth; i++) {
544545 angle = i * 2.0f * (float) Math.PI / teeth;
545 GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f);
546 GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f);
546 glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f);
547 glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f);
547548 if (i < teeth) {
548 GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f);
549 GL11.glVertex3f(r1 * (float) Math.cos(angle + 3.0f * da), r1 * (float) Math.sin(angle + 3.0f * da),
549 glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f);
550 glVertex3f(r1 * (float) Math.cos(angle + 3.0f * da), r1 * (float) Math.sin(angle + 3.0f * da),
550551 width * 0.5f);
551552 }
552553 }
553 GL11.glEnd();
554 glEnd();
554555
555556 /* draw front sides of teeth */
556 GL11.glBegin(GL11.GL_QUADS);
557 glBegin(GL_QUADS);
557558 for (i = 0; i < teeth; i++) {
558559 angle = i * 2.0f * (float) Math.PI / teeth;
559 GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f);
560 GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), width * 0.5f);
561 GL11.glVertex3f(r2 * (float) Math.cos(angle + 2.0f * da), r2 * (float) Math.sin(angle + 2.0f * da), width * 0.5f);
562 GL11.glVertex3f(r1 * (float) Math.cos(angle + 3.0f * da), r1 * (float) Math.sin(angle + 3.0f * da), width * 0.5f);
563 }
564 GL11.glEnd();
560 glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f);
561 glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), width * 0.5f);
562 glVertex3f(r2 * (float) Math.cos(angle + 2.0f * da), r2 * (float) Math.sin(angle + 2.0f * da), width * 0.5f);
563 glVertex3f(r1 * (float) Math.cos(angle + 3.0f * da), r1 * (float) Math.sin(angle + 3.0f * da), width * 0.5f);
564 }
565 glEnd();
565566
566567 /* draw back face */
567 GL11.glBegin(GL11.GL_QUAD_STRIP);
568 glBegin(GL_QUAD_STRIP);
568569 for (i = 0; i <= teeth; i++) {
569570 angle = i * 2.0f * (float) Math.PI / teeth;
570 GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f);
571 GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f);
572 GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f);
573 GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f);
574 }
575 GL11.glEnd();
571 glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f);
572 glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f);
573 glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f);
574 glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f);
575 }
576 glEnd();
576577
577578 /* draw back sides of teeth */
578 GL11.glBegin(GL11.GL_QUADS);
579 glBegin(GL_QUADS);
579580 for (i = 0; i < teeth; i++) {
580581 angle = i * 2.0f * (float) Math.PI / teeth;
581 GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f);
582 GL11.glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), -width * 0.5f);
583 GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), -width * 0.5f);
584 GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f);
585 }
586 GL11.glEnd();
582 glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f);
583 glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), -width * 0.5f);
584 glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), -width * 0.5f);
585 glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f);
586 }
587 glEnd();
587588
588589 /* draw outward faces of teeth */
589 GL11.glBegin(GL11.GL_QUAD_STRIP);
590 glBegin(GL_QUAD_STRIP);
590591 for (i = 0; i < teeth; i++) {
591592 angle = i * 2.0f * (float) Math.PI / teeth;
592 GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f);
593 GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f);
593 glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f);
594 glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f);
594595 u = r2 * (float) Math.cos(angle + da) - r1 * (float) Math.cos(angle);
595596 v = r2 * (float) Math.sin(angle + da) - r1 * (float) Math.sin(angle);
596597 len = (float) Math.sqrt(u * u + v * v);
597598 u /= len;
598599 v /= len;
599 GL11.glNormal3f(v, -u, 0.0f);
600 GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), width * 0.5f);
601 GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), -width * 0.5f);
602 GL11.glNormal3f((float) Math.cos(angle), (float) Math.sin(angle), 0.0f);
603 GL11.glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), width * 0.5f);
604 GL11.glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), -width * 0.5f);
600 glNormal3f(v, -u, 0.0f);
601 glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), width * 0.5f);
602 glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), -width * 0.5f);
603 glNormal3f((float) Math.cos(angle), (float) Math.sin(angle), 0.0f);
604 glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), width * 0.5f);
605 glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), -width * 0.5f);
605606 u = r1 * (float) Math.cos(angle + 3 * da) - r2 * (float) Math.cos(angle + 2 * da);
606607 v = r1 * (float) Math.sin(angle + 3 * da) - r2 * (float) Math.sin(angle + 2 * da);
607 GL11.glNormal3f(v, -u, 0.0f);
608 GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), width * 0.5f);
609 GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f);
610 GL11.glNormal3f((float) Math.cos(angle), (float) Math.sin(angle), 0.0f);
611 }
612 GL11.glVertex3f(r1 * (float) Math.cos(0), r1 * (float) Math.sin(0), width * 0.5f);
613 GL11.glVertex3f(r1 * (float) Math.cos(0), r1 * (float) Math.sin(0), -width * 0.5f);
614 GL11.glEnd();
615
616 GL11.glShadeModel(GL11.GL_SMOOTH);
608 glNormal3f(v, -u, 0.0f);
609 glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), width * 0.5f);
610 glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f);
611 glNormal3f((float) Math.cos(angle), (float) Math.sin(angle), 0.0f);
612 }
613 glVertex3f(r1 * (float) Math.cos(0), r1 * (float) Math.sin(0), width * 0.5f);
614 glVertex3f(r1 * (float) Math.cos(0), r1 * (float) Math.sin(0), -width * 0.5f);
615 glEnd();
616
617 glShadeModel(GL_SMOOTH);
617618
618619 /* draw inside radius cylinder */
619 GL11.glBegin(GL11.GL_QUAD_STRIP);
620 glBegin(GL_QUAD_STRIP);
620621 for (i = 0; i <= teeth; i++) {
621622 angle = i * 2.0f * (float) Math.PI / teeth;
622 GL11.glNormal3f(-(float) Math.cos(angle), -(float) Math.sin(angle), 0.0f);
623 GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f);
624 GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f);
625 }
626 GL11.glEnd();
627 }
623 glNormal3f(-(float) Math.cos(angle), -(float) Math.sin(angle), 0.0f);
624 glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f);
625 glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f);
626 }
627 glEnd();
628 }
628629
629630 public void destroy() {
630 GL11.glDeleteLists(gear1, 1);
631 GL11.glDeleteLists(gear2, 1);
632 GL11.glDeleteLists(gear3, 1);
631 glDeleteLists(gear1, 1);
632 glDeleteLists(gear2, 1);
633 glDeleteLists(gear3, 1);
633634 initialized = false;
634635 }
635636 }
636 // --------------------------------------------------------
637 // --------------------------------------------------------
637638 }
4040 import org.lwjgl.input.Keyboard;
4141 import org.lwjgl.input.Mouse;
4242 import org.lwjgl.opengl.Display;
43 import org.lwjgl.opengl.GL11;
44 import org.lwjgl.util.glu.GLU;
43
44 import static org.lwjgl.opengl.GL11.*;
45 import static org.lwjgl.util.glu.GLU.*;
4546
4647 /**
4748 * <p>
4849 * Tests Display.setParent()
4950 * <p>
50 * @version $Revision: 3102 $
51 * @author $Author: matzon $
52 * $Id: DisplayParentTest.java 3102 2008-06-08 09:30:24Z matzon $
51 * @version $Revision: 3418 $
52 * @author $Author: spasi $
53 * $Id: DisplayParentTest.java 3418 2010-09-28 21:11:35Z spasi $
5354 */
5455 public class DisplayParentTest extends Frame {
55 boolean killswitch = false;
56 boolean killswitch;
5657 public DisplayParentTest() throws LWJGLException {
5758 setTitle("LWJGL Display Parent Test");
5859 setSize(640, 320);
8485 width = Display.getDisplayMode().getWidth();
8586 height = Display.getDisplayMode().getHeight();
8687 }
87
88
8889 if(width < 1 || height < 1) {
8990 continue;
9091 }
91
92 GL11.glViewport(0, 0, width, height);
93 GL11.glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
94 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
95 GL11.glMatrixMode(GL11.GL_PROJECTION);
96 GL11.glLoadIdentity();
97 GLU.gluOrtho2D(0.0f, (float) width, 0.0f, (float) height);
98 GL11.glMatrixMode(GL11.GL_MODELVIEW);
99 GL11.glPushMatrix();
100 GL11.glTranslatef(width / 2.0f, height / 2.0f, 0.0f);
101 GL11.glRotatef(2*angle, 0f, 0f, -1.0f);
102 GL11.glRectf(-50.0f, -50.0f, 50.0f, 50.0f);
103 GL11.glPopMatrix();
92
93 glViewport(0, 0, width, height);
94 glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
95 glClear(GL_COLOR_BUFFER_BIT);
96 glMatrixMode(GL_PROJECTION);
97 glLoadIdentity();
98 gluOrtho2D(0.0f, (float) width, 0.0f, (float) height);
99 glMatrixMode(GL_MODELVIEW);
100 glPushMatrix();
101 glTranslatef(width / 2.0f, height / 2.0f, 0.0f);
102 glRotatef(2*angle, 0f, 0f, -1.0f);
103 glRectf(-50.0f, -50.0f, 50.0f, 50.0f);
104 glPopMatrix();
104105 Display.update();
105106 while(Keyboard.next()) {
106107 // closing on ESCAPE
3535 import org.lwjgl.input.Keyboard;
3636 import org.lwjgl.input.Mouse;
3737 import org.lwjgl.opengl.*;
38 import org.lwjgl.util.glu.GLU;
3938 import org.lwjgl.util.glu.Sphere;
4039
4140 import java.nio.FloatBuffer;
41
42 import static org.lwjgl.opengl.GL11.*;
43 import static org.lwjgl.util.glu.GLU.*;
4244
4345 /**
4446 * A test of loading textures in a background thread. This can be achieved in 2 ways:
8486 else {
8587 handleIO();
8688
87 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
89 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
8890
8991 renderObject();
9092
9193 Util.checkGLError();
9294
9395 // Restore camera position.
94 GL11.glPopMatrix();
95 GL11.glPushMatrix();
96 glPopMatrix();
97 glPushMatrix();
9698 }
9799
98100 Display.update();
130132 kill(e.getMessage());
131133 }
132134
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();
135 glViewport(0, 0, displayMode.getWidth(), displayMode.getHeight());
136
137 glMatrixMode(GL_PROJECTION);
138 glLoadIdentity();
139 gluPerspective(45, displayMode.getWidth() / (float)displayMode.getHeight(), 1.0f, 10.0f);
140
141 glMatrixMode(GL_MODELVIEW);
142 glLoadIdentity();
141143
142144 // 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);
145 glTranslatef(0.0f, 0.0f, -4.0f);
146 glRotatef(90.0f, 1.0f, 0.0f, 0.0f);
147 glPushMatrix();
148
149 glClearDepth(1.0f);
150 glDepthFunc(GL_LEQUAL);
151
152 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
153
154 glFrontFace(GL_CCW);
155 glPolygonMode(GL_FRONT, GL_FILL);
156
157 glCullFace(GL_BACK);
158 glEnable(GL_CULL_FACE);
159
160 glAlphaFunc(GL_GREATER, 0.0f);
161 glEnable(GL_ALPHA_TEST);
162
163 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
164 glDisable(GL_BLEND);
165
166 glShadeModel(GL_SMOOTH);
165167
166168 final FloatBuffer vectorBuffer = BufferUtils.createFloatBuffer(4);
167169
168170 vectorBuffer.clear();
169171 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);
172 glLight(GL_LIGHT0, GL_DIFFUSE, vectorBuffer);
171173
172174 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);
175 glLight(GL_LIGHT0, GL_AMBIENT, vectorBuffer);
174176
175177 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);
178 glLight(GL_LIGHT0, GL_SPECULAR, vectorBuffer);
177179
178180 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);
181 glLight(GL_LIGHT0, GL_POSITION, vectorBuffer);
180182
181183 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);
184 glLightModel(GL_LIGHT_MODEL_AMBIENT, vectorBuffer);
185
186 glEnable(GL_LIGHT0);
187 glEnable(GL_LIGHTING);
186188
187189 sphere = new Sphere();
188190
221223 }
222224
223225 static void renderObject() {
224 GL11.glColor3f(1.0f, 1.0f, 1.0f);
226 glColor3f(1.0f, 1.0f, 1.0f);
225227
226228 int texID = backgroundLoader.getTexID();
227229 if ( texID == 0 ) {
228230 sphere.setTextureFlag(false);
229 GL11.glDisable(GL11.GL_TEXTURE_2D);
231 glDisable(GL_TEXTURE_2D);
230232 } else {
231233 sphere.setTextureFlag(true);
232 GL11.glEnable(GL11.GL_TEXTURE_2D);
233 GL11.glBindTexture(GL11.GL_TEXTURE_2D, texID);
234 glEnable(GL_TEXTURE_2D);
235 glBindTexture(GL_TEXTURE_2D, texID);
234236 }
235237
236238 sphere.draw(1.0f, 32, 32);
237239
238240 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 glBindTexture(GL_TEXTURE_2D, 0);
242 glDisable(GL_TEXTURE_2D);
241243 }
242244 }
243245
244246 private static DisplayMode chooseMode(DisplayMode[] modes, int width, int height) {
245247 DisplayMode bestMode = null;
246248
247 for ( int i = 0; i < modes.length; i++ ) {
248 DisplayMode mode = modes[i];
249 for ( DisplayMode mode : modes ) {
249250 if ( mode.getWidth() == width && mode.getHeight() == height && mode.getFrequency() <= 85 ) {
250251 if ( bestMode == null || (mode.getBitsPerPixel() >= bestMode.getBitsPerPixel() && mode.getFrequency() > bestMode.getFrequency()) )
251252 bestMode = mode;
3939 import org.lwjgl.BufferUtils;
4040 import org.lwjgl.LWJGLException;
4141 import org.lwjgl.opengl.Drawable;
42 import org.lwjgl.opengl.GL11;
4342 import org.lwjgl.util.Color;
4443 import org.lwjgl.util.ReadableColor;
4544
4645 import java.nio.ByteBuffer;
46
47 import static org.lwjgl.opengl.GL11.*;
4748
4849 abstract class BackgroundLoader {
4950
9697 // Create a "dummy" texture while we wait for texture IO
9798 createCheckerTexture(Color.RED, Color.WHITE, 2);
9899
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);
100 texID = glGenTextures();
101 glBindTexture(GL_TEXTURE_2D, texID);
102 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, WIDTH, HEIGHT, 0, GL_RGB, GL_UNSIGNED_BYTE, texture);
102103
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);
104 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
105 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
105106
106 GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
107 glBindTexture(GL_TEXTURE_2D, 0);
107108 }
108109
109110 System.out.println("** Dummy texture created **");
127128 else
128129 createGradientTexture(Color.GREEN, Color.YELLOW);
129130
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);
131 glBindTexture(GL_TEXTURE_2D, texID);
132 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, WIDTH, HEIGHT, 0, GL_RGB, GL_UNSIGNED_BYTE, texture);
132133
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);
134 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
135 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
135136
136 GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
137 glBindTexture(GL_TEXTURE_2D, 0);
137138
138139 System.out.println("** Created new gradient texture **");
139140
3737 import org.lwjgl.input.Keyboard;
3838 import org.lwjgl.opengl.Display;
3939 import org.lwjgl.opengl.DisplayMode;
40 import org.lwjgl.opengl.GL11;
4140 import org.lwjgl.opengl.Pbuffer;
4241 import org.lwjgl.opengl.PixelFormat;
43 import org.lwjgl.util.glu.GLU;
4442 import org.lwjgl.util.vector.Vector2f;
43
44 import static org.lwjgl.opengl.GL11.*;
45 import static org.lwjgl.util.glu.GLU.*;
4546
4647 /**
4748 * <p/>
4849 * Tests Pbuffers
4950 *
5051 * @author elias_naur <elias_naur@users.sourceforge.net>
51 * @version $Revision: 2983 $
52 * $Id: PbufferTest.java 2983 2008-04-07 18:36:09Z matzon $
52 * @version $Revision: 3418 $
53 * $Id: PbufferTest.java 3418 2010-09-28 21:11:35Z spasi $
5354 */
5455 public final class PbufferTest {
5556
214215 texRenderer.enable();
215216
216217 // Clear the background
217 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
218 glClear(GL_COLOR_BUFFER_BIT);
218219
219220 // Draw quad with gradient
220 GL11.glPushMatrix();
221 glPushMatrix();
221222 {
222 GL11.glTranslatef(quadPosition.x * texScaleX, quadPosition.y * texScaleY, 0);
223 GL11.glRotatef(angle, 0.0f, 0.0f, 1.0f);
224 GL11.glBegin(GL11.GL_QUADS);
223 glTranslatef(quadPosition.x * texScaleX, quadPosition.y * texScaleY, 0);
224 glRotatef(angle, 0.0f, 0.0f, 1.0f);
225 glBegin(GL_QUADS);
225226 {
226 GL11.glColor3f(1.0f, 0.0f, 0.0f);
227 GL11.glVertex2i(-QUAD_SIZE, -QUAD_SIZE);
228 GL11.glVertex2i(QUAD_SIZE, -QUAD_SIZE);
229 GL11.glColor3f(0.0f, 0.0f, 1.0f);
230 GL11.glVertex2i(QUAD_SIZE, QUAD_SIZE);
231 GL11.glVertex2i(-QUAD_SIZE, QUAD_SIZE);
232 }
233 GL11.glEnd();
234 }
235 GL11.glPopMatrix();
227 glColor3f(1.0f, 0.0f, 0.0f);
228 glVertex2i(-QUAD_SIZE, -QUAD_SIZE);
229 glVertex2i(QUAD_SIZE, -QUAD_SIZE);
230 glColor3f(0.0f, 0.0f, 1.0f);
231 glVertex2i(QUAD_SIZE, QUAD_SIZE);
232 glVertex2i(-QUAD_SIZE, QUAD_SIZE);
233 }
234 glEnd();
235 }
236 glPopMatrix();
236237
237238 // Refresh the texture
238239 texRenderer.updateTexture();
246247 throw new RuntimeException(e);
247248 }
248249
249 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
250 glClear(GL_COLOR_BUFFER_BIT);
250251
251252 // draw white quad
252 GL11.glPushMatrix();
253 glPushMatrix();
253254 {
254 GL11.glTranslatef(quadPosition.x, quadPosition.y, 0);
255 GL11.glRotatef(angle, 0.0f, 0.0f, 1.0f);
256 GL11.glColor3f(1.0f, 1.0f, 1.0f);
257 GL11.glBegin(GL11.GL_QUADS);
255 glTranslatef(quadPosition.x, quadPosition.y, 0);
256 glRotatef(angle, 0.0f, 0.0f, 1.0f);
257 glColor3f(1.0f, 1.0f, 1.0f);
258 glBegin(GL_QUADS);
258259 {
259 GL11.glTexCoord2f(0f, 0f);
260 GL11.glVertex2i(-QUAD_SIZE, -QUAD_SIZE);
261 GL11.glTexCoord2f(1f, 0f);
262 GL11.glVertex2i(QUAD_SIZE, -QUAD_SIZE);
263 GL11.glTexCoord2f(1f, 1f);
264 GL11.glVertex2i(QUAD_SIZE, QUAD_SIZE);
265 GL11.glTexCoord2f(0f, 1f);
266 GL11.glVertex2i(-QUAD_SIZE, QUAD_SIZE);
267 }
268 GL11.glEnd();
269 }
270 GL11.glPopMatrix();
260 glTexCoord2f(0f, 0f);
261 glVertex2i(-QUAD_SIZE, -QUAD_SIZE);
262 glTexCoord2f(1f, 0f);
263 glVertex2i(QUAD_SIZE, -QUAD_SIZE);
264 glTexCoord2f(1f, 1f);
265 glVertex2i(QUAD_SIZE, QUAD_SIZE);
266 glTexCoord2f(0f, 1f);
267 glVertex2i(-QUAD_SIZE, QUAD_SIZE);
268 }
269 glEnd();
270 }
271 glPopMatrix();
271272 }
272273
273274 /**
333334 // Destroy texture
334335 IntBuffer buffer = BufferUtils.createIntBuffer(1);
335336 buffer.put(0, texID);
336 GL11.glDeleteTextures(buffer);
337 glDeleteTextures(buffer);
337338
338339 texRenderer.destroy();
339340 Display.destroy();
350351 */
351352 private DisplayMode findDisplayMode(int width, int height, int bpp) throws LWJGLException {
352353 DisplayMode[] modes = Display.getAvailableDisplayModes();
353 for ( int i = 0; i < modes.length; i++ ) {
354 if ( modes[i].getWidth() == width
355 && modes[i].getHeight() == height
356 && modes[i].getBitsPerPixel() >= bpp ) {
357 return modes[i];
358 }
354 for ( DisplayMode mode : modes ) {
355 if ( mode.getWidth() == width && mode.getHeight() == height && mode.getBitsPerPixel() >= bpp )
356 return mode;
359357 }
360358 return null;
361359 }
362360
363361 static void initGLState(int width, int height, float color) {
364 GL11.glMatrixMode(GL11.GL_PROJECTION);
365 GL11.glLoadIdentity();
366 GLU.gluOrtho2D(0, width, 0, height);
367
368 GL11.glMatrixMode(GL11.GL_MODELVIEW);
369 GL11.glLoadIdentity();
370 GL11.glViewport(0, 0, width, height);
362 glMatrixMode(GL_PROJECTION);
363 glLoadIdentity();
364 gluOrtho2D(0, width, 0, height);
365
366 glMatrixMode(GL_MODELVIEW);
367 glLoadIdentity();
368 glViewport(0, 0, width, height);
371369
372370 //set clear color
373 GL11.glClearColor(color, color, color, 0.0f);
371 glClearColor(color, color, color, 0.0f);
374372 }
375373
376374 /**
382380
383381 // Create shared texture
384382 IntBuffer buffer = BufferUtils.createIntBuffer(1);
385 GL11.glGenTextures(buffer);
383 glGenTextures(buffer);
386384 texID = buffer.get(0);
387385
388 GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE);
389 GL11.glEnable(GL11.GL_TEXTURE_2D);
390
391 GL11.glBindTexture(GL11.GL_TEXTURE_2D, texID);
392
393 GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP);
394 GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP);
395 GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
396 GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
386 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
387 glEnable(GL_TEXTURE_2D);
388
389 glBindTexture(GL_TEXTURE_2D, texID);
390
391 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
392 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
393 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
394 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
397395
398396 initGLState(mode.getWidth(), mode.getHeight(), 0.0f);
399397 }
3232
3333 import org.lwjgl.LWJGLException;
3434 import org.lwjgl.opengl.Display;
35 import org.lwjgl.opengl.GL11;
3635 import org.lwjgl.opengl.Pbuffer;
3736 import org.lwjgl.opengl.PixelFormat;
37
38 import static org.lwjgl.opengl.GL11.*;
3839
3940 final class UniqueRenderer extends TextureRenderer {
4041
5253 pbuffer.makeCurrent();
5354
5455 PbufferTest.initGLState(width, height, 0.5f);
55 GL11.glBindTexture(GL11.GL_TEXTURE_2D, texID);
56 glBindTexture(GL_TEXTURE_2D, texID);
5657
5758 Display.makeCurrent();
5859 } catch (LWJGLException e) {
6566
6667 public void updateTexture() {
6768 // Copy the pbuffer contents to the texture.
68 GL11.glCopyTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB, 0, 0, width, height, 0);
69 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, width, height, 0);
6970 }
7071
7172 }
3232
3333 import org.lwjgl.LWJGLException;
3434 import org.lwjgl.opengl.Display;
35 import org.lwjgl.opengl.GL11;
3635 import org.lwjgl.opengl.Pbuffer;
3736 import org.lwjgl.opengl.PixelFormat;
3837 import org.lwjgl.opengl.RenderTexture;
38
39 import static org.lwjgl.opengl.GL11.*;
3940
4041 final class UniqueRendererRTT extends TextureRenderer {
4142
5556 pbuffer.makeCurrent();
5657
5758 PbufferTest.initGLState(width, height, 0.5f);
58 GL11.glBindTexture(GL11.GL_TEXTURE_2D, texID);
59 glBindTexture(GL_TEXTURE_2D, texID);
5960
6061 Display.makeCurrent();
6162 } catch (LWJGLException e) {
3737 package org.lwjgl.test.opengl.shaders;
3838
3939 import org.lwjgl.BufferUtils;
40 import org.lwjgl.opengl.ARBProgram;
41 import org.lwjgl.opengl.ARBShaderObjects;
42 import org.lwjgl.opengl.GL11;
4340
4441 import java.io.BufferedInputStream;
42 import java.io.FileInputStream;
4543 import java.io.IOException;
4644 import java.io.InputStream;
4745 import java.nio.ByteBuffer;
46
47 import static org.lwjgl.opengl.ARBProgram.*;
48 import static org.lwjgl.opengl.ARBShaderObjects.*;
49 import static org.lwjgl.opengl.GL11.*;
4850
4951 abstract class Shader {
5052
6163 String shader = null;
6264
6365 try {
64 ClassLoader loader = ShadersTest.class.getClassLoader();
65 InputStream inputStream = loader.getResourceAsStream("org/lwjgl/test/opengl/shaders/" + file);
66 InputStream source = ShadersTest.class.getResourceAsStream(file);
67 if ( source == null ) // dev-mode
68 source = new FileInputStream("src/java/org/lwjgl/test/opengl/shaders/" + file);
6669
67 if ( inputStream == null )
68 ShadersTest.kill("A shader source file could not be found: " + file);
69
70 BufferedInputStream stream = new BufferedInputStream(inputStream);
70 BufferedInputStream stream = new BufferedInputStream(source);
7171
7272 byte character;
7373 while ( (character = (byte)stream.read()) != -1 )
9090 }
9191
9292 protected static void checkProgramError(String programFile, String programSource) {
93 if ( GL11.glGetError() == GL11.GL_INVALID_OPERATION ) {
94 final int errorPos = GL11.glGetInteger(ARBProgram.GL_PROGRAM_ERROR_POSITION_ARB);
93 if ( glGetError() == GL_INVALID_OPERATION ) {
94 final int errorPos = glGetInteger(GL_PROGRAM_ERROR_POSITION_ARB);
9595 int lineStart = 0;
9696 int lineEnd = -1;
9797 for ( int i = 0; i < programSource.length(); i++ ) {
110110
111111 ShadersTest.kill("Low-level program error in file: " + programFile
112112 + "\n\tError line: " + programSource.substring(lineStart, lineEnd)
113 + "\n\tError message: " + GL11.glGetString(ARBProgram.GL_PROGRAM_ERROR_STRING_ARB));
113 + "\n\tError message: " + glGetString(GL_PROGRAM_ERROR_STRING_ARB));
114114 }
115115 }
116116
117117 protected static int getUniformLocation(int ID, String name) {
118 final int location = ARBShaderObjects.glGetUniformLocationARB(ID, name);
118 final int location = glGetUniformLocationARB(ID, name);
119119
120120 if ( location == -1 )
121121 throw new IllegalArgumentException("The uniform \"" + name + "\" does not exist in the Shader Program.");
124124 }
125125
126126 protected static void printShaderObjectInfoLog(String file, int ID) {
127 final int logLength = ARBShaderObjects.glGetObjectParameteriARB(ID, ARBShaderObjects.GL_OBJECT_INFO_LOG_LENGTH_ARB);
127 final int logLength = glGetObjectParameteriARB(ID, GL_OBJECT_INFO_LOG_LENGTH_ARB);
128128 if ( logLength <= 1 )
129129 return;
130130
131131 System.out.println("\nInfo Log of Shader Object: " + file);
132132 System.out.println("--------------------------");
133 System.out.println(ARBShaderObjects.glGetInfoLogARB(ID, logLength));
133 System.out.println(glGetInfoLogARB(ID, logLength));
134134
135135 }
136136
137137 protected static void printShaderProgramInfoLog(int ID) {
138 final int logLength = ARBShaderObjects.glGetObjectParameteriARB(ID, ARBShaderObjects.GL_OBJECT_INFO_LOG_LENGTH_ARB);
138 final int logLength = glGetObjectParameteriARB(ID, GL_OBJECT_INFO_LOG_LENGTH_ARB);
139139 if ( logLength <= 1 )
140140 return;
141141
142142 System.out.println("\nShader Program Info Log: ");
143143 System.out.println("--------------------------");
144 System.out.println(ARBShaderObjects.glGetInfoLogARB(ID, logLength));
144 System.out.println(glGetInfoLogARB(ID, logLength));
145145 }
146146
147147 }
3838 package org.lwjgl.test.opengl.shaders;
3939
4040 import org.lwjgl.opengl.ARBFragmentProgram;
41 import org.lwjgl.opengl.ARBProgram;
4241 import org.lwjgl.opengl.ARBVertexProgram;
43 import org.lwjgl.opengl.GL11;
42
43 import static org.lwjgl.opengl.ARBProgram.*;
44 import static org.lwjgl.opengl.GL11.*;
4445
4546 final class ShaderFP extends Shader {
4647
5960 vpFile = vpShaderFile;
6061 vpSource = getShaderText(vpShaderFile);
6162
62 vpID = ARBProgram.glGenProgramsARB();
63 vpID = glGenProgramsARB();
6364
64 ARBProgram.glBindProgramARB(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB, vpID);
65 ARBProgram.glProgramStringARB(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB, ARBProgram.GL_PROGRAM_FORMAT_ASCII_ARB, vpSource);
65 glBindProgramARB(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB, vpID);
66 glProgramStringARB(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, vpSource);
6667
6768 checkProgramError(vpFile, vpSource);
6869
7071 fpFile = fpShaderFile;
7172 fpSource = getShaderText(fpShaderFile);
7273
73 fpID = ARBProgram.glGenProgramsARB();
74 fpID = glGenProgramsARB();
7475
75 ARBProgram.glBindProgramARB(ARBFragmentProgram.GL_FRAGMENT_PROGRAM_ARB, fpID);
76 ARBProgram.glProgramStringARB(ARBFragmentProgram.GL_FRAGMENT_PROGRAM_ARB, ARBProgram.GL_PROGRAM_FORMAT_ASCII_ARB, fpSource);
76 glBindProgramARB(ARBFragmentProgram.GL_FRAGMENT_PROGRAM_ARB, fpID);
77 glProgramStringARB(ARBFragmentProgram.GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, fpSource);
7778
7879 checkProgramError(fpFile, fpSource);
7980 }
8081
8182 void render() {
82 GL11.glEnable(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB);
83 ARBProgram.glBindProgramARB(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB, vpID);
83 glEnable(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB);
84 glBindProgramARB(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB, vpID);
8485
85 GL11.glEnable(ARBFragmentProgram.GL_FRAGMENT_PROGRAM_ARB);
86 ARBProgram.glBindProgramARB(ARBFragmentProgram.GL_FRAGMENT_PROGRAM_ARB, fpID);
86 glEnable(ARBFragmentProgram.GL_FRAGMENT_PROGRAM_ARB);
87 glBindProgramARB(ARBFragmentProgram.GL_FRAGMENT_PROGRAM_ARB, fpID);
8788
88 ARBProgram.glProgramLocalParameter4fARB(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB, 0,
89 ShadersTest.getSin(), ShadersTest.getSpecularity() * 8.0f, 0.0f, 0.0f);
89 glProgramLocalParameter4fARB(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB, 0,
90 ShadersTest.getSin(), ShadersTest.getSpecularity() * 8.0f, 0.0f, 0.0f);
9091
91 ARBProgram.glProgramLocalParameter4fARB(ARBFragmentProgram.GL_FRAGMENT_PROGRAM_ARB, 0,
92 ShadersTest.getSin(), ShadersTest.getSpecularity() * 8.0f,
93 -ShadersTest.getDisplayWidth() * 0.5f, -ShadersTest.getDisplayHeight() * 0.5f);
92 glProgramLocalParameter4fARB(ARBFragmentProgram.GL_FRAGMENT_PROGRAM_ARB, 0,
93 ShadersTest.getSin(), ShadersTest.getSpecularity() * 8.0f,
94 -ShadersTest.getDisplayWidth() * 0.5f, -ShadersTest.getDisplayHeight() * 0.5f);
9495
9596 ShadersTest.renderObject();
9697
97 GL11.glDisable(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB);
98 GL11.glDisable(ARBFragmentProgram.GL_FRAGMENT_PROGRAM_ARB);
98 glDisable(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB);
99 glDisable(ARBFragmentProgram.GL_FRAGMENT_PROGRAM_ARB);
99100 }
100101
101102 void cleanup() {
102 ARBProgram.glDeleteProgramsARB(vpID);
103 ARBProgram.glDeleteProgramsARB(fpID);
103 glDeleteProgramsARB(vpID);
104 glDeleteProgramsARB(fpID);
104105 }
105106
106107 }
3737
3838 package org.lwjgl.test.opengl.shaders;
3939
40 import org.lwjgl.opengl.ARBFragmentShader;
41 import org.lwjgl.opengl.ARBShaderObjects;
42 import org.lwjgl.opengl.ARBVertexShader;
43 import org.lwjgl.opengl.GL11;
40 import static org.lwjgl.opengl.ARBFragmentShader.*;
41 import static org.lwjgl.opengl.ARBShaderObjects.*;
42 import static org.lwjgl.opengl.ARBVertexShader.*;
43 import static org.lwjgl.opengl.GL11.*;
4444
4545 final class ShaderFSH extends Shader {
4646
6363 this.vshFile = vshFile;
6464 vshSource = getShaderText(vshFile);
6565
66 vshID = ARBShaderObjects.glCreateShaderObjectARB(ARBVertexShader.GL_VERTEX_SHADER_ARB);
67 ARBShaderObjects.glShaderSourceARB(vshID, vshSource);
68 ARBShaderObjects.glCompileShaderARB(vshID);
66 vshID = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
67 glShaderSourceARB(vshID, vshSource);
68 glCompileShaderARB(vshID);
6969
7070 printShaderObjectInfoLog(this.vshFile, vshID);
7171
72 if ( ARBShaderObjects.glGetObjectParameteriARB(vshID, ARBShaderObjects.GL_OBJECT_COMPILE_STATUS_ARB) == GL11.GL_FALSE )
72 if ( glGetObjectParameteriARB(vshID, GL_OBJECT_COMPILE_STATUS_ARB) == GL_FALSE )
7373 ShadersTest.kill("A compilation error occured in a vertex shader.");
7474
7575 // Initialize the fragment shader.
7676 this.fshFile = fshFile;
7777 fshSource = getShaderText(fshFile);
7878
79 fshID = ARBShaderObjects.glCreateShaderObjectARB(ARBFragmentShader.GL_FRAGMENT_SHADER_ARB);
80 ARBShaderObjects.glShaderSourceARB(fshID, fshSource);
81 ARBShaderObjects.glCompileShaderARB(fshID);
79 fshID = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
80 glShaderSourceARB(fshID, fshSource);
81 glCompileShaderARB(fshID);
8282
8383 printShaderObjectInfoLog(this.fshFile, fshID);
8484
85 if ( ARBShaderObjects.glGetObjectParameteriARB(fshID, ARBShaderObjects.GL_OBJECT_COMPILE_STATUS_ARB) == GL11.GL_FALSE )
85 if ( glGetObjectParameteriARB(fshID, GL_OBJECT_COMPILE_STATUS_ARB) == GL_FALSE )
8686 ShadersTest.kill("A compilation error occured in a fragment shader.");
8787
8888 // Initialize the shader program.
89 programID = ARBShaderObjects.glCreateProgramObjectARB();
89 programID = glCreateProgramObjectARB();
9090
91 ARBShaderObjects.glAttachObjectARB(programID, vshID);
92 ARBShaderObjects.glAttachObjectARB(programID, fshID);
91 glAttachObjectARB(programID, vshID);
92 glAttachObjectARB(programID, fshID);
9393
94 ARBShaderObjects.glLinkProgramARB(programID);
94 glLinkProgramARB(programID);
9595
9696 printShaderProgramInfoLog(programID);
9797
98 if ( ARBShaderObjects.glGetObjectParameteriARB(programID, ARBShaderObjects.GL_OBJECT_LINK_STATUS_ARB) == GL11.GL_FALSE )
98 if ( glGetObjectParameteriARB(programID, GL_OBJECT_LINK_STATUS_ARB) == GL_FALSE )
9999 ShadersTest.kill("A linking error occured in a shader program.");
100100
101101 uniformLocation = getUniformLocation(programID, "UNIFORMS");
102102 }
103103
104104 void render() {
105 ARBShaderObjects.glUseProgramObjectARB(programID);
105 glUseProgramObjectARB(programID);
106106
107 ARBShaderObjects.glUniform4fARB(uniformLocation,
108 ShadersTest.getSin(), ShadersTest.getSpecularity() * 8.0f,
109 -ShadersTest.getDisplayWidth() * 0.5f, -ShadersTest.getDisplayHeight() * 0.5f);
107 glUniform4fARB(uniformLocation,
108 ShadersTest.getSin(), ShadersTest.getSpecularity() * 8.0f,
109 -ShadersTest.getDisplayWidth() * 0.5f, -ShadersTest.getDisplayHeight() * 0.5f);
110110
111111 ShadersTest.renderObject();
112112
113 ARBShaderObjects.glUseProgramObjectARB(0);
113 glUseProgramObjectARB(0);
114114 }
115115
116116 void cleanup() {
117 ARBShaderObjects.glDetachObjectARB(programID, vshID);
118 ARBShaderObjects.glDetachObjectARB(programID, fshID);
117 glDetachObjectARB(programID, vshID);
118 glDetachObjectARB(programID, fshID);
119119
120 ARBShaderObjects.glDeleteObjectARB(vshID);
121 ARBShaderObjects.glDeleteObjectARB(fshID);
120 glDeleteObjectARB(vshID);
121 glDeleteObjectARB(fshID);
122122
123 ARBShaderObjects.glDeleteObjectARB(programID);
123 glDeleteObjectARB(programID);
124124 }
125125
126126 }
4242 import java.nio.FloatBuffer;
4343 import java.nio.IntBuffer;
4444
45 import static org.lwjgl.opengl.ARBUniformBufferObject.*;
46 import static org.lwjgl.opengl.GL11.*;
47 import static org.lwjgl.opengl.GL15.*;
48 import static org.lwjgl.opengl.GL20.*;
49
4550 final class ShaderUNI extends Shader {
4651
4752 final String file;
6368 file = shaderFile;
6469 source = getShaderText(shaderFile);
6570
66 shaderID = GL20.glCreateShader(GL20.GL_VERTEX_SHADER);
67 GL20.glShaderSource(shaderID, source);
68 GL20.glCompileShader(shaderID);
71 shaderID = glCreateShader(GL_VERTEX_SHADER);
72 glShaderSource(shaderID, source);
73 glCompileShader(shaderID);
6974
7075 printShaderObjectInfoLog(file, shaderID);
7176
72 if ( GL20.glGetShader(shaderID, GL20.GL_COMPILE_STATUS) == GL11.GL_FALSE )
77 if ( glGetShader(shaderID, GL_COMPILE_STATUS) == GL_FALSE )
7378 ShadersTest.kill("A compilation error occured in a vertex shader.");
7479
75 programID = GL20.glCreateProgram();
80 programID = glCreateProgram();
7681
77 GL20.glAttachShader(programID, shaderID);
78 GL20.glLinkProgram(programID);
82 glAttachShader(programID, shaderID);
83 glLinkProgram(programID);
7984
8085 printShaderProgramInfoLog(programID);
8186
82 if ( GL20.glGetProgram(programID, GL20.GL_LINK_STATUS) == GL11.GL_FALSE )
87 if ( glGetProgram(programID, GL_LINK_STATUS) == GL_FALSE )
8388 ShadersTest.kill("A linking error occured in a shader program.");
8489
8590 final String[] uniformNames = { "uniformA", "uniformB" };
8691
8792 // Get uniform block index and data size
88 final int blockIndex = ARBUniformBufferObject.glGetUniformBlockIndex(programID, "test");
89 final int blockSize = ARBUniformBufferObject.glGetActiveUniformBlock(programID, blockIndex, ARBUniformBufferObject.GL_UNIFORM_BLOCK_DATA_SIZE);
93 final int blockIndex = glGetUniformBlockIndex(programID, "test");
94 final int blockSize = glGetActiveUniformBlock(programID, blockIndex, GL_UNIFORM_BLOCK_DATA_SIZE);
9095
9196 System.out.println("blockSize = " + blockSize);
9297
9398 // Create uniform buffer object and allocate a ByteBuffer
94 bufferID = GL15.glGenBuffers();
95 GL15.glBindBuffer(ARBUniformBufferObject.GL_UNIFORM_BUFFER, bufferID);
96 GL15.glBufferData(ARBUniformBufferObject.GL_UNIFORM_BUFFER, blockSize, GL15.GL_DYNAMIC_DRAW);
99 bufferID = glGenBuffers();
100 glBindBuffer(GL_UNIFORM_BUFFER, bufferID);
101 glBufferData(GL_UNIFORM_BUFFER, blockSize, GL_DYNAMIC_DRAW);
97102 buffer = BufferUtils.createFloatBuffer(blockSize);
98103
99104 // Attach UBO and associate uniform block to binding point 0
100 ARBUniformBufferObject.glBindBufferBase(ARBUniformBufferObject.GL_UNIFORM_BUFFER, 0, bufferID);
101 ARBUniformBufferObject.glUniformBlockBinding(programID, blockIndex, 0);
105 glBindBufferBase(GL_UNIFORM_BUFFER, 0, bufferID);
106 glUniformBlockBinding(programID, blockIndex, 0);
102107
103108 // Get uniform information
104109 IntBuffer indexes = BufferUtils.createIntBuffer(uniformNames.length);
105110 IntBuffer params = BufferUtils.createIntBuffer(uniformNames.length);
106111
107 ARBUniformBufferObject.glGetUniformIndices(programID, uniformNames, indexes);
112 glGetUniformIndices(programID, uniformNames, indexes);
108113 uniformA_index = indexes.get(0);
109114 uniformB_index = indexes.get(1);
110115
111 ARBUniformBufferObject.glGetActiveUniforms(programID, indexes, ARBUniformBufferObject.GL_UNIFORM_OFFSET, params);
116 glGetActiveUniforms(programID, indexes, GL_UNIFORM_OFFSET, params);
112117 uniformA_offset = params.get(0);
113118 uniformB_offset = params.get(1);
114119
122127 }
123128
124129 void render() {
125 GL20.glUseProgram(programID);
130 glUseProgram(programID);
126131
127132 //* -- std140 layout
128133 // Uniform A
130135 // Uniform B - str140 alignment at 16 bytes
131136 buffer.put(4, 0.0f).put(5, 0.7f).put(6, 0.0f);
132137
133 GL15.glBindBuffer(ARBUniformBufferObject.GL_UNIFORM_BUFFER, bufferID);
134 GL15.glBufferData(ARBUniformBufferObject.GL_UNIFORM_BUFFER, buffer, GL15.GL_DYNAMIC_DRAW);
138 glBindBuffer(GL_UNIFORM_BUFFER, bufferID);
139 glBufferData(GL_UNIFORM_BUFFER, buffer, GL_DYNAMIC_DRAW);
135140 //*/
136141
137142 /* -- non-std140 layout
138143 // Uniform A
139144 buffer.put(ShadersTest.getSin()).put(ShadersTest.getSpecularity() * 8.0f);
140145 buffer.flip();
141 GL15.glBufferSubData(ARBUniformBufferObject.GL_UNIFORM_BUFFER, uniformA_offset, buffer);
146 glBufferSubData(GL_UNIFORM_BUFFER, uniformA_offset, buffer);
142147 // Uniform B
143148 buffer.clear();
144149 buffer.put(0.0f).put(0.7f).put(0.0f);
145150 buffer.flip();
146 GL15.glBufferSubData(ARBUniformBufferObject.GL_UNIFORM_BUFFER, uniformB_offset, buffer);
151 glBufferSubData(GL_UNIFORM_BUFFER, uniformB_offset, buffer);
147152 //*/
148153
149154 ShadersTest.renderObject();
150155
151 GL20.glUseProgram(0);
156 glUseProgram(0);
152157 }
153158
154159 void cleanup() {
155 GL15.glDeleteBuffers(bufferID);
160 glDeleteBuffers(bufferID);
156161
157 GL20.glDetachShader(programID, shaderID);
162 glDetachShader(programID, shaderID);
158163
159 GL20.glDeleteShader(shaderID);
160 GL20.glDeleteProgram(programID);
164 glDeleteShader(shaderID);
165 glDeleteProgram(programID);
161166 }
162167
163168 }
3737
3838 package org.lwjgl.test.opengl.shaders;
3939
40 import org.lwjgl.opengl.ARBProgram;
41 import org.lwjgl.opengl.ARBVertexProgram;
42 import org.lwjgl.opengl.GL11;
40 import static org.lwjgl.opengl.ARBVertexProgram.*;
41 import static org.lwjgl.opengl.GL11.*;
4342
4443 final class ShaderVP extends Shader {
4544
5251 file = shaderFile;
5352 source = getShaderText(shaderFile);
5453
55 ID = ARBProgram.glGenProgramsARB();
54 ID = glGenProgramsARB();
5655
57 ARBProgram.glBindProgramARB(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB, ID);
58 ARBProgram.glProgramStringARB(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB, ARBProgram.GL_PROGRAM_FORMAT_ASCII_ARB, source);
56 glBindProgramARB(GL_VERTEX_PROGRAM_ARB, ID);
57 glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, source);
5958
6059 checkProgramError(file, source);
6160 }
6261
6362 void render() {
64 GL11.glEnable(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB);
65 ARBProgram.glBindProgramARB(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB, ID);
63 glEnable(GL_VERTEX_PROGRAM_ARB);
64 glBindProgramARB(GL_VERTEX_PROGRAM_ARB, ID);
6665
67 ARBProgram.glProgramLocalParameter4fARB(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB, 0,
68 ShadersTest.getSin(), ShadersTest.getSpecularity() * 8.0f, 0.0f, 0.0f);
66 glProgramLocalParameter4fARB(GL_VERTEX_PROGRAM_ARB, 0,
67 ShadersTest.getSin(), ShadersTest.getSpecularity() * 8.0f, 0.0f, 0.0f);
6968
7069 ShadersTest.renderObject();
7170
72 GL11.glDisable(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB);
71 glDisable(GL_VERTEX_PROGRAM_ARB);
7372 }
7473
7574 void cleanup() {
76 ARBProgram.glDeleteProgramsARB(ID);
75 glDeleteProgramsARB(ID);
7776 }
7877
7978 }
3737
3838 package org.lwjgl.test.opengl.shaders;
3939
40 import org.lwjgl.opengl.ARBShaderObjects;
41 import org.lwjgl.opengl.ARBVertexShader;
42 import org.lwjgl.opengl.GL11;
40 import static org.lwjgl.opengl.ARBShaderObjects.*;
41 import static org.lwjgl.opengl.ARBVertexShader.*;
42 import static org.lwjgl.opengl.GL11.*;
4343
4444 final class ShaderVSH extends Shader {
4545
5555 file = shaderFile;
5656 source = getShaderText(shaderFile);
5757
58 shaderID = ARBShaderObjects.glCreateShaderObjectARB(ARBVertexShader.GL_VERTEX_SHADER_ARB);
59 ARBShaderObjects.glShaderSourceARB(shaderID, source);
60 ARBShaderObjects.glCompileShaderARB(shaderID);
58 shaderID = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
59 glShaderSourceARB(shaderID, source);
60 glCompileShaderARB(shaderID);
6161
6262 printShaderObjectInfoLog(file, shaderID);
6363
64 if ( ARBShaderObjects.glGetObjectParameteriARB(shaderID, ARBShaderObjects.GL_OBJECT_COMPILE_STATUS_ARB) == GL11.GL_FALSE )
64 if ( glGetObjectParameteriARB(shaderID, GL_OBJECT_COMPILE_STATUS_ARB) == GL_FALSE )
6565 ShadersTest.kill("A compilation error occured in a vertex shader.");
6666
67 programID = ARBShaderObjects.glCreateProgramObjectARB();
67 programID = glCreateProgramObjectARB();
6868
69 ARBShaderObjects.glAttachObjectARB(programID, shaderID);
70 ARBShaderObjects.glLinkProgramARB(programID);
69 glAttachObjectARB(programID, shaderID);
70 glLinkProgramARB(programID);
7171
7272 printShaderProgramInfoLog(programID);
7373
74 if ( ARBShaderObjects.glGetObjectParameteriARB(programID, ARBShaderObjects.GL_OBJECT_LINK_STATUS_ARB) == GL11.GL_FALSE )
74 if ( glGetObjectParameteriARB(programID, GL_OBJECT_LINK_STATUS_ARB) == GL_FALSE )
7575 ShadersTest.kill("A linking error occured in a shader program.");
7676
7777 uniformLocation = getUniformLocation(programID, "UNIFORMS");
7878 }
7979
8080 void render() {
81 ARBShaderObjects.glUseProgramObjectARB(programID);
81 glUseProgramObjectARB(programID);
8282
83 ARBShaderObjects.glUniform2fARB(uniformLocation, ShadersTest.getSin(), ShadersTest.getSpecularity() * 8.0f);
83 glUniform2fARB(uniformLocation, ShadersTest.getSin(), ShadersTest.getSpecularity() * 8.0f);
8484
8585 ShadersTest.renderObject();
8686
87 ARBShaderObjects.glUseProgramObjectARB(0);
87 glUseProgramObjectARB(0);
8888 }
8989
9090 void cleanup() {
91 ARBShaderObjects.glDetachObjectARB(programID, shaderID);
91 glDetachObjectARB(programID, shaderID);
9292
93 ARBShaderObjects.glDeleteObjectARB(shaderID);
94 ARBShaderObjects.glDeleteObjectARB(programID);
93 glDeleteObjectARB(shaderID);
94 glDeleteObjectARB(programID);
9595 }
9696
9797 }
4545 import org.lwjgl.input.Keyboard;
4646 import org.lwjgl.input.Mouse;
4747 import org.lwjgl.opengl.*;
48 import org.lwjgl.util.glu.GLU;
4948 import org.lwjgl.util.glu.Sphere;
49
50 import static org.lwjgl.opengl.GL11.*;
51 import static org.lwjgl.util.glu.GLU.*;
5052
5153 public final class ShadersTest {
5254
9395
9496 handleIO();
9597
96 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
98 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
9799
98100 if ( shader != null )
99101 shader.render();
101103 renderObject();
102104
103105 // Restore camera position.
104 GL11.glPopMatrix();
105 GL11.glPushMatrix();
106 glPopMatrix();
107 glPushMatrix();
106108 }
107109
108110 Display.update();
177179 argsError();
178180 }
179181
180 GL11.glViewport(0, 0, displayMode.getWidth(), displayMode.getHeight());
181
182 GL11.glMatrixMode(GL11.GL_PROJECTION);
183 GL11.glLoadIdentity();
184 GLU.gluPerspective(45, displayMode.getWidth() / (float)displayMode.getHeight(), 1.0f, 10.0f);
185
186 GL11.glMatrixMode(GL11.GL_MODELVIEW);
187 GL11.glLoadIdentity();
182 glViewport(0, 0, displayMode.getWidth(), displayMode.getHeight());
183
184 glMatrixMode(GL_PROJECTION);
185 glLoadIdentity();
186 gluPerspective(45, displayMode.getWidth() / (float)displayMode.getHeight(), 1.0f, 10.0f);
187
188 glMatrixMode(GL_MODELVIEW);
189 glLoadIdentity();
188190
189191 // Setup camera position.
190 GL11.glTranslatef(0.0f, 0.0f, -4.0f);
191 GL11.glRotatef(15.0f, 1.0f, 0.0f, 0.0f);
192 GL11.glPushMatrix();
193
194 GL11.glClearDepth(1.0f);
195 GL11.glDepthFunc(GL11.GL_LEQUAL);
196
197 GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);
198
199 GL11.glFrontFace(GL11.GL_CCW);
200 GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_FILL);
201
202 GL11.glCullFace(GL11.GL_BACK);
203 GL11.glEnable(GL11.GL_CULL_FACE);
204
205 GL11.glAlphaFunc(GL11.GL_NOTEQUAL, 0.0f);
206 GL11.glEnable(GL11.GL_ALPHA_TEST);
207
208 GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
209 GL11.glEnable(GL11.GL_BLEND);
192 glTranslatef(0.0f, 0.0f, -4.0f);
193 glRotatef(15.0f, 1.0f, 0.0f, 0.0f);
194 glPushMatrix();
195
196 glClearDepth(1.0f);
197 glDepthFunc(GL_LEQUAL);
198
199 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
200
201 glFrontFace(GL_CCW);
202 glPolygonMode(GL_FRONT, GL_FILL);
203
204 glCullFace(GL_BACK);
205 glEnable(GL_CULL_FACE);
206
207 glAlphaFunc(GL_NOTEQUAL, 0.0f);
208 glEnable(GL_ALPHA_TEST);
209
210 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
211 glEnable(GL_BLEND);
210212
211213 // Setup lighting for when we have fixed function fragment rendering.
212 GL11.glShadeModel(GL11.GL_SMOOTH);
214 glShadeModel(GL_SMOOTH);
213215
214216 if ( shader == null ) {
215 GL11.glEnable(GL11.GL_LIGHTING);
216 GL11.glEnable(GL11.GL_LIGHT0);
217 glEnable(GL_LIGHTING);
218 glEnable(GL_LIGHT0);
217219 }
218220
219221 vectorBuffer.clear();
220222 vectorBuffer.put(1.0f).put(1.0f).put(1.0f).put(1.0f);
221223 vectorBuffer.clear();
222 GL11.glLight(GL11.GL_LIGHT0, GL11.GL_DIFFUSE, vectorBuffer);
224 glLight(GL_LIGHT0, GL_DIFFUSE, vectorBuffer);
223225
224226 vectorBuffer.put(1.0f).put(1.0f).put(1.0f).put(1.0f);
225227 vectorBuffer.clear();
226 GL11.glLight(GL11.GL_LIGHT0, GL11.GL_AMBIENT, vectorBuffer);
228 glLight(GL_LIGHT0, GL_AMBIENT, vectorBuffer);
227229
228230 vectorBuffer.put(1.0f).put(1.0f).put(0.5f).put(1.0f);
229231 vectorBuffer.clear();
230 GL11.glLight(GL11.GL_LIGHT0, GL11.GL_SPECULAR, vectorBuffer);
232 glLight(GL_LIGHT0, GL_SPECULAR, vectorBuffer);
231233
232234 vectorBuffer.put(-1.0f / 3.0f).put(1.0f / 3.0f).put(1.0f / 3.0f).put(0.0f); // Infinite
233235 vectorBuffer.clear();
234 GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, vectorBuffer);
236 glLight(GL_LIGHT0, GL_POSITION, vectorBuffer);
235237
236238 vectorBuffer.put(0.2f).put(0.2f).put(0.2f).put(1.0f);
237239 vectorBuffer.clear();
238 GL11.glLightModel(GL11.GL_LIGHT_MODEL_AMBIENT, vectorBuffer);
240 glLightModel(GL_LIGHT_MODEL_AMBIENT, vectorBuffer);
239241
240242 sphere = new Sphere();
241243 }
282284 }
283285
284286 static void renderObject() {
285 GL11.glColor3b((byte)255, (byte)255, (byte)255);
287 glColor3b((byte)255, (byte)255, (byte)255);
286288 sphere.draw(1.0f, 32, 32);
287289 }
288290
289291 private static DisplayMode chooseMode(DisplayMode[] modes, int width, int height) {
290292 DisplayMode bestMode = null;
291293
292 for ( int i = 0; i < modes.length; i++ ) {
293 DisplayMode mode = modes[i];
294 for ( DisplayMode mode : modes ) {
294295 if ( mode.getWidth() == width && mode.getHeight() == height && mode.getFrequency() <= 85 ) {
295296 if ( bestMode == null || (mode.getBitsPerPixel() >= bestMode.getBitsPerPixel() && mode.getFrequency() > bestMode.getFrequency()) )
296297 bestMode = mode;
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 */
4141 /**
4242 * Display initialization utility, that can be used to find display modes and pick
4343 * one for you based on your criteria.
44 * @author $Author: matzon $
45 * @version $Revision: 2983 $
46 * $Id: Display.java 2983 2008-04-07 18:36:09Z matzon $
44 * @author $Author: spasi $
45 * @version $Revision: 3418 $
46 * $Id: Display.java 3418 2010-09-28 21:11:35Z spasi $
4747 */
4848 public final class Display {
49
49
5050 private static final boolean DEBUG = false;
51
51
5252 /**
5353 * Determine the available display modes that match the specified minimum and maximum criteria.
5454 * If any given criterium is specified as -1 then it is ignored.
55 *
55 *
5656 * @param minWidth the minimum display resolution in pixels
5757 * @param minHeight the minimum display resolution in pixels
5858 * @param maxWidth the maximum display resolution in pixels
6868 {
6969 // First get the available display modes
7070 DisplayMode[] modes = org.lwjgl.opengl.Display.getAvailableDisplayModes();
71
71
7272 if (LWJGLUtil.DEBUG || DEBUG) {
7373 System.out.println("Available screen modes:");
74 for (int i = 0; i < modes.length; i ++) {
75 System.out.println(modes[i]);
76 }
77 }
78
79 ArrayList matches = new ArrayList(modes.length);
74 for ( DisplayMode mode : modes ) {
75 System.out.println(mode);
76 }
77 }
78
79 ArrayList<DisplayMode> matches = new ArrayList<DisplayMode>(modes.length);
8080
8181 for (int i = 0; i < modes.length; i ++) {
8282 assert modes[i] != null : ""+i+" "+modes.length;
102102 }
103103 matches.add(modes[i]);
104104 }
105
105
106106 DisplayMode[] ret = new DisplayMode[matches.size()];
107107 matches.toArray(ret);
108108 if (LWJGLUtil.DEBUG && DEBUG) {
109109 System.out.println("Filtered screen modes:");
110 for (int i = 0; i < ret.length; i ++) {
111 System.out.println(ret[i]);
112 }
113 }
114
110 for ( DisplayMode mode : ret ) {
111 System.out.println(mode);
112 }
113 }
114
115115 return ret;
116116 }
117
117
118118 /**
119119 * Create the display by choosing from a list of display modes based on an order of preference.
120120 * You must supply a list of allowable display modes, probably by calling getAvailableDisplayModes(),
129129 * @see org.lwjgl.opengl.DisplayMode
130130 */
131131 public static DisplayMode setDisplayMode(DisplayMode[] dm, final String[] param) throws Exception {
132
132
133133 class FieldAccessor {
134134 final String fieldName;
135135 final int order;
157157 throw new IllegalArgumentException("Unknown field "+fieldName);
158158 }
159159 }
160
161 class Sorter implements Comparator {
162
163 final FieldAccessor[] field;
164
160
161 class Sorter implements Comparator<DisplayMode> {
162
163 final FieldAccessor[] accessors;
164
165165 Sorter() {
166 field = new FieldAccessor[param.length];
167 for (int i = 0; i < field.length; i ++) {
166 accessors = new FieldAccessor[param.length];
167 for (int i = 0; i < accessors.length; i ++) {
168168 int idx = param[i].indexOf('=');
169169 if (idx > 0) {
170 field[i] = new FieldAccessor(param[i].substring(0, idx), 0, Integer.parseInt(param[i].substring(idx + 1, param[i].length())), true);
170 accessors[i] = new FieldAccessor(param[i].substring(0, idx), 0, Integer.parseInt(param[i].substring(idx + 1, param[i].length())), true);
171171 } else if (param[i].charAt(0) == '-') {
172 field[i] = new FieldAccessor(param[i].substring(1), -1, 0, false);
172 accessors[i] = new FieldAccessor(param[i].substring(1), -1, 0, false);
173173 } else {
174 field[i] = new FieldAccessor(param[i], 1, 0, false);
174 accessors[i] = new FieldAccessor(param[i], 1, 0, false);
175175 }
176176 }
177177 }
178
178
179179 /**
180180 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
181181 */
182 public int compare(Object o1, Object o2) {
183 DisplayMode dm1 = (DisplayMode) o1;
184 DisplayMode dm2 = (DisplayMode) o2;
185
186 for (int i = 0; i < field.length; i ++) {
187 int f1 = field[i].getInt(dm1);
188 int f2 = field[i].getInt(dm2);
189
190 if (field[i].usePreferred && f1 != f2) {
191 if (f1 == field[i].preferred)
182 public int compare(DisplayMode dm1, DisplayMode dm2) {
183 for ( FieldAccessor accessor : accessors ) {
184 int f1 = accessor.getInt(dm1);
185 int f2 = accessor.getInt(dm2);
186
187 if ( accessor.usePreferred && f1 != f2 ) {
188 if ( f1 == accessor.preferred )
192189 return -1;
193 else if (f2 == field[i].preferred)
190 else if ( f2 == accessor.preferred )
194191 return 1;
195192 else {
196193 // Score according to the difference between the values
197 int absf1 = Math.abs(f1 - field[i].preferred);
198 int absf2 = Math.abs(f2 - field[i].preferred);
199 if (absf1 < absf2)
194 int absf1 = Math.abs(f1 - accessor.preferred);
195 int absf2 = Math.abs(f2 - accessor.preferred);
196 if ( absf1 < absf2 )
200197 return -1;
201 else if (absf1 > absf2)
198 else if ( absf1 > absf2 )
202199 return 1;
203200 else
204201 continue;
205202 }
206 } else if (f1 < f2)
207 return field[i].order;
208 else if (f1 == f2)
203 } else if ( f1 < f2 )
204 return accessor.order;
205 else if ( f1 == f2 )
209206 continue;
210207 else
211 return -field[i].order;
212 }
213
208 return -accessor.order;
209 }
210
214211 return 0;
215212 }
216213 }
217
214
218215 // Sort the display modes
219216 Arrays.sort(dm, new Sorter());
220
217
221218 // Try them out in the appropriate order
222219 if (LWJGLUtil.DEBUG || DEBUG) {
223220 System.out.println("Sorted display modes:");
224 for (int i = 0; i < dm.length; i ++) {
225 System.out.println(dm[i]);
226 }
227 }
228 for (int i = 0; i < dm.length; i ++) {
221 for ( DisplayMode aDm : dm ) {
222 System.out.println(aDm);
223 }
224 }
225 for ( DisplayMode aDm : dm ) {
229226 try {
230 if (LWJGLUtil.DEBUG || DEBUG)
231 System.out.println("Attempting to set displaymode: "+dm[i]);
232 org.lwjgl.opengl.Display.setDisplayMode(dm[i]);
233 return dm[i];
227 if ( LWJGLUtil.DEBUG || DEBUG )
228 System.out.println("Attempting to set displaymode: " + aDm);
229 org.lwjgl.opengl.Display.setDisplayMode(aDm);
230 return aDm;
234231 } catch (Exception e) {
235 if (LWJGLUtil.DEBUG || DEBUG) {
236 System.out.println("Failed to set display mode to "+dm[i]);
232 if ( LWJGLUtil.DEBUG || DEBUG ) {
233 System.out.println("Failed to set display mode to " + aDm);
237234 e.printStackTrace();
238235 }
239236 }
240237 }
241
238
242239 throw new Exception("Failed to set display mode.");
243240 }
244
241
245242 }
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 */
3434
3535 /**
3636 * Readonly interface for Colors
37 * @author $Author: matzon $
38 * @version $Revision: 2983 $
39 * $Id: ReadableColor.java 2983 2008-04-07 18:36:09Z matzon $
37 * @author $Author: spasi $
38 * @version $Revision: 3418 $
39 * $Id: ReadableColor.java 3418 2010-09-28 21:11:35Z spasi $
4040 */
4141 public interface ReadableColor {
4242
4444 * Return the red component (0..255)
4545 * @return int
4646 */
47 public int getRed();
48
47 int getRed();
48
4949 /**
5050 * Return the red component (0..255)
5151 * @return int
5252 */
53 public int getGreen();
54
53 int getGreen();
54
5555 /**
5656 * Return the red component (0..255)
5757 * @return int
5858 */
59 public int getBlue();
60
59 int getBlue();
60
6161 /**
6262 * Return the red component (0..255)
6363 * @return int
6464 */
65 public int getAlpha();
66
65 int getAlpha();
66
6767 /**
6868 * Return the red component
6969 * @return int
7070 */
71 public byte getRedByte();
72
71 byte getRedByte();
72
7373 /**
7474 * Return the red component
7575 * @return int
7676 */
77 public byte getGreenByte();
78
77 byte getGreenByte();
78
7979 /**
8080 * Return the red component
8181 * @return int
8282 */
83 public byte getBlueByte();
84
83 byte getBlueByte();
84
8585 /**
8686 * Return the red component
8787 * @return int
8888 */
89 public byte getAlphaByte();
90
89 byte getAlphaByte();
90
9191 /**
9292 * Write the RGBA color directly out to a ByteBuffer
9393 * @param dest the buffer to write to
9494 */
95 public void writeRGBA(ByteBuffer dest);
96
95 void writeRGBA(ByteBuffer dest);
96
9797 /**
9898 * Write the RGB color directly out to a ByteBuffer
9999 * @param dest the buffer to write to
100100 */
101 public void writeRGB(ByteBuffer dest);
102
101 void writeRGB(ByteBuffer dest);
102
103103 /**
104104 * Write the ABGR color directly out to a ByteBuffer
105105 * @param dest the buffer to write to
106106 */
107 public void writeABGR(ByteBuffer dest);
108
107 void writeABGR(ByteBuffer dest);
108
109109 /**
110110 * Write the BGR color directly out to a ByteBuffer
111111 * @param dest the buffer to write to
112112 */
113 public void writeBGR(ByteBuffer dest);
114
113 void writeBGR(ByteBuffer dest);
114
115115 /**
116116 * Write the BGRA color directly out to a ByteBuffer
117117 * @param dest the buffer to write to
118118 */
119 public void writeBGRA(ByteBuffer dest);
120
119 void writeBGRA(ByteBuffer dest);
120
121121 /**
122122 * Write the ARGB color directly out to a ByteBuffer
123123 * @param dest the buffer to write to
124124 */
125 public void writeARGB(ByteBuffer dest);
126
125 void writeARGB(ByteBuffer dest);
126
127127 /*
128128 * Some standard colors
129129 */
130 public static final ReadableColor RED = new Color(255, 0, 0);
131 public static final ReadableColor ORANGE = new Color(255, 128, 0);
132 public static final ReadableColor YELLOW = new Color(255, 255, 0);
133 public static final ReadableColor GREEN = new Color(0, 255, 0);
134 public static final ReadableColor CYAN = new Color(0, 255, 255);
135 public static final ReadableColor BLUE = new Color(0, 0, 255);
136 public static final ReadableColor PURPLE = new Color(255, 0, 255);
137 public static final ReadableColor WHITE = new Color(255, 255, 255);
138 public static final ReadableColor BLACK = new Color(0, 0, 0);
139 public static final ReadableColor LTGREY = new Color(192, 192, 192);
140 public static final ReadableColor DKGREY = new Color(64, 64, 64);
141 public static final ReadableColor GREY = new Color(128, 128, 128);
130 ReadableColor RED = new Color(255, 0, 0);
131 ReadableColor ORANGE = new Color(255, 128, 0);
132 ReadableColor YELLOW = new Color(255, 255, 0);
133 ReadableColor GREEN = new Color(0, 255, 0);
134 ReadableColor CYAN = new Color(0, 255, 255);
135 ReadableColor BLUE = new Color(0, 0, 255);
136 ReadableColor PURPLE = new Color(255, 0, 255);
137 ReadableColor WHITE = new Color(255, 255, 255);
138 ReadableColor BLACK = new Color(0, 0, 0);
139 ReadableColor LTGREY = new Color(192, 192, 192);
140 ReadableColor DKGREY = new Color(64, 64, 64);
141 ReadableColor GREY = new Color(128, 128, 128);
142142
143143
144
144
145145 }
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 */
3232
3333 /**
3434 * Readonly interface for Dimensions
35 * @author $Author: matzon $
36 * @version $Revision: 2983 $
37 * $Id: ReadableDimension.java 2983 2008-04-07 18:36:09Z matzon $
35 * @author $Author: spasi $
36 * @version $Revision: 3418 $
37 * $Id: ReadableDimension.java 3418 2010-09-28 21:11:35Z spasi $
3838 */
3939 public interface ReadableDimension {
4040
4242 * Get the width
4343 * @return int
4444 */
45 public int getWidth();
46
45 int getWidth();
46
4747 /**
4848 * Get the height
4949 * @return int
5050 */
51 public int getHeight();
52
51 int getHeight();
52
5353 /**
5454 * Copy this ReadableDimension into a destination Dimension
5555 * @param dest The destination
5656 */
57 public void getSize(WritableDimension dest);
57 void getSize(WritableDimension dest);
5858
5959 }
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 */
3232
3333 /**
3434 * Readonly interface for Points
35 * @author $Author: matzon $
36 * @version $Revision: 2983 $
37 * $Id: ReadablePoint.java 2983 2008-04-07 18:36:09Z matzon $
35 * @author $Author: spasi $
36 * @version $Revision: 3418 $
37 * $Id: ReadablePoint.java 3418 2010-09-28 21:11:35Z spasi $
3838 */
3939 public interface ReadablePoint {
4040
4141 /**
4242 * @return int
4343 */
44 public int getX();
45
44 int getX();
45
4646 /**
4747 * @return int
4848 */
49 public int getY();
50
49 int getY();
50
5151 /**
5252 * Copy this ReadablePoint into a destination Point
5353 * @param dest The destination Point, or null, to create a new Point
5454 */
55 public void getLocation(WritablePoint dest);
55 void getLocation(WritablePoint dest);
5656 }
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 */
3232
3333 /**
3434 * Readonly interface for Rectangles
35 * @author $Author: matzon $
36 * @version $Revision: 2983 $
37 * $Id: ReadableRectangle.java 2983 2008-04-07 18:36:09Z matzon $
35 * @author $Author: spasi $
36 * @version $Revision: 3418 $
37 * $Id: ReadableRectangle.java 3418 2010-09-28 21:11:35Z spasi $
3838 */
3939 public interface ReadableRectangle extends ReadableDimension, ReadablePoint {
40
40
4141 /**
4242 * Copy this readable rectangle's bounds into a destination Rectangle
4343 * @param dest The destination Rectangle, or null, to create a new Rectangle
4444 */
45 public void getBounds(WritableRectangle dest);
45 void getBounds(WritableRectangle dest);
4646
4747 }
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 package org.lwjgl.util;
3232
3333 /**
34 *
34 *
3535 * Simple interface to things that can be Rendered.
36 *
37 * @author $Author: matzon $
38 * @version $Revision: 2983 $
39 * $Id: Renderable.java 2983 2008-04-07 18:36:09Z matzon $
36 *
37 * @author $Author: spasi $
38 * @version $Revision: 3418 $
39 * $Id: Renderable.java 3418 2010-09-28 21:11:35Z spasi $
4040 */
4141 public interface Renderable {
42
42
4343 /**
4444 * "Render" this thing. This will involve calls to the GL.
4545 */
46 public void render();
47
46 void render();
47
4848 }
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 */
3838 * All Timers created are updated simultaneously by calling the static method
3939 * tick(). This ensures that within a single iteration of a game loop that
4040 * all timers are updated consistently with each other.
41 *
41 *
4242 * @author cix_foo <cix_foo@users.sourceforge.net>
43 * @version $Revision: 2983 $
44 * $Id: Timer.java 2983 2008-04-07 18:36:09Z matzon $
43 * @version $Revision: 3418 $
44 * $Id: Timer.java 3418 2010-09-28 21:11:35Z spasi $
4545 */
4646 public class Timer {
4747
4848 // Record the timer resolution on classload
4949 private static long resolution = Sys.getTimerResolution();
50
50
5151 // Every so often we will re-query the timer resolution
5252 private static final int QUERY_INTERVAL = 50; // in calls to tick()
53 private static int queryCount = 0;
53 private static int queryCount;
5454
55 // Globally keeps track of time for all instances of Timer
55 // Globally keeps track of time for all instances of Timer
5656 private static long currentTime;
57
57
5858 // When the timer was started
5959 private long startTime;
60
60
6161 // The last time recorded by getTime()
6262 private long lastTime;
6363
6464 // Whether the timer is paused
6565 private boolean paused;
66
66
6767 static {
6868 tick();
6969 }
70
70
7171 /**
7272 * Constructs a timer. The timer will be reset to 0.0 and resumed immediately.
7373 */
7575 reset();
7676 resume();
7777 }
78
78
7979 /**
8080 * @return the time in seconds, as a float
8181 */
9292 public boolean isPaused() {
9393 return paused;
9494 }
95
95
9696 /**
9797 * Pause the timer. Whilst paused the time will not change for this timer
9898 * when tick() is called.
99 *
99 *
100100 * @see #resume()
101101 */
102102 public void pause() {
103103 paused = true;
104104 }
105
105
106106 /**
107107 * Reset the timer. Equivalent to set(0.0f);
108108 * @see #set(float)
110110 public void reset() {
111111 set(0.0f);
112112 }
113
113
114114 /**
115115 * Resume the timer.
116116 * @see #pause()
119119 paused = false;
120120 startTime = currentTime - lastTime;
121121 }
122
122
123123 /**
124124 * Set the time of this timer
125125 * @param newTime the new time, in seconds
129129 startTime = currentTime - newTimeInTicks;
130130 lastTime = newTimeInTicks;
131131 }
132
132
133133 /**
134134 * Get the next time update from the system's hires timer. This method should
135135 * be called once per main loop iteration; all timers are updated simultaneously
137137 */
138138 public static void tick() {
139139 currentTime = Sys.getTime();
140
140
141141 // Periodically refresh the timer resolution:
142142 queryCount ++;
143143 if (queryCount > QUERY_INTERVAL) {
145145 resolution = Sys.getTimerResolution();
146146 }
147147 }
148
148
149149 /**
150150 * Debug output.
151151 */
4545
4646 import org.lwjgl.openal.AL10;
4747
48 import com.sun.media.sound.WaveFileReader;
49
4850 /**
4951 *
5052 * Utitlity class for loading wavefiles.
5153 *
5254 * @author Brian Matzon <brian@matzon.dk>
53 * @version $Revision: 3336 $
54 * $Id: WaveData.java 3336 2010-04-26 21:52:59Z matzon $
55 * @version $Revision: 3438 $
56 * $Id: WaveData.java 3438 2010-10-12 15:34:26Z matzon $
5557 */
5658 public class WaveData {
5759 /** actual wave data */
9193 */
9294 public static WaveData create(URL path) {
9395 try {
94 return create(
95 AudioSystem.getAudioInputStream(
96 new BufferedInputStream(path.openStream())));
96 // due to an issue with AudioSystem.getAudioInputStream
97 // and mixing unsigned and signed code
98 // we will use the reader directly
99 WaveFileReader wfr = new WaveFileReader();
100 return create(wfr.getAudioInputStream(new BufferedInputStream(path.openStream())));
97101 } catch (Exception e) {
98102 org.lwjgl.LWJGLUtil.log("Unable to create from: " + path + ", " + e.getMessage());
99103 return null;
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 */
3434
3535 /**
3636 * Write interface for Colors
37 * @author $Author: matzon $
38 * @version $Revision: 2983 $
39 * $Id: WritableColor.java 2983 2008-04-07 18:36:09Z matzon $
37 * @author $Author: spasi $
38 * @version $Revision: 3418 $
39 * $Id: WritableColor.java 3418 2010-09-28 21:11:35Z spasi $
4040 */
4141 public interface WritableColor {
4242 /**
4343 * Set a color
4444 */
45 public void set(int r, int g, int b, int a);
45 void set(int r, int g, int b, int a);
4646 /**
4747 * Set a color
4848 */
49 public void set(byte r, byte g, byte b, byte a);
49 void set(byte r, byte g, byte b, byte a);
5050 /**
5151 * Set a color
5252 */
53 public void set(int r, int g, int b);
53 void set(int r, int g, int b);
5454 /**
5555 * Set a color
5656 */
57 public void set(byte r, byte g, byte b);
57 void set(byte r, byte g, byte b);
5858 /**
5959 * Set the Red component
6060 */
61 public void setRed(int red);
61 void setRed(int red);
6262 /**
6363 * Set the Green component
6464 */
65 public void setGreen(int green);
65 void setGreen(int green);
6666 /**
6767 * Set the Blue component
6868 */
69 public void setBlue(int blue);
69 void setBlue(int blue);
7070 /**
7171 * Set the Alpha component
7272 */
73 public void setAlpha(int alpha);
73 void setAlpha(int alpha);
7474 /**
7575 * Set the Red component
7676 */
77 public void setRed(byte red);
77 void setRed(byte red);
7878 /**
7979 * Set the Green component
8080 */
81 public void setGreen(byte green);
81 void setGreen(byte green);
8282 /**
8383 * Set the Blue component
8484 */
85 public void setBlue(byte blue);
85 void setBlue(byte blue);
8686 /**
8787 * Set the Alpha component
8888 */
89 public void setAlpha(byte alpha);
89 void setAlpha(byte alpha);
9090 /**
9191 * Read a color from a byte buffer
9292 * @param src The source buffer
9393 */
94 public void readRGBA(ByteBuffer src);
94 void readRGBA(ByteBuffer src);
9595 /**
9696 * Read a color from a byte buffer
9797 * @param src The source buffer
9898 */
99 public void readRGB(ByteBuffer src);
99 void readRGB(ByteBuffer src);
100100 /**
101101 * Read a color from a byte buffer
102102 * @param src The source buffer
103103 */
104 public void readARGB(ByteBuffer src);
104 void readARGB(ByteBuffer src);
105105 /**
106106 * Read a color from a byte buffer
107107 * @param src The source buffer
108108 */
109 public void readBGRA(ByteBuffer src);
109 void readBGRA(ByteBuffer src);
110110 /**
111111 * Read a color from a byte buffer
112112 * @param src The source buffer
113113 */
114 public void readBGR(ByteBuffer src);
114 void readBGR(ByteBuffer src);
115115 /**
116116 * Read a color from a byte buffer
117117 * @param src The source buffer
118118 */
119 public void readABGR(ByteBuffer src);
119 void readABGR(ByteBuffer src);
120120 /**
121121 * Set this color's color by copying another color
122122 * @param src The source color
123123 */
124 public void setColor(ReadableColor src);
124 void setColor(ReadableColor src);
125125 }
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 */
3232
3333 /**
3434 * Write interface for Dimensions
35 * @author $Author: matzon $
36 * @version $Revision: 2983 $
37 * $Id: WritableDimension.java 2983 2008-04-07 18:36:09Z matzon $
35 * @author $Author: spasi $
36 * @version $Revision: 3418 $
37 * $Id: WritableDimension.java 3418 2010-09-28 21:11:35Z spasi $
3838
3939 */
4040 public interface WritableDimension {
41 public void setSize(int w, int h);
42 public void setSize(ReadableDimension d);
41 void setSize(int w, int h);
42 void setSize(ReadableDimension d);
4343 /**
4444 * Sets the height.
4545 * @param height The height to set
4646 */
47 public void setHeight(int height);
47 void setHeight(int height);
4848 /**
4949 * Sets the width.
5050 * @param width The width to set
5151 */
52 public void setWidth(int width);
52 void setWidth(int width);
5353 }
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 */
3232
3333 /**
3434 * Write interface for Points
35 * @author $Author: matzon $
36 * @version $Revision: 2983 $
37 * $Id: WritablePoint.java 2983 2008-04-07 18:36:09Z matzon $
35 * @author $Author: spasi $
36 * @version $Revision: 3418 $
37 * $Id: WritablePoint.java 3418 2010-09-28 21:11:35Z spasi $
3838 */
3939 public interface WritablePoint {
40 public void setLocation(int x, int y);
41 public void setLocation(ReadablePoint p);
42 public void setX(int x);
43 public void setY(int y);
40 void setLocation(int x, int y);
41 void setLocation(ReadablePoint p);
42 void setX(int x);
43 void setY(int y);
4444 }
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 */
3232
3333 /**
3434 * Write interface for Rectangles
35 * @author $Author: matzon $
36 * @version $Revision: 2983 $
37 * $Id: WritableRectangle.java 2983 2008-04-07 18:36:09Z matzon $
35 * @author $Author: spasi $
36 * @version $Revision: 3418 $
37 * $Id: WritableRectangle.java 3418 2010-09-28 21:11:35Z spasi $
3838 */
3939 public interface WritableRectangle extends WritablePoint, WritableDimension {
40
40
4141 /**
4242 * Sets the bounds of the rectangle
4343 * @param x Position of rectangle on x axis
4545 * @param width Width of rectangle
4646 * @param height Height of rectangle
4747 */
48 public void setBounds(int x, int y, int width, int height);
49
48 void setBounds(int x, int y, int width, int height);
49
5050 /**
5151 * Sets the bounds of the rectangle
5252 * @param location
5353 * @param size
5454 */
55 public void setBounds(ReadablePoint location, ReadableDimension size);
56
55 void setBounds(ReadablePoint location, ReadableDimension size);
56
5757 /**
5858 * Sets the bounds of the rectangle
5959 * @param src
6060 */
61 public void setBounds(ReadableRectangle src);
61 void setBounds(ReadableRectangle src);
6262 }
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 */
4545 * <p>
4646 * NOTE: This simple XPM reader does not support extensions nor hotspots
4747 * </p>
48 *
48 *
4949 * @author Brian Matzon <brian@matzon.dk>
5050 * @author Jos Hirth
5151 * @version $Revision$
5555 public class XPMFile {
5656
5757 /** Array of bytes (RGBA) */
58 private byte bytes[] = null;
59
60 private final static int WIDTH = 0;
61
62 private final static int HEIGHT = 1;
63
64 private final static int NUMBER_OF_COLORS = 2;
65
66 private final static int CHARACTERS_PER_PIXEL = 3;
58 private byte bytes[];
59
60 private static final int WIDTH = 0;
61
62 private static final int HEIGHT = 1;
63
64 private static final int NUMBER_OF_COLORS = 2;
65
66 private static final int CHARACTERS_PER_PIXEL = 3;
6767
6868 private static int[] format = new int[4];
6969
7575
7676 /**
7777 * Loads the XPM file
78 *
78 *
7979 * @param file
8080 * path to file
8181 * @return XPMFile loaded, or exception
8888
8989 /**
9090 * Loads the XPM file
91 *
91 *
9292 * @param is
9393 * InputStream to read file from
9494 * @return XPMFile loaded, or exception
127127 try {
128128 LineNumberReader reader = new LineNumberReader(
129129 new InputStreamReader(is));
130 HashMap colors = new HashMap();
130 HashMap<String, Integer> colors = new HashMap<String, Integer>();
131131
132132 format = parseFormat(nextLineOfInterest(reader));
133133
134134 // setup color mapping
135135 for (int i = 0; i < format[NUMBER_OF_COLORS]; i++) {
136136 Object[] colorDefinition = parseColor(nextLineOfInterest(reader));
137 colors.put(colorDefinition[0], colorDefinition[1]);
137 colors.put((String)colorDefinition[0], (Integer)colorDefinition[1]);
138138 }
139139
140140 // read actual image (convert to RGBA)
150150
151151 /**
152152 * Finds the next interesting line of text.
153 *
153 *
154154 * @param reader
155155 * The LineNumberReader to read from
156156 * @return The next interesting String (with stripped quotes)
157157 * @throws IOException
158158 * If any IO exceptions occurs while reading file
159159 */
160 private String nextLineOfInterest(LineNumberReader reader)
160 private static String nextLineOfInterest(LineNumberReader reader)
161161 throws IOException {
162162 String ret;
163163 do {
169169
170170 /**
171171 * Parses the format of the xpm file given a format string
172 *
172 *
173173 * @param format
174174 * String to parse
175175 * @return Array specifying width, height, colors, characters per pixel
176176 */
177 private int[] parseFormat(String format) {
177 private static int[] parseFormat(String format) {
178178 // format should look like this:
179179 // 16 16 122 2
180180
191191 /**
192192 * Given a line defining a color/pixel, parses this into an array containing
193193 * a key and a color
194 *
194 *
195195 * @param line
196196 * Line to parse
197197 * @return Array containing a key (String) and a color (Integer)
198198 */
199 private Object[] parseColor(String line) {
199 private static Object[] parseColor(String line) {
200200 // line should look like this:
201201 // # c #0A0A0A
202202
210210 String color = line.substring(format[CHARACTERS_PER_PIXEL] + 4);
211211
212212 // we always assume type is color, and supplied as #<r><g><b>
213 return new Object[] { key, new Integer(Integer.parseInt(color, 16)) };
213 return new Object[] { key, Integer.parseInt(color, 16) };
214214 }
215215
216216 /**
217217 * Parses an Image line into its byte values
218 *
218 *
219219 * @param line
220220 * Line of chars to parse
221221 * @param format
225225 * @param index
226226 * current index into lines, we've reached
227227 */
228 private void parseImageLine(String line, int[] format, HashMap colors,
228 private void parseImageLine(String line, int[] format, HashMap<String, Integer> colors,
229229 int index) {
230230 // offset for next line
231231 int offset = index * 4 * format[WIDTH];
237237 .substring(
238238 i * format[CHARACTERS_PER_PIXEL],
239239 (i * format[CHARACTERS_PER_PIXEL] + format[CHARACTERS_PER_PIXEL]));
240 Integer color = (Integer) colors.get(key);
241 bytes[offset + (i * 4)] = (byte) ((color.intValue() & 0x00ff0000) >> 16);
242 bytes[offset + ((i * 4) + 1)] = (byte) ((color.intValue() & 0x0000ff00) >> 8);
243 bytes[offset + ((i * 4) + 2)] = (byte) ((color.intValue() & 0x000000ff) >> 0); // looks
240 int color = colors.get(key);
241 bytes[offset + (i * 4)] = (byte) ((color & 0x00ff0000) >> 16);
242 bytes[offset + ((i * 4) + 1)] = (byte) ((color & 0x0000ff00) >> 8);
243 bytes[offset + ((i * 4) + 2)] = (byte) ((color & 0x000000ff) >> 0); // looks
244244 // better
245245 // :)
246246 bytes[offset + ((i * 4) + 3)] = (byte) 0xff; // always 0xff alpha
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 */
3434 import java.applet.AppletStub;
3535 import java.awt.BorderLayout;
3636 import java.awt.Color;
37 import java.awt.EventQueue;
3738 import java.awt.FontMetrics;
3839 import java.awt.Graphics;
3940 import java.awt.Image;
7778 import java.util.jar.JarFile;
7879 import java.util.jar.JarOutputStream;
7980 import java.util.jar.Pack200;
81 import java.util.zip.GZIPInputStream;
8082
8183 import sun.security.util.SecurityConstants;
8284
8789 * while the relevant jars (generic and native) are downloaded from a specified source.
8890 * </p>
8991 * <p>
90 * The downloaded jars are extracted to the users temporary directory - and if enabled, cached for
92 * The downloaded jars are extracted to the users temporary directory - and if enabled, cached for
9193 * faster loading in future uses.
9294 * </p>
9395 * <p>
107109 * <p>
108110 * Additionally the following parameters can be supplied to tweak the behaviour of the AppletLoader.
109111 * <ul>
110 * <li>al_version - [int or float] Version of deployment. If this is specified, the jars will be cached and
112 * <li>al_version - [int or float] Version of deployment. If this is specified, the jars will be cached and
111113 * reused if the version matches. If version doesn't match all of the files are reloaded.</li>
112114 * <li>al_cache - [boolean] Whether to use cache system. <i>Default: true</i>.</li>
113115 * <li>al_debug - [boolean] Whether to enable debug mode. <i>Default: false</i>.</li>
128130 * $Id$
129131 */
130132 public class AppletLoader extends Applet implements Runnable, AppletStub {
131
133
132134 /** initializing */
133135 public static final int STATE_INIT = 1;
134
136
135137 /** determining which packages that are required */
136138 public static final int STATE_DETERMINING_PACKAGES = 2;
137
139
138140 /** checking for already downloaded files */
139141 public static final int STATE_CHECKING_CACHE = 3;
140
142
141143 /** downloading packages */
142144 public static final int STATE_DOWNLOADING = 4;
143
145
144146 /** extracting packages */
145147 public static final int STATE_EXTRACTING_PACKAGES = 5;
146
148
147149 /** updating the classpath */
148150 public static final int STATE_UPDATING_CLASSPATH = 6;
149
151
150152 /** switching to real applet */
151153 public static final int STATE_SWITCHING_APPLET = 7;
152154
153155 /** initializing real applet */
154156 public static final int STATE_INITIALIZE_REAL_APPLET = 8;
155
157
156158 /** stating real applet */
157159 public static final int STATE_START_REAL_APPLET = 9;
158
160
159161 /** done */
160162 public static final int STATE_DONE = 10;
161
163
162164 /** used to calculate length of progress bar */
163165 protected int percentage;
164166
165167 /** current size of download in bytes */
166 protected int currentSizeDownload;
168 protected int currentSizeDownload;
167169
168170 /** total size of download in bytes */
169 protected int totalSizeDownload;
171 protected int totalSizeDownload;
170172
171173 /** current size of extracted in bytes */
172 protected int currentSizeExtract;
174 protected int currentSizeExtract;
173175
174176 /** total size of extracted in bytes */
175 protected int totalSizeExtract;
176
177 protected int totalSizeExtract;
178
177179 /** logo to be shown while loading */
178180 protected Image logo, logoBuffer;
179181
180182 /** progressbar to render while loading */
181183 protected Image progressbar, progressbarBuffer;
182
184
183185 /** offscreen image used */
184186 protected Image offscreen;
185
187
186188 /** set to true while painting is done */
187189 protected boolean painting;
188
190
189191 /** background color of applet */
190192 protected Color bgColor = Color.white;
191193
192194 /** color to write foreground in */
193 protected Color fgColor = Color.black;
195 protected Color fgColor = Color.black;
194196
195197 /** urls of the jars to download */
196198 protected URL[] urlList;
197
199
198200 /** classLoader used to add downloaded jars to the classpath */
199201 protected ClassLoader classLoader;
200
202
201203 /** actual thread that does the loading */
202204 protected Thread loaderThread;
203
205
204206 /** animation thread that renders our load screen while loading */
205207 protected Thread animationThread;
206208
207209 /** applet to load after all downloads are complete */
208210 protected Applet lwjglApplet;
209
211
210212 /** whether a fatal error occured */
211213 protected boolean fatalError;
212
213 /** fatal error that occured */
214 protected String fatalErrorDescription;
215
214
216215 /** whether we're running in debug mode */
217216 protected boolean debugMode;
218
217
219218 /** whether to prepend host to cache path */
220219 protected boolean prependHost;
221
220
222221 /** Used to store file names with lastModified time */
223 protected HashMap filesLastModified;
224
222 protected HashMap<String, Long> filesLastModified;
223
225224 /** Sizes of files to download */
226225 protected int[] fileSizes;
227226
227 /** Number of native jars */
228 protected int nativeJarCount;
229
228230 /** whether to use caching system, only download files that have changed */
229231 protected boolean cacheEnabled;
230
232
231233 /** String to display as a subtask */
232234 protected String subtaskMessage = "";
233235
234236 /** state of applet loader */
235 protected int state = STATE_INIT;
236
237 protected volatile int state = STATE_INIT;
238
237239 /** whether lzma is supported */
238 protected boolean lzmaSupported = false;
239
240 protected boolean lzmaSupported;
241
240242 /** whether pack200 is supported */
241 protected boolean pack200Supported = false;
242
243 protected boolean pack200Supported;
244
243245 /** generic error message to display on error */
244246 protected String[] genericErrorMessage = { "An error occured while loading the applet.",
245247 "Please contact support to resolve this issue.",
246248 "<placeholder for error message>"};
247
249
248250 /** whether a certificate refused error occured */
249251 protected boolean certificateRefused;
250
252
251253 /** error message to display if user refuses to accept certicate*/
252254 protected String[] certificateRefusedMessage = { "Permissions for Applet Refused.",
253255 "Please accept the permissions dialog to allow",
254256 "the applet to continue the loading process."};
255
257
256258 /** have natives been loaded by another instance of this applet */
257 static protected boolean natives_loaded = false;
258
259 protected static boolean natives_loaded;
260
259261 /*
260262 * @see java.applet.Applet#init()
261263 */
262264 public void init() {
263 state = STATE_INIT;
265 setState(STATE_INIT);
264266
265267 // sanity check
266268 String[] requiredArgs = {"al_main", "al_logo", "al_progressbar", "al_jars"};
267 for(int i=0; i<requiredArgs.length; i++) {
268 if(getParameter(requiredArgs[i]) == null) {
269 fatalErrorOccured("missing required applet parameter: " + requiredArgs[i], null);
270 return;
271 }
272 }
273
269 for ( String requiredArg : requiredArgs ) {
270 if ( getParameter(requiredArg) == null ) {
271 fatalErrorOccured("missing required applet parameter: " + requiredArg, null);
272 return;
273 }
274 }
275
274276 // whether to use cache system
275277 cacheEnabled = getBooleanParameter("al_cache", true);
276
278
277279 // whether to run in debug mode
278280 debugMode = getBooleanParameter("al_debug", false);
279
281
280282 // whether to prepend host to cache path
281283 prependHost = getBooleanParameter("al_prepend_host", true);
282
284
283285 // get colors of applet
284286 bgColor = getColor("boxbgcolor", Color.white);
285287 setBackground(bgColor);
286 fgColor = getColor("boxfgcolor", Color.black);
287
288 // load logos
289 logo = getImage(getParameter("al_logo"));
290 progressbar = getImage(getParameter("al_progressbar"));
291
292 //sanity check
293 if(logo == null || progressbar == null) {
294 fatalErrorOccured("Unable to load logo and progressbar images", null);
295 }
296
288 fgColor = getColor("boxfgcolor", Color.black);
289
290 // load logos, if value is "" then skip
291 if (getParameter("al_logo").length() > 0) {
292 logo = getImage(getParameter("al_logo"));
293 }
294 if (getParameter("al_progressbar").length() > 0) {
295 progressbar = getImage(getParameter("al_progressbar"));
296 }
297
297298 // check for lzma support
298299 try {
299300 Class.forName("LZMA.LzmaInputStream");
301302 } catch (Throwable e) {
302303 /* no lzma support */
303304 }
304
305
305306 // check pack200 support
306307 try {
307308 java.util.jar.Pack200.class.getSimpleName();
308309 pack200Supported = true;
309310 } catch (Throwable e) {
310311 /* no pack200 support */
311 }
312 }
312313 }
313314
314315 /**
316317 * @param exception Exception to make stacktrace of
317318 * @return Stacktrace of exception in the form of a string
318319 */
319 private String generateStacktrace(Exception exception) {
320 private static String generateStacktrace(Exception exception) {
320321 Writer result = new StringWriter();
321322 PrintWriter printWriter = new PrintWriter(result);
322323 exception.printStackTrace(printWriter);
335336 loaderThread = new Thread(this);
336337 loaderThread.setName("AppletLoader.loaderThread");
337338 loaderThread.start();
338
339
339340 animationThread = new Thread() {
340341 public void run() {
341342 while(loaderThread != null) {
350351 }
351352 }
352353 }
353
354
354355 /*
355356 * @see java.applet.Applet#stop()
356357 */
359360 lwjglApplet.stop();
360361 }
361362 }
362
363
363364 /*
364365 * @see java.applet.Applet#destroy()
365366 */
367368 if (lwjglApplet != null) {
368369 lwjglApplet.destroy();
369370 }
370
371 }
372
373 /**
374 * Clean up resources
375 */
376 protected void cleanUp() {
371377 progressbar = null;
372378 logo = null;
373
379
374380 logoBuffer = null;
375381 progressbarBuffer = null;
376 }
377
382
383 offscreen = null;
384 }
385
378386 /**
379387 * Retrieves the applet that has been loaded. Useful for liveconnect.
380388 */
381389 public Applet getApplet() {
382390 return lwjglApplet;
383391 }
384
385 /**
386 * Transfers the call of AppletResize from the stub to the lwjglApplet.
392
393 /**
394 * Transfers the call of AppletResize from the stub to the lwjglApplet.
387395 */
388396 public void appletResize(int width, int height) {
389397 resize(width, height);
390 }
398 }
391399
392400 /*
393401 * @see java.awt.Container#update(java.awt.Graphics)
395403 public final void update(Graphics g) {
396404 paint(g);
397405 }
398
406
399407 /*
400408 * @see java.awt.Container#paint(java.awt.Graphics)
401409 */
402410 public void paint(Graphics g) {
403
404411 // don't paint loader if applet loaded
405412 if(state == STATE_DONE) {
413 cleanUp(); // clean up resources
406414 return;
407415 }
408
416
409417 // create offscreen if missing
410418 if (offscreen == null) {
411419 offscreen = createImage(getWidth(), getHeight());
412
420
413421 // 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);
422 if (logo != null) {
423 logoBuffer = createImage(logo.getWidth(null), logo.getHeight(null));
424 // add image observer, it will notify when next animated gif frame is ready
425 offscreen.getGraphics().drawImage(logo, 0, 0, this);
426 // in case image is not animated fill image buffer once
427 imageUpdate(logo, ImageObserver.FRAMEBITS, 0, 0, 0, 0);
428 }
429
430 if (progressbar != null) {
431 progressbarBuffer = createImage(progressbar.getWidth(null), progressbar.getHeight(null));
432 // add image observer, it will notify when next animated gif frame is ready
433 offscreen.getGraphics().drawImage(progressbar, 0, 0, this);
434 // in case image is not animated fill image buffer once
435 imageUpdate(progressbar, ImageObserver.FRAMEBITS, 0, 0, 0, 0);
436 }
424437 }
425438
426439 // draw everything onto an image before drawing to avoid flicker
431444 og.setColor(bgColor);
432445 og.fillRect(0, 0, offscreen.getWidth(null), offscreen.getHeight(null));
433446
434 // get logo position so its in the middle of applet
435 int x = 0, y = 0;
436
437 if(logo != null && !fatalError) {
438 x = (offscreen.getWidth(null) - logo.getWidth(null)) / 2;
439 y = (offscreen.getHeight(null) - logo.getHeight(null)) / 2;
440 }
441
442447 og.setColor(fgColor);
443448 String message = getDescriptionForState();
444449
445450 // if we had a failure of some sort, notify the user
446451 if (fatalError) {
447452 String[] errorMessage = (certificateRefused) ? certificateRefusedMessage : genericErrorMessage;
448
449 if (!certificateRefused) {
450 errorMessage[errorMessage.length-1] = fatalErrorDescription;
451 }
452
453
453454 for(int i=0; i<errorMessage.length; i++) {
454455 if(errorMessage[i] != null) {
455456 int messageX = (offscreen.getWidth(null) - fm.stringWidth(errorMessage[i])) / 2;
456457 int messageY = (offscreen.getHeight(null) - (fm.getHeight() * errorMessage.length)) / 2;
457
458
458459 og.drawString(errorMessage[i], messageX, messageY + i*fm.getHeight());
459460 }
460461 }
461462 } else {
462463 og.setColor(fgColor);
463
464
464465 painting = true;
465
466
467 // get position at the middle of the offscreen buffer
468 int x = offscreen.getWidth(null)/2;
469 int y = offscreen.getHeight(null)/2;
470
466471 // draw logo
467 og.drawImage(logoBuffer, x, y, this);
468
472 if (logo != null) {
473 og.drawImage(logoBuffer, x-logo.getWidth(null)/2, y-logo.getHeight(null)/2, this);
474 }
475
469476 // draw message
470477 int messageX = (offscreen.getWidth(null) - fm.stringWidth(message)) / 2;
471 int messageY = y + logoBuffer.getHeight(null) + 20;
478 int messageY = y + 20;
479
480 if (logo != null) messageY += logo.getHeight(null)/2;
481 else if (progressbar != null) messageY += progressbar.getHeight(null)/2;
482
472483 og.drawString(message, messageX, messageY);
473
484
474485 // draw subtaskmessage, if any
475486 if(subtaskMessage.length() > 0) {
476487 messageX = (offscreen.getWidth(null) - fm.stringWidth(subtaskMessage)) / 2;
478489 }
479490
480491 // draw loading bar, clipping it depending on percentage done
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
492 if (progressbar != null) {
493 int barSize = (progressbar.getWidth(null) * percentage) / 100;
494 og.clipRect(x-progressbar.getWidth(null)/2, 0, barSize, offscreen.getHeight(null));
495 og.drawImage(progressbarBuffer, x-progressbar.getWidth(null)/2, y-progressbar.getHeight(null)/2, this);
496 }
497
485498 painting = false;
486499 }
487
500
488501 og.dispose();
489
502
490503 // finally draw it all centred
491504 g.drawImage(offscreen, (getWidth() - offscreen.getWidth(null))/2, (getHeight() - offscreen.getHeight(null))/2, null);
492505 }
493
494 /**
495 * When an animated gif frame is ready to be drawn the ImageObserver
506
507 /**
508 * When an animated gif frame is ready to be drawn the ImageObserver
496509 * will call this method.
497 *
498 * The Image frame is copied into a buffer, which is then drawn.
510 *
511 * The Image frame is copied into a buffer, which is then drawn.
499512 * This is done to prevent image tearing on gif animations.
500513 */
501514 public boolean imageUpdate(Image img, int flag, int x, int y, int width, int height) {
502
515
516 // finish with this ImageObserver
517 if (state == STATE_DONE) return false;
518
503519 // if image frame is ready to be drawn and is currently not being painted
504520 if (flag == ImageObserver.FRAMEBITS && !painting) {
505521 Image buffer;
506
522
507523 // select which buffer to fill
508524 if (img == logo) buffer = logoBuffer;
509525 else buffer = progressbarBuffer;
510
526
511527 Graphics g = buffer.getGraphics();
512
528
513529 // clear background on buffer
514530 g.setColor(bgColor);
515531 g.fillRect(0, 0, buffer.getWidth(null), buffer.getHeight(null));
516
532
517533 // buffer background is cleared, so draw logo under progressbar
518 if (img == progressbar) g.drawImage(logoBuffer, 0, 0, null);
519
534 if (img == progressbar && logo != null) {
535 g.drawImage(logoBuffer, progressbar.getWidth(null)/2-logo.getWidth(null)/2,
536 progressbar.getHeight(null)/2-logo.getHeight(null)/2, null);
537 }
538
520539 g.drawImage(img, 0, 0, this);
521540 g.dispose();
522
541
523542 repaint();
524543 }
525
544
526545 return true;
527546 }
528547
555574 return "unknown state";
556575 }
557576 }
558
577
559578 /**
560579 * Trims the passed file string based on the available capabilities
561580 * @param file string of files to be trimmed
565584 if (!pack200Supported) {
566585 file = file.replaceAll(".pack", "");
567586 }
568
587
569588 if (!lzmaSupported) {
570589 file = file.replaceAll(".lzma", "");
571 }
590 }
572591 return file;
573592 }
574593
578597 * jar to the urlList
579598 */
580599 protected void loadJarURLs() throws Exception {
581 state = STATE_DETERMINING_PACKAGES;
582
600 setState(STATE_DETERMINING_PACKAGES);
601
583602 // jars to load
584603 String jarList = getParameter("al_jars");
585
586 jarList = trimExtensionByCapabilities(jarList);
587
588 StringTokenizer jar = new StringTokenizer(jarList, ", ");
589
590 int jarCount = jar.countTokens() + 1;
591
592 urlList = new URL[jarCount];
593
594 URL path = getCodeBase();
595
596 // set jars urls
597 for (int i = 0; i < jarCount - 1; i++) {
598 urlList[i] = new URL(path, jar.nextToken());
599 }
600
601 // native jar url
602 String osName = System.getProperty("os.name");
603 String nativeJar = null;
604 String nativeJarList = null;
605
606 String osName = System.getProperty("os.name");
604607
605608 if (osName.startsWith("Win")) {
606
609
607610 // check if arch specific natives have been specified
608611 if (System.getProperty("os.arch").endsWith("64")) {
609 nativeJar = getParameter("al_windows64");
612 nativeJarList = getParameter("al_windows64");
610613 } else {
611 nativeJar = getParameter("al_windows32");
612 }
613
614 if (nativeJar == null) {
615 nativeJar = getParameter("al_windows");
616 }
617
614 nativeJarList = getParameter("al_windows32");
615 }
616
617 if (nativeJarList == null) {
618 nativeJarList = getParameter("al_windows");
619 }
620
618621 } else if (osName.startsWith("Linux")) {
619
622
620623 // check if arch specific natives have been specified
621624 if (System.getProperty("os.arch").endsWith("64")) {
622 nativeJar = getParameter("al_linux64");
625 nativeJarList = getParameter("al_linux64");
623626 } else {
624 nativeJar = getParameter("al_linux32");
625 }
626
627 if (nativeJar == null) {
628 nativeJar = getParameter("al_linux");
629 }
630
631 } else if (osName.startsWith("Mac")) {
632 nativeJar = getParameter("al_mac");
627 nativeJarList = getParameter("al_linux32");
628 }
629
630 if (nativeJarList == null) {
631 nativeJarList = getParameter("al_linux");
632 }
633
634 } else if (osName.startsWith("Mac") || osName.startsWith("Darwin")) {
635 nativeJarList = getParameter("al_mac");
633636 } else if (osName.startsWith("Solaris") || osName.startsWith("SunOS")) {
634 nativeJar = getParameter("al_solaris");
637 nativeJarList = getParameter("al_solaris");
635638 } else if (osName.startsWith("FreeBSD")) {
636 nativeJar = getParameter("al_freebsd");
639 nativeJarList = getParameter("al_freebsd");
637640 } else {
638641 fatalErrorOccured("OS (" + osName + ") not supported", null);
639 }
640
641 if (nativeJar == null) {
642 return;
643 }
644
645 if (nativeJarList == null) {
642646 fatalErrorOccured("no lwjgl natives files found", null);
643 } else {
644 nativeJar = trimExtensionByCapabilities(nativeJar);
645 urlList[jarCount - 1] = new URL(path, nativeJar);
647 return;
648 }
649
650 jarList = trimExtensionByCapabilities(jarList);
651 StringTokenizer jars = new StringTokenizer(jarList, ", ");
652
653 nativeJarList = trimExtensionByCapabilities(nativeJarList);
654 StringTokenizer nativeJars = new StringTokenizer(nativeJarList, ", ");
655
656 int jarCount = jars.countTokens();
657 nativeJarCount = nativeJars.countTokens();
658
659 urlList = new URL[jarCount+nativeJarCount];
660
661 URL path = getCodeBase();
662
663 // set jars urls
664 for (int i = 0; i < jarCount; i++) {
665 urlList[i] = new URL(path, jars.nextToken());
666 }
667
668 for (int i = jarCount; i < jarCount+nativeJarCount; i++) {
669 urlList[i] = new URL(path, nativeJars.nextToken());
646670 }
647671 }
648672
649673 /**
650674 * 4 steps
651 *
675 *
652676 * 1) check version of applet and decide whether to download jars
653677 * 2) download the jars
654678 * 3) extract natives
656680 * 5) switch applets
657681 */
658682 public void run() {
659 state = STATE_CHECKING_CACHE;
660
683 setState(STATE_CHECKING_CACHE);
684
661685 percentage = 5;
662686
663687 try {
665689
666690 // parse the urls for the jars into the url list
667691 loadJarURLs();
668
692
669693 // get path where applet will be stored
670 String path = (String) AccessController.doPrivileged(new PrivilegedExceptionAction() {
671 public Object run() throws Exception {
672
694 String path = AccessController.doPrivileged(new PrivilegedExceptionAction<String>() {
695 public String run() throws Exception {
696
673697 // we append the code base to avoid naming collisions with al_title
674698 String codebase = "";
675699 if(prependHost) {
679703 }
680704 codebase += File.separator;
681705 }
682 return System.getProperty("java.io.tmpdir") + File.separator + codebase + getParameter("al_title") + File.separator;
706 return getCacheDir() + File.separator + codebase + getParameter("al_title") + File.separator;
683707 }
684708 });
685
709
686710 File dir = new File(path);
687711
688712 // create directory
689713 if (!dir.exists()) {
690714 dir.mkdirs();
691715 }
692
716
693717 File versionFile = new File(dir, "version");
694
718
695719 // if specified applet version already available don't download anything
696720 boolean versionAvailable = false;
697721
698722 // version of applet
699723 String version = getParameter("al_version");
700724 float latestVersion = 0;
701
725
702726 // if applet version specifed, check if you have latest version of applet
703727 if (version != null) {
704728
707731 // if version file exists
708732 if (versionFile.exists()) {
709733 // compare to new version
710 if (latestVersion <= readVersionFile(versionFile)) {
734 if (latestVersion != readVersionFile(versionFile)) {
711735 versionAvailable = true;
712736 percentage = 90;
713
737
714738 if(debugMode) {
715739 System.out.println("Loading Cached Applet Version " + latestVersion);
716740 }
723747 if (!versionAvailable) {
724748 // get jars file sizes and check cache
725749 getJarInfo(dir); // 5-15%
726
750
727751 // downloads jars from the server
728752 downloadJars(path); // 15-55%
729
753
730754 // Extract Pack and LZMA files
731755 extractJars(path); // 55-65%
732756
736760 // save version information once jars downloaded successfully
737761 if (version != null) {
738762 percentage = 90;
739 writeVersionFile(dir, latestVersion);
763 writeVersionFile(versionFile, latestVersion);
740764 }
741
765
742766 // save file names with last modified info once downloaded successfully
743767 writeCacheFile(new File(dir, "cache"), filesLastModified);
744768 }
745769
746770 // add the downloaded jars and natives to classpath
747771 updateClassPath(path);
748
749 // switch to LWJGL Applet
750 switchApplet();
751
752 state = STATE_DONE;
772
773 // set lwjgl properties
774 setLWJGLProperties();
775
776 // make applet switch on EDT as an AWT/Swing permission dialog could be called
777 EventQueue.invokeAndWait(new Runnable() {
778 public void run() {
779 try {
780 switchApplet();
781 } catch (Exception e) {
782 fatalErrorOccured("This occurred while '" + getDescriptionForState() + "'", e);
783 }
784 setState(STATE_DONE);
785 repaint();
786 }
787 });
788
753789 } catch (AccessControlException ace) {
754790 fatalErrorOccured(ace.getMessage(), ace);
755791 certificateRefused = true;
756792 } catch (Exception e) {
757 fatalErrorOccured(e.getMessage(), e);
793 fatalErrorOccured("This occurred while '" + getDescriptionForState() + "'", e);
758794 } finally {
759795 loaderThread = null;
760796 }
761797 }
798
799 /**
800 * Parses the java_arguments list and sets lwjgl specific
801 * properties accordingly, before the launch.
802 */
803 protected void setLWJGLProperties() {
804 String lwjglArguments = getParameter("lwjgl_arguments");
805
806 if(lwjglArguments != null && lwjglArguments.length() > 0) {
807 int start = lwjglArguments.indexOf("-Dorg.lwjgl");
808 while(start != -1) {
809 int end = lwjglArguments.indexOf(" ", start);
810 if(end == -1) {
811 end = lwjglArguments.length();
812 }
813 String[] keyValue = lwjglArguments.substring(start+2, end).split("=");
814 System.setProperty(keyValue[0], keyValue[1]);
815 if(debugMode) {
816 System.out.println("Setting property " + keyValue[0] + " to " + keyValue[1]);
817 }
818 start = lwjglArguments.indexOf("-Dorg.lwjgl", end);
819 }
820 }
821 }
822
823 /**
824 * get path to the lwjgl cache directory
825 *
826 * @return path to the lwjgl cache directory
827 */
828 protected String getCacheDir() {
829 String cacheDir = System.getProperty("deployment.user.cachedir");
830
831 if (cacheDir == null || System.getProperty("os.name").startsWith("Win")) {
832 cacheDir = System.getProperty("java.io.tmpdir");
833 }
834
835 return cacheDir + File.separator + "lwjglcache";
836 }
762837
763838 /**
764839 * read the current version file
765 *
840 *
766841 * @param file the file to read
767842 * @return the version value of saved file
768843 * @throws Exception if it fails to read value
776851
777852 /**
778853 * write out version file of applet
779 *
854 *
780855 * @param file the file to write out to
781856 * @param version the version of the applet as a float
782857 * @throws Exception if it fails to write file
786861 dos.writeFloat(version);
787862 dos.close();
788863 }
789
864
790865 /**
791866 * read the current cache file
792 *
867 *
793868 * @param file the file to read
794869 * @return the hashmap containing the files names and lastModified times
795870 * @throws Exception if it fails to read hashmap
796871 */
797 protected HashMap readCacheFile(File file) throws Exception {
872 @SuppressWarnings("unchecked")
873 protected HashMap<String, Long> readCacheFile(File file) throws Exception {
798874 ObjectInputStream dis = new ObjectInputStream(new FileInputStream(file));
799 HashMap hashMap = (HashMap)dis.readObject();
875 HashMap<String, Long> hashMap = (HashMap<String, Long>)dis.readObject();
800876 dis.close();
801877 return hashMap;
802878 }
803879
804880 /**
805881 * write out cache file of applet
806 *
882 *
807883 * @param file the file to write out to
808884 * @param filesLastModified the hashmap containing files names and lastModified times
809885 * @throws Exception if it fails to write file
810886 */
811 protected void writeCacheFile(File file, HashMap filesLastModified) throws Exception {
887 protected void writeCacheFile(File file, HashMap<String, Long> filesLastModified) throws Exception {
812888 ObjectOutputStream dos = new ObjectOutputStream(new FileOutputStream(file));
813889 dos.writeObject(filesLastModified);
814890 dos.close();
818894 * Edits the ClassPath at runtime to include the jars
819895 * that have just been downloaded and then adds the
820896 * lwjgl natives folder property.
821 *
897 *
822898 * @param path location where applet is stored
823899 * @throws Exception if it fails to add classpath
824900 */
825 protected void updateClassPath(String path) throws Exception {
826
827 state = STATE_UPDATING_CLASSPATH;
828
901 protected void updateClassPath(final String path) throws Exception {
902
903 setState(STATE_UPDATING_CLASSPATH);
904
829905 percentage = 95;
830
906
831907 URL[] urls = new URL[urlList.length];
832
908
833909 for (int i = 0; i < urlList.length; i++) {
834910 urls[i] = new URL("file:" + path + getJarName(urlList[i]));
835911 }
836
912
837913 // add downloaded jars to the classpath with required permissions
838914 classLoader = new URLClassLoader(urls) {
839915 protected PermissionCollection getPermissions (CodeSource codesource) {
840916 PermissionCollection perms = null;
841
917
842918 try {
843919 // getPermissions from original classloader is important as it checks for signed jars and shows any security dialogs needed
844920 Method method = SecureClassLoader.class.getDeclaredMethod("getPermissions", new Class[] { CodeSource.class });
845921 method.setAccessible(true);
846922 perms = (PermissionCollection)method.invoke(getClass().getClassLoader(), new Object[] {codesource});
847
923
848924 String host = getCodeBase().getHost();
849
925
850926 if (host != null && (host.length() > 0)) {
851927 // add permission for downloaded jars to access host they were from
852928 perms.add(new SocketPermission(host, SecurityConstants.SOCKET_CONNECT_ACCEPT_ACTION));
853929 }
854 else if (codesource.getLocation().getProtocol().equals("file")) {
930 else if ( "file".equals(codesource.getLocation().getProtocol()) ) {
855931 // if running locally add file permission
856932 String path = codesource.getLocation().getFile().replace('/', File.separatorChar);
857933 perms.add(new FilePermission(path, SecurityConstants.FILE_READ_ACTION));
858934 }
859
935
860936 } catch (Exception e) {
861937 e.printStackTrace();
862938 }
863
939
864940 return perms;
865941 }
942
943 // allow non lwjgl native to be found from cache directory
944 protected String findLibrary (String libname) {
945 return path + "natives" + File.separator + System.mapLibraryName(libname);
946 }
866947 };
867
948
868949 debug_sleep(2000);
869
950
870951 // unload natives loaded by a previous instance of this lwjgl applet
871952 unloadNatives(path);
872
953
873954 // add natives files path to native class path
874955 System.setProperty("org.lwjgl.librarypath", path + "natives");
875956
876957 // Make sure jinput knows about the new path too
877958 System.setProperty("net.java.games.input.librarypath", path + "natives");
878
959
960 // set the library path, useful for non lwjgl natives
961 System.setProperty("java.library.path", path + "natives");
962
879963 // mark natives as loaded
880964 natives_loaded = true;
881965 }
882
966
883967 /**
884968 * Unload natives loaded by a different classloader.
885 *
886 * Due to limitations of the jvm, native files can only
887 * be loaded once and only be used by the classloader
969 *
970 * Due to limitations of the jvm, native files can only
971 * be loaded once and only be used by the classloader
888972 * they were loaded from.
889 *
973 *
890974 * Due to the way applets on plugin1 work, one jvm must
891 * be used for all applets. We need to use multiple
892 * classloaders in the same jvm due to LWJGL's static
893 * nature. I order to solve this we simply remove the
894 * natives from a previous classloader allowing a new
975 * be used for all applets. We need to use multiple
976 * classloaders in the same jvm due to LWJGL's static
977 * nature. In order to solve this we simply remove the
978 * natives from a previous classloader allowing a new
895979 * classloader to use those natives in the same jvm.
896 *
980 *
897981 * This method will only attempt to unload natives from a
898982 * previous classloader if it detects that the natives have
899983 * been loaded in the same jvm.
900 *
984 *
901985 * @param nativePath directory where natives are stored
902986 */
903987 private void unloadNatives(String nativePath) {
904
988
905989 // check whether natives have been loaded into this jvm
906990 if (!natives_loaded) {
907991 return;
908992 }
909
993
910994 try {
911995 Field field = ClassLoader.class.getDeclaredField("loadedLibraryNames");
912996 field.setAccessible(true);
913997 Vector libs = (Vector) field.get(getClass().getClassLoader());
914
998
915999 String path = new File(nativePath).getCanonicalPath();
916
1000
9171001 for (int i = 0; i < libs.size(); i++) {
9181002 String s = (String) libs.get(i);
919
1003
9201004 // if a native from the nativePath directory is loaded, unload it
9211005 if (s.startsWith(path)) {
9221006 libs.remove(i);
9331017 * using AppletStub and initialise and start it
9341018 */
9351019 protected void switchApplet() throws Exception {
936
937 state = STATE_SWITCHING_APPLET;
1020
1021 setState(STATE_SWITCHING_APPLET);
9381022 percentage = 100;
939
1023
9401024 debug_sleep(2000);
9411025
9421026 Class appletClass = classLoader.loadClass(getParameter("al_main"));
9491033 add(lwjglApplet);
9501034 validate();
9511035
952 state = STATE_INITIALIZE_REAL_APPLET;
1036 setState(STATE_INITIALIZE_REAL_APPLET);
9531037 lwjglApplet.init();
9541038
955 state = STATE_START_REAL_APPLET;
1039 setState(STATE_START_REAL_APPLET);
9561040 lwjglApplet.start();
9571041 }
958
1042
9591043 /**
9601044 * This method will get the files sizes of the files to download.
9611045 * It wil further get the lastModified time of files
9621046 * and save it in a hashmap, if cache is enabled it will mark
9631047 * those files that have not changed since last download to not
9641048 * redownloaded.
965 *
1049 *
9661050 * @param dir - location to read cache file from
9671051 * @throws Exception - if fails to get infomation
9681052 */
9691053 protected void getJarInfo(File dir) throws Exception {
970
971 filesLastModified = new HashMap();
972
1054
1055 filesLastModified = new HashMap<String, Long>();
1056
9731057 // store file sizes and mark which files not to download
9741058 fileSizes = new int[urlList.length];
975
1059
9761060 URLConnection urlconnection;
977
1061
9781062 File cacheFile = new File(dir, "cache");
979
1063
9801064 // if cache file exists, load it
9811065 if (cacheFile.exists()) {
9821066 filesLastModified = readCacheFile(cacheFile);
9831067 }
984
1068
9851069 // calculate total size of jars to download
9861070 for (int i = 0; i < urlList.length; i++) {
9871071 urlconnection = urlList[i].openConnection();
9891073 if (urlconnection instanceof HttpURLConnection) {
9901074 ((HttpURLConnection) urlconnection).setRequestMethod("HEAD");
9911075 }
992
1076
9931077 fileSizes[i] = urlconnection.getContentLength();
994
1078
9951079 long lastModified = urlconnection.getLastModified();
9961080 String fileName = getFileName(urlList[i]);
997
998
999 if (cacheEnabled && lastModified != 0 &&
1081
1082
1083 if (cacheEnabled && lastModified != 0 &&
10001084 filesLastModified.containsKey(fileName)) {
1001 long savedLastModified = ((Long)filesLastModified.get(fileName)).longValue();
1002
1085 long savedLastModified = filesLastModified.get(fileName);
1086
10031087 // if lastModifed time is the same, don't redownload
10041088 if (savedLastModified == lastModified) {
10051089 fileSizes[i] = -2; // mark it to not redownload
10061090 }
10071091 }
1008
1092
10091093 if (fileSizes[i] >= 0) {
10101094 totalSizeDownload += fileSizes[i];
10111095 }
1012
1096
10131097 // put key and value in the hashmap
1014 filesLastModified.put(fileName, new Long(lastModified));
1015
1098 filesLastModified.put(fileName, lastModified);
1099
10161100 // update progress bar
10171101 percentage = 5 + (int)(10 * i/(float)urlList.length);
10181102 }
10191103 }
1020
1104
10211105 /**
10221106 * Will download the jars from the server using the list of urls
10231107 * in urlList, while at the same time updating progress bar
1024 *
1108 *
10251109 * @param path location of the directory to save to
10261110 * @throws Exception if download fails
10271111 */
10281112 protected void downloadJars(String path) throws Exception {
1029
1030 state = STATE_DOWNLOADING;
1113
1114 setState(STATE_DOWNLOADING);
10311115
10321116 URLConnection urlconnection;
1033
1117
10341118 int initialPercentage = percentage = 15;
10351119
10361120 // download each jar
10371121 byte buffer[] = new byte[65536];
10381122 for (int i = 0; i < urlList.length; i++) {
1039
1123
10401124 // skip file if marked as -2 (already downloaded and not changed)
10411125 if (fileSizes[i] == -2) continue;
1042
1126
10431127 int unsuccessfulAttempts = 0;
10441128 int maxUnsuccessfulAttempts = 3;
10451129 boolean downloadFile = true;
1046
1130
10471131 // download the jar a max of 3 times
10481132 while(downloadFile) {
10491133 downloadFile = false;
1050
1134
10511135 debug_sleep(2000);
1052
1136
10531137 urlconnection = urlList[i].openConnection();
1054
1138
10551139 if (urlconnection instanceof HttpURLConnection) {
10561140 urlconnection.setRequestProperty("Cache-Control", "no-cache");
10571141 urlconnection.connect();
10581142 }
1059
1143
10601144 String currentFile = getFileName(urlList[i]);
10611145 InputStream inputstream = getJarInputStream(currentFile, urlconnection);
10621146 FileOutputStream fos = new FileOutputStream(path + currentFile);
1063
1064
1147
1148
10651149 int bufferSize;
10661150 long downloadStartTime = System.currentTimeMillis();
10671151 int downloadedAmount = 0;
10681152 int fileSize = 0;
10691153 String downloadSpeedMessage = "";
1070
1154
10711155 while ((bufferSize = inputstream.read(buffer, 0, buffer.length)) != -1) {
10721156 debug_sleep(10);
10731157 fos.write(buffer, 0, bufferSize);
10751159 fileSize += bufferSize;
10761160 percentage = initialPercentage + ((currentSizeDownload * 45) / totalSizeDownload);
10771161 subtaskMessage = "Retrieving: " + currentFile + " " + ((currentSizeDownload * 100) / totalSizeDownload) + "%";
1078
1162
10791163 downloadedAmount += bufferSize;
10801164 long timeLapse = System.currentTimeMillis() - downloadStartTime;
10811165 // update only if a second or more has passed
10911175 // reset start time
10921176 downloadStartTime = System.currentTimeMillis();
10931177 }
1094
1178
10951179 subtaskMessage += downloadSpeedMessage;
10961180 }
1097
1181
10981182 inputstream.close();
10991183 fos.close();
1100
1184
11011185 // download complete, verify if it was successful
11021186 if (urlconnection instanceof HttpURLConnection) {
11031187 if (fileSize == fileSizes[i]) {
11321216 */
11331217 protected InputStream getJarInputStream(final String currentFile, final URLConnection urlconnection) throws Exception {
11341218 final InputStream[] is = new InputStream[1];
1135
1136 // try to get the input stream 3 times.
1219
1220 // try to get the input stream 3 times.
11371221 // Wait at most 5 seconds before interrupting the thread
11381222 for (int j = 0; j < 3 && is[0] == null; j++) {
11391223 Thread t = new Thread() {
11471231 };
11481232 t.setName("JarInputStreamThread");
11491233 t.start();
1150
1234
11511235 int iterationCount = 0;
11521236 while(is[0] == null && iterationCount++ < 5) {
11531237 try {
11561240 /* ignored */
11571241 }
11581242 }
1159
1243
11601244 if(is[0] == null) {
11611245 try {
11621246 t.interrupt();
11661250 }
11671251 }
11681252 }
1169
1253
11701254 if(is[0] == null) {
11711255 throw new Exception("Unable to get input stream for " + currentFile);
11721256 }
11731257
1174
1258
11751259 return is[0];
11761260 }
1177
1261
11781262 /**
11791263 * Extract LZMA File
11801264 * @param in Input path to pack file
11811265 * @param out output path to resulting file
1182 * @throws exception if any errors occur
1266 * @throws Exception if any errors occur
11831267 */
11841268 protected void extractLZMA(String in, String out) throws Exception {
1185
1269
11861270 File f = new File(in);
11871271 FileInputStream fileInputHandle = new FileInputStream(f);
11881272
11891273 // use reflection to avoid hard dependency
1190 Class clazz = Class.forName( "LZMA.LzmaInputStream" );
1191 Constructor constructor = clazz.getDeclaredConstructor( new Class[] {InputStream.class} );
1192 InputStream inputHandle = (InputStream) constructor.newInstance( new Object[] {fileInputHandle} );
1274 Class<?> clazz = Class.forName( "LZMA.LzmaInputStream" );
1275 Constructor constructor = clazz.getDeclaredConstructor(InputStream.class);
1276 InputStream inputHandle = (InputStream) constructor.newInstance(fileInputHandle);
11931277
11941278 OutputStream outputHandle;
11951279 outputHandle = new FileOutputStream(out);
1196
1280
11971281 byte [] buffer = new byte [1<<14];
1198
1282
11991283 int ret = inputHandle.read(buffer);
12001284 while (ret >= 1) {
12011285 outputHandle.write(buffer,0,ret);
12071291
12081292 outputHandle = null;
12091293 inputHandle = null;
1210
1294
12111295 // delete LZMA file, as it is no longer needed
1296 f.delete();
1297 }
1298
1299 /**
1300 * Extract GZip File
1301 * @param in Input path to pack file
1302 * @param out output path to resulting file
1303 * @throws Exception if any errors occur
1304 */
1305 protected void extractGZip(String in, String out) throws Exception {
1306
1307 File f = new File(in);
1308 FileInputStream fileInputHandle = new FileInputStream(f);
1309
1310 InputStream inputHandle = new GZIPInputStream(fileInputHandle);
1311
1312 OutputStream outputHandle;
1313 outputHandle = new FileOutputStream(out);
1314
1315 byte [] buffer = new byte [1<<14];
1316
1317 int ret = inputHandle.read(buffer);
1318 while (ret >= 1) {
1319 outputHandle.write(buffer,0,ret);
1320 ret = inputHandle.read(buffer);
1321 }
1322
1323 inputHandle.close();
1324 outputHandle.close();
1325
1326 outputHandle = null;
1327 inputHandle = null;
1328
1329 // delete GZip file, as it is no longer needed
12121330 f.delete();
12131331 }
12141332
12161334 * Extract Pack File
12171335 * @param in Input path to pack file
12181336 * @param out output path to resulting file
1219 * @throws exception if any errors occur
1220 */
1221 protected void extractPack(String in, String out) throws Exception {
1337 * @throws Exception if any errors occur
1338 */
1339 protected void extractPack(String in, String out) throws Exception {
12221340 File f = new File(in);
12231341 FileOutputStream fostream = new FileOutputStream(out);
12241342 JarOutputStream jostream = new JarOutputStream(fostream);
1225
1343
12261344 Pack200.Unpacker unpacker = Pack200.newUnpacker();
12271345 unpacker.unpack(f, jostream);
12281346 jostream.close();
1229
1347
12301348 // delete pack file as its no longer needed
12311349 f.delete();
12321350 }
1233
1234 /**
1235 * Extract all jars from any lzma/pack files
1236 *
1351
1352 /**
1353 * Extract all jars from any lzma/gz/pack files
1354 *
12371355 * @param path output path
1238 * @throws exception if any errors occur
1356 * @throws Exception if any errors occur
12391357 */
12401358 protected void extractJars(String path) throws Exception {
1241 state = STATE_EXTRACTING_PACKAGES;
1242
1359 setState(STATE_EXTRACTING_PACKAGES);
1360
12431361 float increment = (float) 10.0 / urlList.length;
1244 // extract all lzma and pack.lzma files
1362 // extract all gz, lzma, pack.gz and pack.lzma files
12451363 for (int i = 0; i < urlList.length; i++) {
1246
1364
12471365 // if file has not changed, skip it
12481366 if (fileSizes[i] == -2) continue;
1249
1367
12501368 percentage = 55 + (int) (increment * (i+1));
12511369 String filename = getFileName(urlList[i]);
12521370
12541372 subtaskMessage = "Extracting: " + filename + " to " + filename.replaceAll(".lzma", "");
12551373 debug_sleep(1000);
12561374 extractLZMA(path + filename, path + filename.replaceAll(".lzma", ""));
1257
1375
12581376 subtaskMessage = "Extracting: " + filename.replaceAll(".lzma", "") + " to " + filename.replaceAll(".pack.lzma", "");
12591377 debug_sleep(1000);
12601378 extractPack(path + filename.replaceAll(".lzma", ""), path + filename.replaceAll(".pack.lzma", ""));
1261 }
1379 }
1380 else if (filename.endsWith(".pack.gz")) {
1381 subtaskMessage = "Extracting: " + filename + " to " + filename.replaceAll(".gz", "");
1382 debug_sleep(1000);
1383 extractGZip(path + filename, path + filename.replaceAll(".gz", ""));
1384
1385 subtaskMessage = "Extracting: " + filename.replaceAll(".gz", "") + " to " + filename.replaceAll(".pack.gz", "");
1386 debug_sleep(1000);
1387 extractPack(path + filename.replaceAll(".gz", ""), path + filename.replaceAll(".pack.gz", ""));
1388 }
12621389 else if (filename.endsWith(".pack")) {
12631390 subtaskMessage = "Extracting: " + filename + " to " + filename.replace(".pack", "");
12641391 debug_sleep(1000);
12691396 debug_sleep(1000);
12701397 extractLZMA(path + filename, path + filename.replace(".lzma", ""));
12711398 }
1272 }
1273 }
1399 else if (filename.endsWith(".gz")) {
1400 subtaskMessage = "Extracting: " + filename + " to " + filename.replace(".gz", "");
1401 debug_sleep(1000);
1402 extractGZip(path + filename, path + filename.replace(".gz", ""));
1403 }
1404 }
1405 }
12741406
12751407 /**
12761408 * This method will extract all file from the native jar and extract them
12771409 * to the subdirectory called "natives" in the local path, will also check
1278 * to see if the native jar files is signed properly
1279 *
1410 * to see if the native jar files is signed properly
1411 *
12801412 * @param path base folder containing all downloaded jars
12811413 * @throws Exception if it fails to extract files
12821414 */
12831415 protected void extractNatives(String path) throws Exception {
1284
1285 // if no new native jar was downloaded, no extracting needed
1286 if (fileSizes[fileSizes.length-1] == -2) {
1287 return;
1288 }
1289
1290 state = STATE_EXTRACTING_PACKAGES;
1291
1292 int initialPercentage = percentage;
1293
1294 // get name of jar file with natives from urlList, it will be the last url
1295 String nativeJar = getJarName(urlList[urlList.length - 1]);
1296
1297 // get the current certificate to compare against native files
1416
1417 setState(STATE_EXTRACTING_PACKAGES);
1418
1419 float percentageParts = 20f/nativeJarCount; // parts for each native jar from 20%
1420
1421 // create native folder
1422 File nativeFolder = new File(path + "natives");
1423 if (!nativeFolder.exists()) {
1424 nativeFolder.mkdir();
1425 }
1426
1427 // get the current certificate to compare against native files
12981428 Certificate[] certificate = AppletLoader.class.getProtectionDomain().getCodeSource().getCertificates();
1299
1429
13001430 // workaround for bug where cached applet loader does not have certificates!?
13011431 if (certificate == null) {
13021432 URL location = AppletLoader.class.getProtectionDomain().getCodeSource().getLocation();
1303
1433
13041434 // manually load the certificate
13051435 JarURLConnection jurl = (JarURLConnection) (new URL("jar:" + location.toString() + "!/org/lwjgl/util/applet/AppletLoader.class").openConnection());
13061436 jurl.setDefaultUseCaches(true);
13071437 certificate = jurl.getCertificates();
13081438 }
1309
1310 // create native folder
1311 File nativeFolder = new File(path + "natives");
1312 if (!nativeFolder.exists()) {
1313 nativeFolder.mkdir();
1314 }
1315
1316 // open jar file
1317 JarFile jarFile = new JarFile(path + nativeJar, true);
1318
1319 // get list of files in jar
1320 Enumeration entities = jarFile.entries();
1321
1322 totalSizeExtract = 0;
1323
1324 // calculate the size of the files to extract for progress bar
1325 while (entities.hasMoreElements()) {
1326 JarEntry entry = (JarEntry) entities.nextElement();
1327
1328 // skip directories and anything in directories
1329 // conveniently ignores the manifest
1330 if (entry.isDirectory() || entry.getName().indexOf('/') != -1) {
1439
1440 for (int i = urlList.length - nativeJarCount; i < urlList.length; i++) {
1441
1442 // if a new native jar was not downloaded, no extracting needed
1443 if (fileSizes[i] == -2) {
13311444 continue;
13321445 }
1333 totalSizeExtract += entry.getSize();
1334 }
1335
1336 currentSizeExtract = 0;
1337
1338 // reset point to begining by getting list of file again
1339 entities = jarFile.entries();
1340
1341 // extract all files from the jar
1342 while (entities.hasMoreElements()) {
1343 JarEntry entry = (JarEntry) entities.nextElement();
13441446
1345 // skip directories and anything in directories
1346 // conveniently ignores the manifest
1347 if (entry.isDirectory() || entry.getName().indexOf('/') != -1) {
1348 continue;
1349 }
1350
1351 // check if native file already exists if so delete it to make room for new one
1352 // useful when using the reload button on the browser
1353 File f = new File(path + "natives" + File.separator + entry.getName());
1354 if (f.exists()) {
1355 if (!f.delete()) {
1356 continue; // unable to delete file, it is in use, skip extracting it
1447 // get name of jar file with natives from urlList
1448 String nativeJar = getJarName(urlList[i]);
1449
1450 // open jar file
1451 JarFile jarFile = new JarFile(path + nativeJar, true);
1452
1453 // get list of files in jar
1454 Enumeration entities = jarFile.entries();
1455
1456 totalSizeExtract = 0;
1457 int jarNum = i - (urlList.length - nativeJarCount); // used for progressbar
1458
1459 // calculate the size of the files to extract for progress bar
1460 while (entities.hasMoreElements()) {
1461 JarEntry entry = (JarEntry) entities.nextElement();
1462
1463 // skip directories and anything in directories
1464 // conveniently ignores the manifest
1465 if (entry.isDirectory() || entry.getName().indexOf('/') != -1) {
1466 continue;
13571467 }
1358 }
1359
1360 debug_sleep(1000);
1361
1362 InputStream in = jarFile.getInputStream(jarFile.getEntry(entry.getName()));
1363 OutputStream out = new FileOutputStream(path + "natives" + File.separator + entry.getName());
1364
1365 int bufferSize;
1366 byte buffer[] = new byte[65536];
1367
1368 while ((bufferSize = in.read(buffer, 0, buffer.length)) != -1) {
1369 debug_sleep(10);
1370 out.write(buffer, 0, bufferSize);
1371 currentSizeExtract += bufferSize;
1372
1373 // update progress bar
1374 percentage = initialPercentage + ((currentSizeExtract * 20) / totalSizeExtract);
1375 subtaskMessage = "Extracting: " + entry.getName() + " " + ((currentSizeExtract * 100) / totalSizeExtract) + "%";
1376 }
1377
1378 // validate if the certificate for native file is correct
1379 validateCertificateChain(certificate, entry.getCertificates());
1380
1381 in.close();
1382 out.close();
1383 }
1384 subtaskMessage = "";
1385
1386 jarFile.close();
1387
1388 // delete native jar as it is no longer needed
1389 File f = new File(path + nativeJar);
1390 f.delete();
1468 totalSizeExtract += entry.getSize();
1469 }
1470
1471 currentSizeExtract = 0;
1472
1473 // reset point to begining by getting list of file again
1474 entities = jarFile.entries();
1475
1476 // extract all files from the jar
1477 while (entities.hasMoreElements()) {
1478 JarEntry entry = (JarEntry) entities.nextElement();
1479
1480 // skip directories and anything in directories
1481 // conveniently ignores the manifest
1482 if (entry.isDirectory() || entry.getName().indexOf('/') != -1) {
1483 continue;
1484 }
1485
1486 // check if native file already exists if so delete it to make room for new one
1487 // useful when using the reload button on the browser
1488 File f = new File(path + "natives" + File.separator + entry.getName());
1489 if (f.exists()) {
1490 if (!f.delete()) {
1491 continue; // unable to delete file, it is in use, skip extracting it
1492 }
1493 }
1494
1495 debug_sleep(1000);
1496
1497 InputStream in = jarFile.getInputStream(jarFile.getEntry(entry.getName()));
1498 OutputStream out = new FileOutputStream(path + "natives" + File.separator + entry.getName());
1499
1500 int bufferSize;
1501 byte buffer[] = new byte[65536];
1502
1503 while ((bufferSize = in.read(buffer, 0, buffer.length)) != -1) {
1504 debug_sleep(10);
1505 out.write(buffer, 0, bufferSize);
1506 currentSizeExtract += bufferSize;
1507
1508 // update progress bar
1509 percentage = 65 + (int)(percentageParts * (jarNum + currentSizeExtract/(float)totalSizeExtract));
1510 subtaskMessage = "Extracting: " + entry.getName() + " " + ((currentSizeExtract * 100) / totalSizeExtract) + "%";
1511 }
1512
1513 // validate if the certificate for native file is correct
1514 validateCertificateChain(certificate, entry.getCertificates());
1515
1516 in.close();
1517 out.close();
1518 }
1519 subtaskMessage = "";
1520
1521 jarFile.close();
1522
1523 // delete native jar as it is no longer needed
1524 File f = new File(path + nativeJar);
1525 f.delete();
1526
1527 }
13911528 }
13921529
13931530 /**
13941531 * Validates the certificate chain for a single file
1395 *
1532 *
13961533 * @param ownCerts Chain of certificates to check against
13971534 * @param native_certs Chain of certificates to check
13981535 */
14091546 }
14101547 }
14111548 }
1412
1549
14131550 /**
14141551 * Get Image from path provided
1415 *
1552 *
14161553 * @param s location of the image
14171554 * @return the Image file
14181555 */
14191556 protected Image getImage(String s) {
1557
1558 Image image = null;
1559
14201560 try {
1421 URL url = AppletLoader.class.getResource("/"+s);
1422
1423 // if image not found in jar, look outside it
1424 if (url == null) {
1425 url = new URL(getCodeBase(), s);
1426 }
1427
1561 image = getImage(new URL(getCodeBase(), s));
1562 } catch (Exception e) {
1563 /* */
1564 }
1565
1566 // if image failed to load, try another method
1567 if (image == null) {
1568 image = getImage(Thread.currentThread().getContextClassLoader().getResource(s));
1569 }
1570
1571 // if image loaded sucessfully return it
1572 if (image != null) {
1573 return image;
1574 }
1575
1576 // show error as image could not be loaded
1577 fatalErrorOccured("Unable to load logo and progressbar images", null);
1578 return null;
1579 }
1580
1581 /**
1582 * Get Image from path provided
1583 *
1584 * @param url location of the image
1585 * @return the Image file
1586 */
1587 public Image getImage(URL url) {
1588 try {
14281589 Image image = super.getImage(url);
1429
1590
14301591 // wait for image to load
14311592 MediaTracker tracker = new MediaTracker(this);
14321593 tracker.addImage(image, 0);
14331594 tracker.waitForAll();
1434
1435 return image;
1595
1596 // if no errors return image
1597 if (!tracker.isErrorAny()) {
1598 return image;
1599 }
14361600 } catch (Exception e) {
14371601 /* */
14381602 }
1603
14391604 return null;
14401605 }
14411606
1442
14431607 /**
14441608 * Get jar name from URL.
1445 *
1609 *
14461610 * @param url Get jar file name from this url
14471611 * @return file name as string
14481612 */
14511615
14521616 if (fileName.endsWith(".pack.lzma")) {
14531617 fileName = fileName.replaceAll(".pack.lzma", "");
1618 } else if (fileName.endsWith(".pack.gz")) {
1619 fileName = fileName.replaceAll(".pack.gz", "");
14541620 } else if (fileName.endsWith(".pack")) {
14551621 fileName = fileName.replaceAll(".pack", "");
14561622 } else if (fileName.endsWith(".lzma")) {
14571623 fileName = fileName.replaceAll(".lzma", "");
1624 } else if (fileName.endsWith(".gz")) {
1625 fileName = fileName.replaceAll(".gz", "");
14581626 }
14591627
14601628 return fileName.substring(fileName.lastIndexOf('/') + 1);
1461 }
1462
1629 }
1630
14631631 /**
14641632 * Get file name portion of URL.
1465 *
1633 *
14661634 * @param url Get file name from this url
14671635 * @return file name as string
14681636 */
14701638 String fileName = url.getFile();
14711639 return fileName.substring(fileName.lastIndexOf('/') + 1);
14721640 }
1473
1641
14741642 /**
14751643 * Retrieves the color
1476 *
1477 * @param color Color to load
1644 *
1645 * @param param Color to load
14781646 * @param defaultColor Default color to use if no color to load
14791647 * @return Color to use
14801648 */
14811649 protected Color getColor(String param, Color defaultColor) {
14821650 String color = getParameter(param);
1483
1651
14841652 if (color == null) return defaultColor;
1485
1653
14861654 // Check if RGB format
14871655 if (color.indexOf(",") != -1) {
14881656 StringTokenizer st = new StringTokenizer(color, ",");
1489
1657
14901658 // We've got three components for the color
14911659 try {
1492 return new Color(Integer.parseInt(st.nextToken().trim()),
1493 Integer.parseInt(st.nextToken().trim()),
1660 return new Color(Integer.parseInt(st.nextToken().trim()),
1661 Integer.parseInt(st.nextToken().trim()),
14941662 Integer.parseInt(st.nextToken().trim()));
14951663 } catch (Exception e) {
14961664 // failed to parse
14971665 return defaultColor;
14981666 }
14991667 }
1500
1668
15011669 // Check & decode if the color is in hexadecimal color format (i.e. #808000)
15021670 try {
15031671 return Color.decode(color);
15041672 } catch (NumberFormatException e) {
15051673 // ignore exception
15061674 }
1507
1675
15081676 // Get the color by name if it exists
15091677 try {
15101678 return (Color)Color.class.getField(color).get(null);
15121680 return defaultColor;
15131681 }
15141682 }
1515
1683
15161684 /**
15171685 * Retrieves the boolean value for the applet
15181686 * @param name Name of parameter
15261694 }
15271695 return defaultValue;
15281696 }
1529
1697
15301698 /**
15311699 * Sets the state of the loaded and prints some debug information
1532 *
1700 *
15331701 * @param error Error message to print
15341702 */
15351703 protected void fatalErrorOccured(String error, Exception e) {
15361704 fatalError = true;
1537 fatalErrorDescription = "This occurred while '" + getDescriptionForState() + "'";
1538 System.out.println(fatalErrorDescription);
1705 genericErrorMessage[genericErrorMessage.length-1] = error;
1706 System.out.println(error);
15391707 if(e != null) {
1708 System.out.println(e.getMessage());
15401709 System.out.println(generateStacktrace(e));
15411710 }
15421711 repaint();
1712 }
1713
1714 /**
1715 * set the state of applet loader
1716 * @param new state of applet loader
1717 * */
1718 protected void setState(int state) {
1719 this.state = state;
1720 if(debugMode) {
1721 System.out.println(getDescriptionForState());
1722 }
15431723 }
15441724
15451725 /**
15521732 sleep(ms);
15531733 }
15541734 }
1555
1735
15561736 /**
15571737 * Utility method for sleeping
15581738 * @param ms milliseconds to sleep
15631743 } catch (Exception e) {
15641744 /* ignored */
15651745 }
1566 }
1567
1746 }
15681747
15691748 }
4848 /** If true, an alternate Java->native call will be created. Useful when the alternate implementation uses different types. */
4949 boolean nativeAlt() default false;
5050
51 /** Applicable when nativeAlt is true. If true, no extra native call will be generated. Useful when there's another nativeAlt already defined. */
52 boolean skipNative() default false;
53
5154 /** If true, the alternate method's name will be used for the Java call. */
5255 boolean javaAlt() default false;
5356 }
3636 * according to the remaining() of a Buffer parameter.
3737 *
3838 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 3355 $
40 * $Id: AutoSize.java 3355 2010-05-27 22:56:29Z spasi $
39 * @version $Revision: 3412 $
40 * $Id: AutoSize.java 3412 2010-09-26 23:43:24Z spasi $
4141 */
4242
4343 import java.lang.annotation.Target;
4444 import java.lang.annotation.ElementType;
4545
4646 @Auto
47 @Target(ElementType.PARAMETER)
47 @Target({ElementType.METHOD,ElementType.PARAMETER})
4848 public @interface AutoSize {
4949 String value(); // The name of the Buffer parameter
5050 String expression() default ""; // This value is added after the argument
5151 boolean canBeNull() default false; // When this is true and the Buffer parameter is null, 0 will be used.
52 boolean isNative() default false; // When this is true, auto-sizing will be performed in native code.
5253 }
3333 /**
3434 *
3535 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2983 $
37 * $Id: Check.java 2983 2008-04-07 18:36:09Z matzon $
36 * @version $Revision: 3412 $
37 * $Id: Check.java 3412 2010-09-26 23:43:24Z spasi $
3838 */
3939
4040 import java.lang.annotation.Target;
4141 import java.lang.annotation.ElementType;
4242
43 @Target(ElementType.PARAMETER)
43 @Target({ElementType.PARAMETER, ElementType.METHOD})
4444 public @interface Check {
4545 String value() default "";
4646 boolean canBeNull() default false;
3333 /**
3434 *
3535 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2983 $
37 * $Id: Code.java 2983 2008-04-07 18:36:09Z matzon $
36 * @version $Revision: 3412 $
37 * $Id: Code.java 3412 2010-09-26 23:43:24Z spasi $
3838 */
3939
40 import java.lang.annotation.ElementType;
4041 import java.lang.annotation.Target;
41 import java.lang.annotation.ElementType;
4242
4343 @Target(ElementType.METHOD)
4444 public @interface Code {
45 String value();
45
46 String value() default ""; // Java, before everything
47
48 boolean tryBlock() default false; // Add a try/finally block around the native call and return statement
49
50 String javaBeforeNative() default ""; // Before the native call
51 String javaAfterNative() default ""; // After the native call
52 String javaFinally() default ""; // In the finally block
53
54 String nativeAfterVars() default ""; // After variable declaration
55 String nativeBeforeCall() default ""; // Before the API call
56 String nativeAfterCall() default ""; // After the API call
57
4658 }
3333 /**
3434 *
3535 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 3287 $
37 * $Id: Constant.java 3287 2010-03-14 23:24:40Z spasi $
36 * @version $Revision: 3412 $
37 * $Id: Constant.java 3412 2010-09-26 23:43:24Z spasi $
3838 */
3939
4040 import java.lang.annotation.Target;
4545 String value();
4646 /** If true, the original parameter will not be removed from the method. */
4747 boolean keepParam() default false;
48 /** If true, this is a native code constant. */
49 boolean isNative() default false;
4850 }
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 import java.lang.annotation.ElementType;
34 import java.lang.annotation.Target;
35
36 /**
37 * Functions marked with <code>@Extern</code> will not be declared as <code>static</code> in the C implementation.
38 * This allows other source files to call them.
39 *
40 * @author Spasi
41 */
42 @Target(ElementType.METHOD)
43 public @interface Extern {
44
45 }
3333 /**
3434 *
3535 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2983 $
37 * $Id: GenerateAutos.java 2983 2008-04-07 18:36:09Z matzon $
36 * @version $Revision: 3412 $
37 * $Id: GenerateAutos.java 3412 2010-09-26 23:43:24Z spasi $
3838 */
3939
4040 import java.lang.annotation.Target;
4242
4343 @Target(ElementType.METHOD)
4444 public @interface GenerateAutos {
45 /** If true, a size variable will be generated. */
46 String[] sizeVariables() default {};
4547 }
3131
3232 package org.lwjgl.util.generator;
3333
34 import com.sun.mirror.apt.*;
35 import com.sun.mirror.declaration.*;
36
3734 import java.io.File;
3835 import java.io.FileFilter;
36 import java.util.Arrays;
3937 import java.util.Collection;
38 import java.util.Map;
4039 import java.util.Set;
41 import java.util.Map;
42 import java.util.Arrays;
4340
41 import com.sun.mirror.apt.*;
42 import com.sun.mirror.declaration.AnnotationTypeDeclaration;
43 import com.sun.mirror.declaration.TypeDeclaration;
44
45 import static com.sun.mirror.util.DeclarationVisitors.*;
4446 import static java.util.Collections.*;
45 import static com.sun.mirror.util.DeclarationVisitors.*;
4647
4748 /**
48 *
4949 * Generator tool for creating the java classes and native code
5050 * from an annotated template java interface.
5151 *
5252 * @author elias_naur <elias_naur@users.sourceforge.net>
53 * @version $Revision: 3289 $
54 * $Id: GeneratorProcessorFactory.java 3289 2010-03-16 19:05:19Z spasi $
53 * @version $Revision: 3430 $
54 * $Id: GeneratorProcessorFactory.java 3430 2010-10-04 17:04:46Z spasi $
5555 */
5656 public class GeneratorProcessorFactory implements AnnotationProcessorFactory, RoundCompleteListener {
57
5758 private static boolean first_round = true;
5859
5960 // Process any set of annotations
7778
7879 public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds, AnnotationProcessorEnvironment env) {
7980 // Only process the initial types, not the generated ones
80 if (first_round) {
81 if ( first_round ) {
8182 env.addListener(this);
8283 return new GeneratorProcessor(env);
8384 } else
8586 }
8687
8788 private static class GeneratorProcessor implements AnnotationProcessor {
89
8890 private final AnnotationProcessorEnvironment env;
8991
9092 GeneratorProcessor(AnnotationProcessorEnvironment env) {
9698 String typemap_classname = null;
9799 boolean generate_error_checks = options.containsKey("-Ageneratechecks");
98100 boolean context_specific = options.containsKey("-Acontextspecific");
99 for (String k : options.keySet()) {
101 for ( String k : options.keySet() ) {
100102 int delimiter = k.indexOf('=');
101 if (delimiter != -1) {
102 if (k.startsWith("-Atypemap")) {
103 if ( delimiter != -1 ) {
104 if ( k.startsWith("-Atypemap") ) {
103105 typemap_classname = k.substring(delimiter + 1);
104106 }
105107 }
106108 }
107 if (typemap_classname == null)
109 if ( typemap_classname == null )
108110 throw new RuntimeException("No TypeMap class name specified with -Atypemap=<class-name>");
109111
110112 TypeDeclaration lastFile = null;
111113 try {
112114 long generatorLM = getGeneratorLastModified();
113115 TypeMap type_map = (TypeMap)(Class.forName(typemap_classname).newInstance());
114 for (TypeDeclaration typedecl : env.getSpecifiedTypeDeclarations()) {
116 for ( TypeDeclaration typedecl : env.getSpecifiedTypeDeclarations() ) {
115117 lastFile = typedecl;
116118 typedecl.accept(getDeclarationScanner(new GeneratorVisitor(env, type_map, generate_error_checks, context_specific, generatorLM), NO_OP));
117119 }
129131 * @return time of the latest change
130132 */
131133 private static long getGeneratorLastModified() {
132 final File pck = new File(System.getProperty("user.dir") + "/bin/org/lwjgl/util/generator");
134 long lastModified = getDirectoryLastModified("/bin/org/lwjgl/util/generator");
135 lastModified = Math.max(lastModified, getDirectoryLastModified("/bin/org/lwjgl/util/generator/openal"));
136 lastModified = Math.max(lastModified, getDirectoryLastModified("/bin/org/lwjgl/util/generator/opengl"));
137 lastModified = Math.max(lastModified, getDirectoryLastModified("/bin/org/lwjgl/util/generator/opencl"));
138
139 return lastModified;
140 }
141
142 private static long getDirectoryLastModified(final String path) {
143 final File pck = new File(System.getProperty("user.dir") + path);
133144 if ( !pck.exists() || !pck.isDirectory() )
134145 return Long.MAX_VALUE;
135146
3636 import com.sun.mirror.type.*;
3737 import com.sun.mirror.util.*;
3838
39 import java.io.*;
40 import java.lang.annotation.Annotation;
41 import java.nio.channels.FileChannel;
3942 import java.util.*;
4043
41 import java.io.PrintWriter;
42 import java.io.IOException;
43 import java.io.File;
44
4544 import java.nio.*;
4645
4746 /**
4948 * Generator visitor for the generator tool
5049 *
5150 * @author elias_naur <elias_naur@users.sourceforge.net>
52 * @version $Revision: 3355 $
53 * $Id: GeneratorVisitor.java 3355 2010-05-27 22:56:29Z spasi $
51 * @version $Revision: 3430 $
52 * $Id: GeneratorVisitor.java 3430 2010-10-04 17:04:46Z spasi $
5453 */
5554 public class GeneratorVisitor extends SimpleDeclarationVisitor {
5655 private final AnnotationProcessorEnvironment env;
6564 this.generate_error_checks = generate_error_checks;
6665 this.context_specific = context_specific;
6766 this.generatorLM = generatorLM;
68 }
69
70 private void validateMethods(InterfaceDeclaration d) {
71 for (MethodDeclaration method : d.getMethods())
72 validateMethod(method);
7367 }
7468
7569 private void validateMethod(MethodDeclaration method) {
9589 if (method.getAnnotation(CachedResult.class) != null) {
9690 if (Utils.getNIOBufferType(Utils.getMethodReturnType(method)) == null)
9791 throw new RuntimeException(method + " return type is not a Buffer, but is annotated with CachedResult");
98 if (method.getAnnotation(AutoResultSize.class) == null)
99 throw new RuntimeException(method + " is annotated with CachedResult but misses an AutoResultSize annotation");
92 if (method.getAnnotation(AutoSize.class) == null)
93 throw new RuntimeException(method + " is annotated with CachedResult but misses an AutoSize annotation");
10094 }
10195 validateTypes(method, method.getAnnotationMirrors(), method.getReturnType());
10296 }
10397
104 private void validateType(MethodDeclaration method, Class annotation_type, Class type) {
98 private void validateType(MethodDeclaration method, Class<?extends Annotation> annotation_type, Class type) {
10599 Class[] valid_types = type_map.getValidAnnotationTypes(type);
106 for (int i = 0; i < valid_types.length; i++)
107 if (valid_types[i].equals(annotation_type))
100 for ( Class valid_type : valid_types )
101 if ( valid_type.equals(annotation_type) )
108102 return;
109103 throw new RuntimeException(type + " is annotated with invalid native type " + annotation_type +
110104 " in method " + method);
114108 for (AnnotationMirror annotation : annotations) {
115109 NativeType native_type_annotation = NativeTypeTranslator.getAnnotation(annotation, NativeType.class);
116110 if (native_type_annotation != null) {
117 Class annotation_type = NativeTypeTranslator.getClassFromType(annotation.getAnnotationType());
111 Class<? extends Annotation> annotation_type = NativeTypeTranslator.getClassFromType(annotation.getAnnotationType());
118112 Class type = Utils.getJavaType(type_mirror);
119113 if (Buffer.class.equals(type))
120114 continue;
171165 }
172166
173167 private static void generateMethodNativePointers(PrintWriter writer, MethodDeclaration method) {
174 writer.println("static " + Utils.getTypedefName(method) + " " + method.getSimpleName() + ";");
168 if ( method.getAnnotation(Extern.class) == null )
169 writer.print("static ");
170 writer.println(Utils.getTypedefName(method) + " " + method.getSimpleName() + ";");
175171 }
176172
177173 private void generateJavaSource(InterfaceDeclaration d, PrintWriter java_writer) throws IOException {
181177 java_writer.println();
182178 java_writer.println("import org.lwjgl.*;");
183179 java_writer.println("import java.nio.*;");
180 Imports imports = d.getAnnotation(Imports.class);
181 if ( imports != null ) {
182 for ( String i : imports.value() )
183 java_writer.println("import " + i + ";");
184 }
184185 java_writer.println();
185186 Utils.printDocComment(java_writer, d);
186 java_writer.print("public ");
187 if ( d.getAnnotation(Private.class) == null )
188 java_writer.print("public ");
187189 boolean is_final = Utils.isFinal(d);
188190 if (is_final)
189191 java_writer.write("final ");
246248 }
247249
248250 public void visitInterfaceDeclaration(InterfaceDeclaration d) {
249 File input = d.getPosition().file();
250 File output = new File(env.getOptions().get("-s") + '/' + d.getPackage().getQualifiedName().replace('.', '/'), Utils.getSimpleClassName(d) + ".java");
251 final File input = d.getPosition().file();
252 final File outputJava = new File(env.getOptions().get("-s") + '/' + d.getPackage().getQualifiedName().replace('.', '/'), Utils.getSimpleClassName(d) + ".java");
251253
252254 PrintWriter java_writer = null;
253255
254256 try {
257 final Collection<? extends MethodDeclaration> methods = d.getMethods();
258 if ( methods.size() == 0 && d.getFields().size() == 0 )
259 return;
260
255261 // Skip this class if the output exists and the input has not been modified.
256 if ( output.exists() && Math.max(input.lastModified(), generatorLM) < output.lastModified() )
262 if ( outputJava.exists() && Math.max(input.lastModified(), generatorLM) < outputJava.lastModified() )
257263 return;
258264
259 if (d.getMethods().size() > 0 || d.getFields().size() > 0) {
260 validateMethods(d);
261 java_writer = env.getFiler().createTextFile(Filer.Location.SOURCE_TREE, d.getPackage().getQualifiedName(), new File(Utils.getSimpleClassName(d) + ".java"), null);
262 generateJavaSource(d, java_writer);
265 for ( final MethodDeclaration method : methods )
266 validateMethod(method);
267 java_writer = env.getFiler().createTextFile(Filer.Location.SOURCE_TREE, d.getPackage().getQualifiedName(), new File(Utils.getSimpleClassName(d) + ".java"), null);
268 generateJavaSource(d, java_writer);
269
270 if ( methods.size() > 0 ) {
271 boolean hasNative = false;
272 for ( final MethodDeclaration method : methods ) {
273 Alternate alt_annotation = method.getAnnotation(Alternate.class);
274 if ( (alt_annotation == null || alt_annotation.nativeAlt()) && method.getAnnotation(Reuse.class) == null ) {
275 hasNative = true;
276 break;
277 }
278 }
279 if ( !hasNative )
280 return;
281
282 final String outputPath = env.getOptions().get("-d") + '/' + Utils.getNativeQualifiedName(Utils.getQualifiedClassName(d));
283 final File outputNative = new File(outputPath + ".c");
284 final File outputBackup = new File(outputPath + "_backup.c");
285
286 // If the native file exists, rename.
287 final ByteBuffer nativeBefore;
288 if ( outputNative.exists() ) {
289 nativeBefore = readFile(outputNative);
290 outputNative.renameTo(outputBackup);
291 } else
292 nativeBefore = null;
293
294 try {
295 generateNativeSource(d);
296
297 // If the native file did exist, compare with the new file. If they're the same,
298 // reset the last modified time to avoid ridiculous C compilation times.
299 if ( nativeBefore != null && outputNative.length() == nativeBefore.capacity() ) {
300 final ByteBuffer nativeAfter = readFile(outputNative);
301 boolean same = true;
302 for ( int i = nativeBefore.position(); i < nativeBefore.limit(); i++ ) {
303 if ( nativeBefore.get(i) != nativeAfter.get(i) ) {
304 same = false;
305 break;
306 }
307 }
308
309 if ( same ) {
310 outputNative.delete();
311 outputBackup.renameTo(outputNative);
312 }
313 }
314 } finally {
315 if ( outputBackup.exists() )
316 outputBackup.delete();
317 }
263318 }
264 if (d.getMethods().size() > 0)
265 generateNativeSource(d);
266319 } catch (Exception e) {
267320 // If anything goes wrong mid-gen, delete output to allow regen next time we run.
268321 if ( java_writer != null ) java_writer.close();
269 if ( output.exists() ) output.delete();
322 if ( outputJava.exists() ) outputJava.delete();
270323
271324 throw new RuntimeException(e);
272325 }
273326 }
327
328 private static ByteBuffer readFile(final File file) throws IOException {
329 final FileChannel channel = new FileInputStream(file).getChannel();
330
331 final long bytesTotal = channel.size();
332 final ByteBuffer buffer = ByteBuffer.allocateDirect((int)bytesTotal);
333
334 long bytesRead = 0;
335 do {
336 bytesRead += channel.read(buffer);
337 } while ( bytesRead < bytesTotal );
338 buffer.flip();
339
340 channel.close();
341
342 return buffer;
343 }
344
274345 }
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 * Method parameters marked with <code>@Helper</code> will be considered Java-API
35 * parameters and will be ignored when generating native stubs/code.
36 *
37 * @author Spasi
38 */
39 import java.lang.annotation.ElementType;
40 import java.lang.annotation.Target;
41
42 @Target(ElementType.PARAMETER)
43 public @interface Helper {
44 boolean passToNative() default false;
45 }
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 import java.lang.annotation.ElementType;
34 import java.lang.annotation.Target;
35
36 /**
37 * This annotation can be used when an extension template needs
38 * extra imports in its generated class.
39 *
40 * @author Spasi
41 */
42 @Target(ElementType.TYPE)
43 public @interface Imports {
44 String[] value();
45 }
4040 * type strings.
4141 *
4242 * @author elias_naur <elias_naur@users.sourceforge.net>
43 * @version $Revision: 3281 $
44 * $Id: JNITypeTranslator.java 3281 2010-03-12 21:55:13Z spasi $
43 * @version $Revision: 3412 $
44 * $Id: JNITypeTranslator.java 3412 2010-09-26 23:43:24Z spasi $
4545 */
4646 public class JNITypeTranslator implements TypeVisitor {
4747 private final StringBuilder signature = new StringBuilder();
5555 }
5656
5757 public void visitArrayType(ArrayType t) {
58 if ( "java.lang.CharSequence".equals(t.getComponentType().toString()) )
58 final String className = t.getComponentType().toString();
59 if ( "java.lang.CharSequence".equals(className) )
5960 signature.append("jobject");
61 else if ( "java.nio.ByteBuffer".equals(className) )
62 signature.append("jobjectArray");
63 else if ( "org.lwjgl.opencl.CLMem".equals(className) )
64 signature.append("jobjectArray");
6065 else
6166 throw new RuntimeException(t + " is not allowed");
6267 }
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: 3355 $
40 * $Id: JavaMethodsGenerator.java 3355 2010-05-27 22:56:29Z spasi $
39 * @version $Revision: 3460 $
40 * $Id: JavaMethodsGenerator.java 3460 2010-11-29 18:25:28Z spasi $
4141 */
42
43 import org.lwjgl.PointerBuffer;
44 import org.lwjgl.util.generator.opengl.GLreturn;
4245
4346 import com.sun.mirror.apt.*;
4447 import com.sun.mirror.declaration.*;
4952 import java.nio.*;
5053
5154 public class JavaMethodsGenerator {
52 private final static String SAVED_PARAMETER_POSTFIX = "_saved";
55 private static final String SAVED_PARAMETER_POSTFIX = "_saved";
5356
5457 public static void generateMethodsJava(AnnotationProcessorEnvironment env, TypeMap type_map, PrintWriter writer, InterfaceDeclaration interface_decl, boolean generate_error_checks, boolean context_specific) {
5558 for (MethodDeclaration method : interface_decl.getMethods())
7073 if ( method.getAnnotation(CachedResult.class) != null && !method.getAnnotation(CachedResult.class).isRange() ) {
7174 printMethodWithMultiType(env, type_map, writer, interface_decl, method, TypeInfo.getDefaultTypeInfoMap(method), Mode.CACHEDRESULT, generate_error_checks, context_specific);
7275 }
76
77 Reuse reuse_annotation = method.getAnnotation(Reuse.class);
7378 Alternate alt_annotation = method.getAnnotation(Alternate.class);
74 if ( alt_annotation == null || alt_annotation.nativeAlt() ) {
79 if ( alt_annotation == null || (alt_annotation.nativeAlt() && !alt_annotation.skipNative()) ) {
7580 if ( alt_annotation != null && method.getSimpleName().equals(alt_annotation.value()) )
7681 throw new RuntimeException("An alternate function with native code should have a different name than the main function.");
77 printJavaNativeStub(writer, method, Mode.NORMAL, generate_error_checks, context_specific);
82
83 if ( reuse_annotation == null )
84 printJavaNativeStub(writer, method, Mode.NORMAL, generate_error_checks, context_specific);
85
7886 if (Utils.hasMethodBufferObjectParameter(method)) {
7987 printMethodWithMultiType(env, type_map, writer, interface_decl, method, TypeInfo.getDefaultTypeInfoMap(method), Mode.BUFFEROBJECT, generate_error_checks, context_specific);
80 printJavaNativeStub(writer, method, Mode.BUFFEROBJECT, generate_error_checks, context_specific);
88 if ( reuse_annotation == null )
89 printJavaNativeStub(writer, method, Mode.BUFFEROBJECT, generate_error_checks, context_specific);
8190 }
8291 }
8392 }
8493
8594 private static void printJavaNativeStub(PrintWriter writer, MethodDeclaration method, Mode mode, boolean generate_error_checks, boolean context_specific) {
8695 if (Utils.isMethodIndirect(generate_error_checks, context_specific, method)) {
87 writer.print("\tprivate static native ");
96 writer.print("\tstatic native ");
8897 } else {
8998 Utils.printDocComment(writer, method);
9099 writer.print("\tpublic static native ");
91100 }
92 printResultType(writer, method, true);
101 writer.print(getResultType(method, true));
93102 writer.print(" " + Utils.getSimpleNativeMethodName(method, generate_error_checks, context_specific));
94103 if (mode == Mode.BUFFEROBJECT)
95104 writer.print(Utils.BUFFER_OBJECT_METHOD_POSTFIX);
96105 writer.print("(");
97 boolean first_parameter = generateParametersJava(writer, method, TypeInfo.getDefaultTypeInfoMap(method), true, mode);
106 boolean first_parameter = generateParametersJava(writer, method, TypeInfo.getDefaultTypeInfoMap(method), true, true, mode);
98107 if (context_specific) {
99108 if (!first_parameter)
100109 writer.print(", ");
103112 writer.println(");");
104113 }
105114
106 private static boolean generateParametersJava(PrintWriter writer, MethodDeclaration method, Map<ParameterDeclaration, TypeInfo> typeinfos_instance,
107 boolean native_stub, Mode mode) {
115 private static boolean generateParametersJava(PrintWriter writer, MethodDeclaration method, Map<ParameterDeclaration, TypeInfo> typeinfos_instance, boolean native_stub, final boolean printTypes, Mode mode) {
108116 boolean first_parameter = true;
109117 for (ParameterDeclaration param : method.getParameters()) {
118 if ( native_stub && (param.getAnnotation(Helper.class) != null && !param.getAnnotation(Helper.class).passToNative()) )
119 continue;
120 final Constant constant_annotation = param.getAnnotation(Constant.class);
121 if ( constant_annotation != null && constant_annotation.isNative() )
122 continue;
110123 AnnotationMirror auto_annotation_mirror = Utils.getParameterAutoAnnotation(param);
111124 boolean hide_auto_parameter = mode == Mode.NORMAL && !native_stub && auto_annotation_mirror != null;
112125 if (hide_auto_parameter) {
118131 if (!first_parameter)
119132 writer.print(", ");
120133 first_parameter = false;
121 writer.print("boolean " + TypeInfo.UNSIGNED_PARAMETER_NAME);
134 if ( printTypes )
135 writer.print("boolean ");
136 writer.print(TypeInfo.UNSIGNED_PARAMETER_NAME);
122137 }
123138 }
124139 } else if (
125140 param.getAnnotation(Result.class) == null
126141 && (native_stub || ((param.getAnnotation(Constant.class) == null || param.getAnnotation(Constant.class).keepParam()) && !Utils.isReturnParameter(method, param)))
127 && (getAutoTypeParameter(method, param) == null || mode != Mode.AUTOS)
128 )
129 {
130 TypeInfo type_info = typeinfos_instance.get(param);
131 first_parameter = generateParameterJava(writer, param, type_info, native_stub, first_parameter, mode);
142 && (mode != Mode.AUTOS || getAutoTypeParameter(method, param) == null)
143 ) {
144 first_parameter = generateParameterJava(writer, param, typeinfos_instance.get(param), native_stub, printTypes, first_parameter, mode);
132145 }
133146 }
134147 CachedResult cached_result_annotation = method.getAnnotation(CachedResult.class);
135148 TypeMirror result_type = Utils.getMethodReturnType(method);
136149 if ((native_stub && Utils.getNIOBufferType(result_type) != null) || Utils.needResultSize(method)) {
137 if (cached_result_annotation == null || !cached_result_annotation.isRange()) {
138 if (!first_parameter)
139 writer.print(", ");
140 first_parameter = false;
141 writer.print("long " + Utils.RESULT_SIZE_NAME);
150 AutoSize auto_size_annotation = method.getAnnotation(AutoSize.class);
151 if ( auto_size_annotation == null || !auto_size_annotation.isNative() ) {
152 if (cached_result_annotation == null || !cached_result_annotation.isRange()) {
153 if (!first_parameter)
154 writer.print(", ");
155 first_parameter = false;
156 if ( printTypes )
157 writer.print("long ");
158 writer.print(Utils.RESULT_SIZE_NAME);
159 }
142160 }
143161 }
144162 if (cached_result_annotation != null) {
145163 if (!first_parameter)
146164 writer.print(", ");
147165
148 if ( mode == Mode.CACHEDRESULT )
149 writer.print("long " + Utils.CACHED_BUFFER_LENGTH_NAME + ", ");
166 if ( mode == Mode.CACHEDRESULT ) {
167 if ( printTypes )
168 writer.print("long ");
169 writer.print(Utils.CACHED_BUFFER_LENGTH_NAME + ", ");
170 }
150171
151172 first_parameter = false;
152 printResultType(writer, method, native_stub);
173 if ( printTypes )
174 writer.print(getResultType(method, native_stub));
153175 writer.print(" " + Utils.CACHED_BUFFER_NAME);
154176 }
155177 return first_parameter;
156178 }
157179
158 private static boolean generateParameterJava(PrintWriter writer, ParameterDeclaration param, TypeInfo type_info, boolean native_stub, boolean first_parameter, Mode mode) {
180 private static boolean generateParameterJava(PrintWriter writer, ParameterDeclaration param, TypeInfo type_info, boolean native_stub, final boolean printTypes, boolean first_parameter, Mode mode) {
159181 Class buffer_type = Utils.getNIOBufferType(param.getType());
160182 if (!first_parameter)
161183 writer.print(", ");
163185 if (bo_annotation != null && mode == Mode.BUFFEROBJECT) {
164186 if (buffer_type == null)
165187 throw new RuntimeException("type of " + param + " is not a nio Buffer parameter but is annotated as buffer object");
166 writer.print("long " + param.getSimpleName() + Utils.BUFFER_OBJECT_PARAMETER_POSTFIX);
188 if ( printTypes )
189 writer.print("long ");
190 writer.print(param.getSimpleName() + Utils.BUFFER_OBJECT_PARAMETER_POSTFIX);
167191 } else {
168 if ( native_stub && param.getAnnotation(GLpointer.class) != null )
169 writer.print("long");
192 if ( native_stub && param.getAnnotation(PointerWrapper.class) != null )
193 writer.print("long ");
170194 else {
171195 Class type = type_info.getType();
172 if ( native_stub && (type == CharSequence.class || type == CharSequence[].class) )
173 writer.print("ByteBuffer");
174 else
175 writer.print(type_info.getType().getSimpleName());
176 }
177 writer.print(" " + param.getSimpleName());
196 if ( native_stub && (type == CharSequence.class || type == CharSequence[].class || type == PointerBuffer.class) )
197 writer.print("ByteBuffer ");
198 else if ( printTypes )
199 writer.print(type_info.getType().getSimpleName() + " ");
200 }
201 AutoSize auto_size_annotation = param.getAnnotation(AutoSize.class);
202 if ( auto_size_annotation != null )
203 writer.print(auto_size_annotation.value() + "_");
204 writer.print(param.getSimpleName());
178205 if ( native_stub && buffer_type != null )
179206 writer.print(", int " + param.getSimpleName() + NativeMethodStubsGenerator.BUFFER_POSITION_POSTFIX);
180207 }
204231
205232 private static void printMethodWithMultiType(AnnotationProcessorEnvironment env, TypeMap type_map, PrintWriter writer, InterfaceDeclaration interface_decl, MethodDeclaration method, Map<ParameterDeclaration, TypeInfo> typeinfos_instance, Mode mode, boolean generate_error_checks, boolean context_specific) {
206233 Utils.printDocComment(writer, method);
207 writer.print("\tpublic static ");
208 printResultType(writer, method, false);
234 if ( interface_decl.getAnnotation(Private.class) == null && method.getAnnotation(Private.class) == null )
235 writer.print("\tpublic static ");
236 else
237 writer.print("\tstatic ");
238 writer.print(getResultType(method, false));
209239 StripPostfix strip_annotation = method.getAnnotation(StripPostfix.class);
210240 String method_name;
211241 Alternate alt_annotation = method.getAnnotation(Alternate.class);
213243 if (strip_annotation != null && mode == Mode.NORMAL)
214244 method_name = getPostfixStrippedName(type_map, interface_decl, method);
215245 writer.print(" " + method_name + "(");
216 generateParametersJava(writer, method, typeinfos_instance, false, mode);
217 TypeMirror result_type = Utils.getMethodReturnType(method);
246 generateParametersJava(writer, method, typeinfos_instance, false, true, mode);
218247 writer.println(") {");
248
249 final TypeMirror result_type = Utils.getMethodReturnType(method);
250 boolean has_result = !result_type.equals(env.getTypeUtils().getVoidType());
251
252 final Reuse reuse_annotation = method.getAnnotation(Reuse.class);
253 if ( reuse_annotation != null ) {
254 writer.print("\t\t");
255 if ( has_result || method.getAnnotation(GLreturn.class) != null )
256 writer.print("return ");
257
258 writer.print(reuse_annotation.value() + "." + method_name + "(");
259 generateParametersJava(writer, method, typeinfos_instance, false, false, mode);
260 writer.println(");\n\t}");
261 return;
262 }
263
219264 if (context_specific) {
220 writer.println("\t\tContextCapabilities caps = GLContext.getCapabilities();");
221 writer.print("\t\tlong " + Utils.FUNCTION_POINTER_VAR_NAME + " = caps.");
265 type_map.printCapabilitiesInit(writer);
266 writer.print("\t\tlong " + Utils.FUNCTION_POINTER_VAR_NAME + " = " + type_map.getCapabilities() + ".");
222267 writer.println(Utils.getFunctionAddressName(interface_decl, method, true) + ";");
223268 writer.print("\t\tBufferChecks.checkFunctionAddress(");
224269 writer.println(Utils.FUNCTION_POINTER_VAR_NAME + ");");
225270 }
226 Code code_annotation = method.getAnnotation(Code.class);
227 if (code_annotation != null)
271 final Code code_annotation = method.getAnnotation(Code.class);
272 if (code_annotation != null && code_annotation.value().length() > 0)
228273 writer.println(code_annotation.value());
229274 printBufferObjectChecks(writer, method, mode);
230 printParameterChecks(writer, method, typeinfos_instance, mode);
275 printParameterChecks(writer, method, typeinfos_instance, mode, generate_error_checks);
231276 printParameterCaching(writer, interface_decl, method, mode);
277
278 if ( code_annotation != null && code_annotation.javaBeforeNative().length() > 0 )
279 writer.println(code_annotation.javaBeforeNative());
232280 writer.print("\t\t");
233 boolean has_result = !result_type.equals(env.getTypeUtils().getVoidType());
281
282 final PointerWrapper pointer_wrapper_annotation = method.getAnnotation(PointerWrapper.class);
234283 if (has_result) {
235 printResultType(writer, method, false);
236 writer.print(" " + Utils.RESULT_VAR_NAME + " = ");
237
238 if ( method.getAnnotation(GLpointer.class) != null )
239 writer.print("new " + method.getReturnType() + "(");
240 }
241 if ( method.getAnnotation(GLreturn.class) != null ) {
284 writer.print(getResultType(method, false) + " " + Utils.RESULT_VAR_NAME);
285
286 if ( code_annotation != null && code_annotation.tryBlock() ) {
287 writer.print(" = " + getDefaultResultValue(method));
288 writer.println(";\n\t\ttry {");
289 writer.print("\t\t\t" + Utils.RESULT_VAR_NAME);
290 }
291
292 writer.print(" = ");
293 if ( pointer_wrapper_annotation != null ) {
294 if ( pointer_wrapper_annotation.factory().length() > 0 )
295 writer.print(pointer_wrapper_annotation.factory() + "(");
296 else
297 writer.print("new " + getResultType(method, false) + "(");
298 }
299 } else if ( method.getAnnotation(GLreturn.class) != null ) {
242300 has_result = true;
243301 Utils.printGLReturnPre(writer, method, method.getAnnotation(GLreturn.class));
244302 }
252310 writer.print(", ");
253311 writer.print(Utils.FUNCTION_POINTER_VAR_NAME);
254312 }
255 if ( has_result && method.getAnnotation(GLpointer.class) != null )
313 if ( has_result && pointer_wrapper_annotation != null ) {
256314 writer.print(")");
315 if ( pointer_wrapper_annotation.params().length() > 0 )
316 writer.print(", " + pointer_wrapper_annotation.params());
317 }
257318 writer.println(");");
319
320 if ( code_annotation != null && code_annotation.javaAfterNative().length() > 0 )
321 writer.println(code_annotation.javaAfterNative());
322
323 final String tabs = code_annotation != null && code_annotation.tryBlock() ? "\t\t\t" : "\t\t";
258324 if (generate_error_checks && method.getAnnotation(NoErrorCheck.class) == null)
259 writer.println("\t\t" + type_map.getErrorCheckMethodName() + ";");
325 type_map.printErrorCheckMethod(writer, method, tabs);
260326 // DISABLED: indirect buffer support
261327 //printNondirectParameterCopies(writer, method, mode);
262328 if (has_result) {
263329 if ( method.getAnnotation(GLreturn.class) == null ) {
264330 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.
331 writer.println(tabs + "return LWJGLUtil.CHECKS && " + Utils.RESULT_VAR_NAME + " == null ? null : " + Utils.RESULT_VAR_NAME + ".order(ByteOrder.nativeOrder());"); // safeNewBuffer returns a direct ByteBuffer with BIG_ENDIAN order.
266332 else
267 writer.println("\t\treturn " + Utils.RESULT_VAR_NAME + ";");
333 writer.println(tabs + "return " + Utils.RESULT_VAR_NAME + ";");
268334 } else
269335 Utils.printGLReturnPost(writer, method, method.getAnnotation(GLreturn.class));
336 }
337
338 if ( code_annotation != null && code_annotation.tryBlock() ) {
339 writer.println("\t\t} finally {");
340 writer.println(code_annotation.javaFinally());
341 writer.println("\t\t}");
270342 }
271343 writer.println("\t}");
272344 }
295367 else if (annotation_type.equals(AutoSize.class))
296368 parameter_name = param.getAnnotation(AutoSize.class).value();
297369 else
298 throw new RuntimeException("Unkown annotation type " + annotation_type);
370 throw new RuntimeException("Unknown annotation type " + annotation_type);
299371 if (target_parameter.getSimpleName().equals(parameter_name))
300372 return param;
301373 }
367439 private static boolean printMethodCallArgument(PrintWriter writer, MethodDeclaration method, ParameterDeclaration param, Map<ParameterDeclaration, TypeInfo> typeinfos_instance, Mode mode, boolean first_parameter) {
368440 if (!first_parameter)
369441 writer.print(", ");
442
370443 AnnotationMirror auto_annotation = Utils.getParameterAutoAnnotation(param);
371444 Constant constant_annotation = param.getAnnotation(Constant.class);
372445 if (constant_annotation != null) {
374447 } else if (auto_annotation != null && mode == Mode.NORMAL) {
375448 Class param_type = NativeTypeTranslator.getClassFromType(auto_annotation.getAnnotationType());
376449 if (AutoType.class.equals(param_type)) {
377 AutoType auto_type_annotation = param.getAnnotation(AutoType.class);
378 String auto_parameter_name = auto_type_annotation.value();
379 ParameterDeclaration auto_parameter = Utils.findParameter(method, auto_parameter_name);
380 String auto_type = typeinfos_instance.get(auto_parameter).getAutoType();
381 if (auto_type == null)
450 final AutoType auto_type_annotation = param.getAnnotation(AutoType.class);
451 final ParameterDeclaration auto_parameter = Utils.findParameter(method, auto_type_annotation.value());
452 final String auto_type = typeinfos_instance.get(auto_parameter).getAutoType();
453 if ( auto_type == null )
382454 throw new RuntimeException("No auto type for parameter " + param.getSimpleName() + " in method " + method);
383455 writer.print(auto_type);
384456 } else if (AutoSize.class.equals(param_type)) {
385 AutoSize auto_type_annotation = param.getAnnotation(AutoSize.class);
386 String auto_parameter_name = auto_type_annotation.value();
387 ParameterDeclaration auto_target_param = Utils.findParameter(method, auto_parameter_name);
388 TypeInfo auto_target_type_info = typeinfos_instance.get(auto_target_param);
389 if ( auto_type_annotation.canBeNull() )
390 writer.print("((" + auto_parameter_name + " == null ? 0 : " + auto_parameter_name + ".remaining())");
457 final AutoSize auto_size_annotation = param.getAnnotation(AutoSize.class);
458 final String auto_parameter_name = auto_size_annotation.value();
459 final ParameterDeclaration auto_target_param = Utils.findParameter(method, auto_parameter_name);
460 final TypeInfo auto_target_type_info = typeinfos_instance.get(auto_target_param);
461 final boolean shift_remaining = !hasAnyParameterAutoTypeAnnotation(method, auto_target_param) && Utils.isParameterMultiTyped(auto_target_param);
462 int shifting = 0;
463 if ( shift_remaining ) {
464 shifting = getBufferElementSizeExponent(auto_target_type_info.getType());
465 if ( shifting > 0 )
466 writer.print("(");
467 }
468 if ( auto_size_annotation.canBeNull() )
469 writer.print("(" + auto_parameter_name + " == null ? 0 : " + auto_parameter_name + ".remaining())");
391470 else
392 writer.print("(" + auto_parameter_name + ".remaining()");
471 writer.print(auto_parameter_name + ".remaining()");
393472 // Shift the remaining if the target parameter is multityped and there's no AutoType to track type
394 boolean shift_remaining = !hasAnyParameterAutoTypeAnnotation(method, auto_target_param) && Utils.isParameterMultiTyped(auto_target_param);
395 if (shift_remaining) {
396 int shifting = getBufferElementSizeExponent(auto_target_type_info.getType());
397 if (shifting > 0)
398 writer.print(" << " + shifting);
399 }
400 writer.print(")");
401 writer.print(auto_type_annotation.expression());
473 if (shift_remaining && shifting > 0) {
474 writer.print(" << " + shifting);
475 writer.print(")");
476 }
477 writer.print(auto_size_annotation.expression());
402478 } else
403479 throw new RuntimeException("Unknown auto annotation " + param_type);
404480 } else {
406482 writer.print(param.getSimpleName() + Utils.BUFFER_OBJECT_PARAMETER_POSTFIX);
407483 } else {
408484 Class type = typeinfos_instance.get(param).getType();
485 Check check_annotation = param.getAnnotation(Check.class);
409486 boolean hide_buffer = mode == Mode.AUTOS && getAutoTypeParameter(method, param) != null;
410 if (hide_buffer)
487 if (hide_buffer) {
411488 writer.print("null");
412 else {
489 } else {
413490 if ( type == CharSequence.class || type == CharSequence[].class ) {
414491 final String offset = Utils.getStringOffset(method, param);
415492
416 writer.print("APIUtils.getBuffer");
493 writer.print("APIUtil.getBuffer");
417494 if ( param.getAnnotation(NullTerminated.class) != null )
418495 writer.print("NT");
419496 writer.print("(" + param.getSimpleName());
421498 writer.print(", " + offset);
422499 writer.print(")");
423500 hide_buffer = true;
424 } else
501 } else {
502 final AutoSize auto_size_annotation = param.getAnnotation(AutoSize.class);
503 if ( auto_size_annotation != null )
504 writer.print(auto_size_annotation.value() + "_");
425505 writer.print(param.getSimpleName());
506 if ( PointerBuffer.class.isAssignableFrom(type) ) {
507 if ( check_annotation != null && check_annotation.canBeNull() )
508 writer.print(" != null ? " + param.getSimpleName());
509 writer.print(".getBuffer()");
510 if ( check_annotation != null && check_annotation.canBeNull() )
511 writer.print(" : null");
512 }
513 }
426514 }
427515 Class buffer_type = Utils.getNIOBufferType(param.getType());
428516 if (buffer_type != null) {
429517 writer.print(", ");
430518 if (!hide_buffer) {
431 TypeInfo type_info = typeinfos_instance.get(param);
432 Check check_annotation = param.getAnnotation(Check.class);
433519 int shifting;
434 if (Utils.getNIOBufferType(param.getType()).equals(Buffer.class))
435 shifting = getBufferElementSizeExponent(type_info.getType());
436 else
520 if (Utils.getNIOBufferType(param.getType()).equals(Buffer.class)) {
521 shifting = getBufferElementSizeExponent(type == Buffer.class ? ByteBuffer.class : type); // TODO: This will always throw an exception
522 //shifting = 0;
523 } else
437524 shifting = 0;
438525 writer.print(param.getSimpleName());
439526 if (check_annotation != null && check_annotation.canBeNull())
440527 writer.print(" != null ? " + param.getSimpleName());
441 writer.print(".position()");
528 if ( type == PointerBuffer.class )
529 writer.print(".positionByte()");
530 else
531 writer.print(".position()");
442532 if (shifting > 0)
443533 writer.print(" << " + shifting);
444534 if (check_annotation != null && check_annotation.canBeNull())
448538 writer.print(offset == null ? "0" : offset);
449539 } else
450540 writer.print("0");
451 } else {
452 GLpointer pointer_annotation = param.getAnnotation(GLpointer.class);
541 } else if ( type != long.class ) {
542 PointerWrapper pointer_annotation = param.getAnnotation(PointerWrapper.class);
453543 if ( pointer_annotation != null ) {
454544 if ( pointer_annotation.canBeNull() )
455545 writer.print(" == null ? 0 : " + param.getSimpleName());
463553
464554 private static boolean printMethodCallArguments(PrintWriter writer, MethodDeclaration method, Map<ParameterDeclaration, TypeInfo> typeinfos_instance, Mode mode) {
465555 boolean first_parameter = true;
466 for (ParameterDeclaration param : method.getParameters())
467 if (param.getAnnotation(Result.class) == null) {
556 for ( ParameterDeclaration param : method.getParameters() ) {
557 if ( param.getAnnotation(Result.class) != null || (param.getAnnotation(Helper.class) != null && !param.getAnnotation(Helper.class).passToNative()) )
558 continue;
559
560 final Constant constant_annotation = param.getAnnotation(Constant.class);
561 if ( constant_annotation== null || !constant_annotation.isNative() )
468562 first_parameter = printMethodCallArgument(writer, method, param, typeinfos_instance, mode, first_parameter);
469 }
563 }
470564 if (Utils.getNIOBufferType(Utils.getMethodReturnType(method)) != null) {
471565 if (method.getAnnotation(CachedResult.class) != null && method.getAnnotation(CachedResult.class).isRange()) {
472566 first_parameter = false;
473567 Utils.printExtraCallArguments(writer, method, "");
474568 } else {
475 if (!first_parameter)
476 writer.print(", ");
477 first_parameter = false;
478
479 String result_size_expression;
480 if ( mode == Mode.CACHEDRESULT )
481 result_size_expression = Utils.CACHED_BUFFER_LENGTH_NAME;
482 else {
483 AutoResultSize auto_result_size_annotation = method.getAnnotation(AutoResultSize.class);
484 if (auto_result_size_annotation == null)
569 AutoSize auto_size_annotation = method.getAnnotation(AutoSize.class);
570 if ( auto_size_annotation == null || !auto_size_annotation.isNative() ) {
571 if (!first_parameter)
572 writer.print(", ");
573 first_parameter = false;
574
575 String result_size_expression;
576 if ( mode == Mode.CACHEDRESULT )
577 result_size_expression = Utils.CACHED_BUFFER_LENGTH_NAME;
578 else if ( auto_size_annotation == null )
485579 result_size_expression = Utils.RESULT_SIZE_NAME;
486580 else
487 result_size_expression = auto_result_size_annotation.value();
488 }
489 Utils.printExtraCallArguments(writer, method, result_size_expression);
581 result_size_expression = auto_size_annotation.value();
582
583 Utils.printExtraCallArguments(writer, method, result_size_expression);
584 }
490585 }
491586 }
492587 return first_parameter;
500595 cachedReference != null &&
501596 (mode != Mode.BUFFEROBJECT || param.getAnnotation(BufferObject.class) == null) &&
502597 param.getAnnotation(Result.class) == null) {
503 writer.print("\t\tif ( LWJGLUtil.CHECKS ) " + Utils.CHECKS_CLASS_NAME + ".getReferences(caps).");
598 writer.print("\t\tif ( LWJGLUtil.CHECKS ) " + "StateTracker.getReferences(caps).");
504599 if(cachedReference.name().length() > 0) {
505600 writer.print(cachedReference.name());
506601 } else {
530625 }
531626 }
532627
533 private static void printParameterChecks(PrintWriter writer, MethodDeclaration method, Map<ParameterDeclaration, TypeInfo> typeinfos, Mode mode) {
628 private static void printParameterChecks(PrintWriter writer, MethodDeclaration method, Map<ParameterDeclaration, TypeInfo> typeinfos, Mode mode, final boolean generate_error_checks) {
629 if ( mode == Mode.NORMAL ) {
630 final GenerateAutos gen_autos_annotation = method.getAnnotation(GenerateAutos.class);
631 if ( gen_autos_annotation != null && gen_autos_annotation.sizeVariables().length > 0 ) {
632 // For the auto-generated parameters, declare and init a size variable (that can be reused by @Code)
633 for ( final ParameterDeclaration param : method.getParameters() ) {
634 if ( Arrays.binarySearch(gen_autos_annotation.sizeVariables(), param.getSimpleName()) >= 0 ) {
635 final int shifting = getBufferElementSizeExponent(typeinfos.get(param).getType());
636 final Check check_annotation = param.getAnnotation(Check.class);
637
638 writer.print("\t\tlong " + param.getSimpleName() + "_size = ");
639 if ( check_annotation == null || !check_annotation.canBeNull() )
640 writer.println(param.getSimpleName() + ".remaining() << " + shifting + ";");
641 else
642 writer.println(param.getSimpleName() + " == null ? 0 : " + param.getSimpleName() + ".remaining() << " + shifting + ";");
643 }
644 }
645 }
646 }
647
534648 for (ParameterDeclaration param : method.getParameters()) {
535649 Class java_type = Utils.getJavaType(param.getType());
536 if (Utils.isAddressableType(java_type) &&
650 if ( java_type.isArray() || (Utils.isAddressableType(java_type) &&
537651 (mode != Mode.BUFFEROBJECT || param.getAnnotation(BufferObject.class) == null) &&
538652 (mode != Mode.AUTOS || getAutoTypeParameter(method, param) == null) &&
539653 param.getAnnotation(Result.class) == null &&
540 !Utils.isReturnParameter(method, param) ) {
654 !Utils.isReturnParameter(method, param)) ) {
541655 String check_value = null;
542656 boolean can_be_null = false;
543657 Check check_annotation = param.getAnnotation(Check.class);
545659 check_value = check_annotation.value();
546660 can_be_null = check_annotation.canBeNull();
547661 }
548 NullTerminated null_terminated = param.getAnnotation(NullTerminated.class);
549 if (Buffer.class.isAssignableFrom(java_type) && param.getAnnotation(Constant.class) == null) {
662 if ((Buffer.class.isAssignableFrom(java_type) || PointerBuffer.class.isAssignableFrom(java_type)) && param.getAnnotation(Constant.class) == null) {
550663 boolean indirect_buffer_allowed = false && param.getAnnotation(CachedReference.class) == null; // DISABLED: indirect buffer support
551664 boolean out_parameter = param.getAnnotation(OutParameter.class) != null;
552665 TypeInfo typeinfo = typeinfos.get(param);
553 printParameterCheck(writer, param.getSimpleName(), typeinfo.getType().getSimpleName(), check_value, can_be_null, null_terminated, indirect_buffer_allowed, out_parameter);
666 printParameterCheck(writer, method, param.getSimpleName(), typeinfo.getType().getSimpleName(), check_value, can_be_null, param.getAnnotation(NullTerminated.class), indirect_buffer_allowed, out_parameter, generate_error_checks);
554667 } else if ( String.class.equals(java_type)) {
555668 if (!can_be_null)
556669 writer.println("\t\tBufferChecks.checkNotNull(" + param.getSimpleName() + ");");
670 } else if ( java_type.isArray() ) {
671 final TypeInfo typeinfo = typeinfos.get(param);
672 printArrayParameterCheck(writer, param.getSimpleName(), typeinfo.getType().getSimpleName(), check_value, can_be_null);
557673 }
558674 }
559675 }
560676 if (method.getAnnotation(CachedResult.class) != null)
561 printParameterCheck(writer, Utils.CACHED_BUFFER_NAME, null, null, true, null, false, false);
562 }
563
564 private static void printParameterCheck(PrintWriter writer, String name, String type, String check_value, boolean can_be_null, NullTerminated null_terminated, boolean indirect_buffer_allowed, boolean out_parameter) {
677 printParameterCheck(writer, method, Utils.CACHED_BUFFER_NAME, null, null, true, null, false, false, generate_error_checks);
678 }
679
680 private static void printParameterCheck(PrintWriter writer, MethodDeclaration method, String name, String type, String check_value, boolean can_be_null, NullTerminated null_terminated, boolean indirect_buffer_allowed, boolean out_parameter, final boolean generate_error_checks) {
565681 if (indirect_buffer_allowed && out_parameter) {
566682 writer.println("\t\t" + type + " " + name + SAVED_PARAMETER_POSTFIX + " = " + name + ";");
567683 }
684 String tabs;
568685 if (can_be_null) {
569 writer.println("\t\tif (" + name + " != null)");
570 writer.print("\t");
571 }
686 writer.print("\t\tif (" + name + " != null)");
687 if ( null_terminated != null )
688 writer.println(" {");
689 else
690 writer.println();
691 tabs = "\t\t\t";
692 } else
693 tabs = "\t\t";
572694 if (indirect_buffer_allowed) {
573 writer.print("\t\t" + name + " = NondirectBufferWrapper.wrap");
695 writer.print(tabs + name + " = NondirectBufferWrapper.wrap");
574696 if (out_parameter)
575697 writer.print("NoCopy");
576698 } else
577 writer.print("\t\tBufferChecks.check");
578 if (check_value != null && !"".equals(check_value) ) {
579 writer.print("Buffer(" + name + ", " + check_value);
699 writer.print(tabs + "BufferChecks.check");
700 if (check_value != null && check_value.length() > 0) {
701 writer.print("Buffer");
702 if ( "Buffer".equals(type) )
703 writer.print("Size"); // Check size only, Buffer.isDirect() was added in 1.6, cannot use yet. TODO: Remove?
704 writer.print("(" + name + ", " + check_value);
580705 } else {
581706 writer.print("Direct(" + name);
582707 }
583708 writer.println(");");
709 if ( can_be_null && generate_error_checks ) {
710 final Check check_annotation = method.getAnnotation(Check.class);
711 if ( check_annotation != null && check_annotation.value().equals(name) ) {
712 writer.println("\t\telse");
713 writer.println("\t\t\t" + name + " = APIUtil.getBufferIntDebug();"); // Use an exclusive buffer here
714 }
715 }
584716 if (null_terminated != null) {
585 writer.print("\t\tBufferChecks.checkNullTerminated(");
717 writer.print(tabs + "BufferChecks.checkNullTerminated(");
586718 writer.print(name);
587719 if ( null_terminated.value().length() > 0 ) {
588720 writer.print(", ");
589721 writer.print(null_terminated.value());
590722 }
591723 writer.println(");");
592 }
593 }
594
595 private static void printResultType(PrintWriter writer, MethodDeclaration method, boolean native_stub) {
596 if ( native_stub && method.getAnnotation(GLpointer.class) != null )
597 writer.print("long");
724 if ( can_be_null )
725 writer.println("\t\t}");
726 }
727 }
728
729 private static void printArrayParameterCheck(PrintWriter writer, String name, String type, String check_value, boolean can_be_null) {
730 String tabs;
731 if ( can_be_null ) {
732 writer.println("\t\tif (" + name + " != null)");
733 tabs = "\t\t\t";
734 } else
735 tabs = "\t\t";
736
737 writer.print(tabs + "BufferChecks.checkArray(" + name);
738 if ( check_value != null && check_value.length() > 0)
739 writer.print(", " + check_value);
740 writer.println(");");
741 }
742
743 private static String getResultType(MethodDeclaration method, boolean native_stub) {
744 if ( native_stub && method.getAnnotation(PointerWrapper.class) != null )
745 return "long";
598746 else if ( !native_stub && method.getAnnotation(GLreturn.class) != null )
599 writer.print(Utils.getMethodReturnType(method, method.getAnnotation(GLreturn.class), false));
747 return Utils.getMethodReturnType(method, method.getAnnotation(GLreturn.class), false);
600748 else
601 writer.print(Utils.getMethodReturnType(method).toString());
602 }
749 return Utils.getJavaType(Utils.getMethodReturnType(method)).getSimpleName();
750 }
751
752 private static String getDefaultResultValue(MethodDeclaration method) {
753 if ( method.getAnnotation(GLreturn.class) != null ) {
754 final String type = Utils.getMethodReturnType(method, method.getAnnotation(GLreturn.class), false);
755 if ( "boolean".equals(type) )
756 return "false";
757 else if ( Character.isLowerCase(type.charAt(0)) )
758 return "0";
759 else
760 return "null";
761 } else {
762 final Class type = Utils.getJavaType(Utils.getMethodReturnType(method));
763 if ( type.isPrimitive() ) {
764 if ( type == boolean.class )
765 return "false";
766 else
767 return "0";
768 } else
769 return "null";
770 }
771 }
772
603773 }
3131
3232 package org.lwjgl.util.generator;
3333
34 import org.lwjgl.opencl.CLMem;
35
36 import java.nio.ByteBuffer;
37
3438 import com.sun.mirror.type.*;
3539 import com.sun.mirror.util.*;
3640
3741 /**
38 *
3942 * A TypeVisitor that translates (annotated) TypeMirrors to
4043 * java types (represented by a Class)
4144 *
4245 * @author elias_naur <elias_naur@users.sourceforge.net>
43 * @version $Revision: 3287 $
44 * $Id: JavaTypeTranslator.java 3287 2010-03-14 23:24:40Z spasi $
46 * @version $Revision: 3430 $
47 * $Id: JavaTypeTranslator.java 3430 2010-10-04 17:04:46Z spasi $
4548 */
4649 public class JavaTypeTranslator implements TypeVisitor {
4750 private Class type;
5558 }
5659
5760 public void visitArrayType(ArrayType t) {
58 if ( "java.lang.CharSequence".equals(t.getComponentType().toString()) )
59 type = CharSequence[].class;
60 else
61 throw new RuntimeException(t + " is not allowed");
61 final TypeMirror componentType = t.getComponentType();
62 if ( componentType instanceof PrimitiveType ) {
63 type = getPrimitiveArrayClassFromKind(((PrimitiveType)componentType).getKind());
64 } else {
65 try {
66 final Class c = Class.forName(t.getComponentType().toString());
67 if ( CharSequence.class.isAssignableFrom(c) || ByteBuffer.class.isAssignableFrom(c) || org.lwjgl.PointerWrapper.class.isAssignableFrom(c) )
68 type = Class.forName("[L" + t.getComponentType() + ";");
69 else {
70 throw new RuntimeException(t + " is not allowed");
71 }
72 } catch (ClassNotFoundException e) {
73 throw new RuntimeException(e);
74 }
75 }
6276 }
6377
6478 public static Class getPrimitiveClassFromKind(PrimitiveType.Kind kind) {
7791 return byte.class;
7892 case BOOLEAN:
7993 return boolean.class;
94 default:
95 throw new RuntimeException(kind + " is not allowed");
96 }
97 }
98
99 private static Class getPrimitiveArrayClassFromKind(PrimitiveType.Kind kind) {
100 switch ( kind ) {
101 case LONG:
102 return long[].class;
103 case INT:
104 return int[].class;
105 case DOUBLE:
106 return double[].class;
107 case FLOAT:
108 return float[].class;
109 case SHORT:
110 return short[].class;
111 case BYTE:
112 return byte[].class;
113 case BOOLEAN:
114 return boolean[].class;
80115 default:
81116 throw new RuntimeException(kind + " is not allowed");
82117 }
3636 * This class generates the functions in the native source files.
3737 *
3838 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 3289 $
40 * $Id: NativeMethodStubsGenerator.java 3289 2010-03-16 19:05:19Z spasi $
39 * @version $Revision: 3418 $
40 * $Id: NativeMethodStubsGenerator.java 3418 2010-09-28 21:11:35Z spasi $
4141 */
42
43 import org.lwjgl.PointerBuffer;
4244
4345 import com.sun.mirror.apt.*;
4446 import com.sun.mirror.declaration.*;
5153 public class NativeMethodStubsGenerator {
5254 private static final String BUFFER_ADDRESS_POSTFIX = "_address";
5355 public static final String BUFFER_POSITION_POSTFIX = "_position";
54 private static final String STRING_LIST_POSTFIX = "_str";
56 private static final String STRING_LIST_NAME = "_str";
57 private static final String POINTER_LIST_NAME = "_ptr";
5558
5659 public static void generateNativeMethodStubs(AnnotationProcessorEnvironment env, TypeMap type_map, PrintWriter writer, InterfaceDeclaration d, boolean generate_error_checks, boolean context_specific) {
5760 for (MethodDeclaration method : d.getMethods()) {
5861 Alternate alt_annotation = method.getAnnotation(Alternate.class);
59 if ( alt_annotation != null && !alt_annotation.nativeAlt() )
62 if ( (alt_annotation != null && (!alt_annotation.nativeAlt() || alt_annotation.skipNative())) || method.getAnnotation(Reuse.class) != null )
6063 continue;
6164 generateMethodStub(env, type_map, writer, Utils.getQualifiedClassName(d), method, Mode.NORMAL, generate_error_checks, context_specific);
6265 if (Utils.hasMethodBufferObjectParameter(method))
6568 }
6669
6770 private static void generateParameters(PrintWriter writer, Collection<ParameterDeclaration> params, Mode mode) {
68 for (ParameterDeclaration param : params)
69 if (param.getAnnotation(Result.class) == null)
71 for (ParameterDeclaration param : params) {
72 if ( param.getAnnotation(Result.class) != null || (param.getAnnotation(Helper.class) != null && !param.getAnnotation(Helper.class).passToNative()) )
73 continue;
74 final Constant constant_annotation = param.getAnnotation(Constant.class);
75 if ( constant_annotation == null || !constant_annotation.isNative() )
7076 generateParameter(writer, param, mode);
77 }
7178 }
7279
7380 private static void generateParameter(PrintWriter writer, ParameterDeclaration param, Mode mode) {
7481 writer.print(", ");
7582 if (mode == Mode.BUFFEROBJECT && param.getAnnotation(BufferObject.class) != null) {
7683 writer.print("jlong " + param.getSimpleName() + Utils.BUFFER_OBJECT_PARAMETER_POSTFIX);
77 } else if ( param.getAnnotation(GLpointer.class) != null ) {
84 } else if ( param.getAnnotation(PointerWrapper.class) != null ) {
7885 writer.print("jlong " + param.getSimpleName());
7986 } else {
8087 JNITypeTranslator translator = new JNITypeTranslator();
9198 else
9299 writer.print("JNIEXPORT ");
93100
94 TypeMirror result_type = Utils.getMethodReturnType(method);
95
96 if ( method.getAnnotation(GLpointer.class) != null ) {
101 final TypeMirror result_type = Utils.getMethodReturnType(method);
102 final CachedResult cached_result_annotation = method.getAnnotation(CachedResult.class);
103 final AutoSize auto_size_annotation = method.getAnnotation(AutoSize.class);
104
105 if ( method.getAnnotation(PointerWrapper.class) != null ) {
97106 writer.print("jlong");
98107 } else {
99108 JNITypeTranslator translator = new JNITypeTranslator();
108117 writer.print("(JNIEnv *env, jclass clazz");
109118 generateParameters(writer, method.getParameters(), mode);
110119 if (Utils.getNIOBufferType(result_type) != null) {
111 CachedResult cached_result_annotation = method.getAnnotation(CachedResult.class);
112 if (cached_result_annotation == null || !cached_result_annotation.isRange())
120 if ( (cached_result_annotation == null || !cached_result_annotation.isRange()) && (auto_size_annotation == null || !auto_size_annotation.isNative()) )
113121 writer.print(", jlong " + Utils.RESULT_SIZE_NAME);
114122 if (cached_result_annotation != null)
115123 writer.print(", jobject " + Utils.CACHED_BUFFER_NAME);
118126 writer.print(", jlong " + Utils.FUNCTION_POINTER_VAR_NAME);
119127 }
120128 writer.println(") {");
129
121130 generateBufferParameterAddresses(type_map, writer, method, mode);
122131 Alternate alt_annotation = method.getAnnotation(Alternate.class);
123132 if (context_specific) {
126135 writer.print(" = (" + typedef_name + ")((intptr_t)");
127136 writer.println(Utils.FUNCTION_POINTER_VAR_NAME + ");");
128137 }
129 generateStringListInits(writer, method.getParameters());
138
139 final Code code_annotation = method.getAnnotation(Code.class);
140
141 final boolean hasResult = !result_type.equals(env.getTypeUtils().getVoidType());
142 final boolean resultPreDeclare = hasResult && (hasPointerArrayInits(method.getParameters()) || (code_annotation != null && (code_annotation.nativeAfterVars().length() > 0 || code_annotation.nativeBeforeCall().length() > 0)));
143 if ( resultPreDeclare )
144 printResultParam(type_map, writer, method, result_type, true);
145
146 if ( code_annotation != null && code_annotation.nativeAfterVars().length() > 0 )
147 writer.println(code_annotation.nativeAfterVars());
148
149 generatePointerArrayInits(type_map, writer, method.getParameters());
150
151 if ( code_annotation != null && code_annotation.nativeBeforeCall().length() > 0 )
152 writer.println(code_annotation.nativeBeforeCall());
153
130154 writer.print("\t");
131 if (!result_type.equals(env.getTypeUtils().getVoidType())) {
132 Declaration return_declaration;
133 ParameterDeclaration result_param = Utils.getResultParameter(method);
134 if (result_param != null)
135 return_declaration = result_param;
136 else
137 return_declaration = method;
138 NativeTypeTranslator native_translator = new NativeTypeTranslator(type_map, return_declaration);
139 result_type.accept(native_translator);
140 writer.print(native_translator.getSignature() + " " + Utils.RESULT_VAR_NAME);
141 if (result_param != null) {
142 writer.println(";");
143 writer.print("\t");
144 } else
145 writer.print(" = ");
146 }
155 if ( resultPreDeclare )
156 writer.print(Utils.RESULT_VAR_NAME + " = ");
157 else if ( hasResult )
158 printResultParam(type_map, writer, method, result_type, false);
147159 writer.print((alt_annotation == null ? method.getSimpleName() : alt_annotation.value()) + "(");
148160 generateCallParameters(writer, type_map, method.getParameters());
149161 writer.print(")");
150162 writer.println(";");
163
164 if ( code_annotation != null && code_annotation.nativeAfterCall().length() > 0 )
165 writer.println(code_annotation.nativeAfterCall());
166
151167 generateStringDeallocations(writer, method.getParameters());
152168 if (!result_type.equals(env.getTypeUtils().getVoidType())) {
153169 writer.print("\treturn ");
154170 Class java_result_type = Utils.getJavaType(result_type);
155171 if (Buffer.class.isAssignableFrom(java_result_type)) {
156 if (method.getAnnotation(CachedResult.class) != null)
172 if (cached_result_annotation != null)
157173 writer.print("safeNewBufferCached(env, ");
158174 else
159175 writer.print("safeNewBuffer(env, ");
160176 } else if (String.class.equals(java_result_type)) {
161177 writer.print("NewStringNativeUnsigned(env, ");
162 } else if ( method.getAnnotation(GLpointer.class) != null ) {
178 } else if ( method.getAnnotation(PointerWrapper.class) != null ) {
163179 writer.print("(intptr_t)");
164180 }
165181 writer.print(Utils.RESULT_VAR_NAME);
166182 if (Buffer.class.isAssignableFrom(java_result_type)) {
183 final String size_parameter_name;
184 if ( auto_size_annotation != null && (auto_size_annotation.isNative() || (cached_result_annotation != null && cached_result_annotation.isRange())) )
185 size_parameter_name = auto_size_annotation.value();
186 else
187 size_parameter_name = Utils.RESULT_SIZE_NAME;
188
167189 writer.print(", ");
168 if (method.getAnnotation(CachedResult.class) != null && method.getAnnotation(CachedResult.class).isRange())
169 Utils.printExtraCallArguments(writer, method, method.getAnnotation(AutoResultSize.class).value());
170 else
171 Utils.printExtraCallArguments(writer, method, Utils.RESULT_SIZE_NAME);
190 Utils.printExtraCallArguments(writer, method, size_parameter_name);
172191 }
173192 if (Buffer.class.isAssignableFrom(java_result_type) ||
174193 String.class.equals(java_result_type))
179198 writer.println();
180199 }
181200
201 private static void printResultParam(final TypeMap type_map, final PrintWriter writer, final MethodDeclaration method, final TypeMirror result_type, final boolean preDeclare) {
202 final ParameterDeclaration result_param = Utils.getResultParameter(method);
203 final Declaration return_declaration = result_param == null ? method : result_param;
204 final NativeTypeTranslator result_translator = new NativeTypeTranslator(type_map, return_declaration);
205 result_type.accept(result_translator);
206 if ( preDeclare )
207 writer.print("\t");
208 writer.print(result_translator.getSignature() + " " + Utils.RESULT_VAR_NAME);
209 if ( preDeclare)
210 writer.println(";");
211 else
212 writer.print(result_param == null ? " = " : ";\n\t");
213 }
214
182215 private static void generateCallParameters(PrintWriter writer, TypeMap type_map, Collection<ParameterDeclaration> params) {
183216 if (params.size() > 0) {
184 Iterator<ParameterDeclaration> it = params.iterator();
185 generateCallParameter(writer, type_map, it.next());
186 while (it.hasNext()) {
187 writer.print(", ");
188 generateCallParameter(writer, type_map, it.next());
217 boolean first = true;
218 for ( ParameterDeclaration param : params ) {
219 if ( param.getAnnotation(Helper.class) != null )
220 continue;
221
222 if ( first )
223 first = false;
224 else
225 writer.print(", ");
226
227 generateCallParameter(writer, type_map, param);
189228 }
190229 }
191230 }
192231
193232 private static void generateCallParameter(PrintWriter writer, TypeMap type_map, ParameterDeclaration param) {
233 if ( param.getAnnotation(Helper.class) != null )
234 return;
235
236 final Constant constant_annotation = param.getAnnotation(Constant.class);
237 if ( constant_annotation != null && constant_annotation.isNative() ) {
238 writer.print(constant_annotation.value());
239 return;
240 }
241
194242 boolean is_indirect = param.getAnnotation(Indirect.class) != null;
195 if (is_indirect || param.getAnnotation(StringList.class) != null) {
243 if (is_indirect || param.getAnnotation(PointerArray.class) != null) {
196244 writer.print("(");
197 NativeTypeTranslator translator = new NativeTypeTranslator(type_map, param);
245 final NativeTypeTranslator translator = new NativeTypeTranslator(type_map, param);
198246 param.getType().accept(translator);
199247 writer.print(translator.getSignature());
200248 writer.print("*)");
201249 }
202 if ( param.getAnnotation(GLpointer.class) != null )
203 writer.print("(" + param.getAnnotation(GLpointer.class).value() + ")(intptr_t)");
250 if ( param.getAnnotation(PointerWrapper.class) != null )
251 writer.print("(" + param.getAnnotation(PointerWrapper.class).value() + ")(intptr_t)");
204252 if (param.getAnnotation(Result.class) != null || is_indirect)
205253 writer.print("&");
206 if (param.getAnnotation(Result.class) != null) {
254
255 if ( param.getAnnotation(Result.class) != null ) {
207256 writer.print(Utils.RESULT_VAR_NAME);
208257 } else {
209258 writer.print(param.getSimpleName());
210 if ( param.getAnnotation(StringList.class) != null )
211 writer.print(STRING_LIST_POSTFIX);
212 else if (Utils.isAddressableType(param.getType()))
259 if ( param.getAnnotation(PointerArray.class) != null )
260 writer.print(getPointerArrayName(Utils.getJavaType(param.getType())));
261 else if ( Utils.isAddressableType(param.getType()) )
213262 writer.print(BUFFER_ADDRESS_POSTFIX);
214263 }
215264 }
216265
217266 private static void generateStringDeallocations(PrintWriter writer, Collection<ParameterDeclaration> params) {
218267 for (ParameterDeclaration param : params) {
219 if (Utils.getJavaType(param.getType()).equals(String.class) &&
220 param.getAnnotation(Result.class) == null)
268 final Class java_type = Utils.getJavaType(param.getType());
269 if ( java_type.equals(String.class) && param.getAnnotation(Result.class) == null )
221270 writer.println("\tfree(" + param.getSimpleName() + BUFFER_ADDRESS_POSTFIX + ");");
222 else if (param.getAnnotation(StringList.class) != null ) // Free the string array mem
223 writer.println("\tfree(" + param.getSimpleName() + STRING_LIST_POSTFIX + ");");
271 else if (param.getAnnotation(PointerArray.class) != null ) // Free the string array mem
272 writer.println("\tfree(" + param.getSimpleName() + getPointerArrayName(java_type) + ");");
224273 }
225274 }
226275
227276 private static void generateBufferParameterAddresses(TypeMap type_map, PrintWriter writer, MethodDeclaration method, Mode mode) {
228 boolean loopDeclared = false;
229 for (ParameterDeclaration param : method.getParameters())
230 if (Utils.isAddressableType(param.getType()) && param.getAnnotation(Result.class) == null)
231 loopDeclared = generateBufferParameterAddress(type_map, writer, method, param, mode, loopDeclared);
232 }
233
234 private static boolean generateBufferParameterAddress(TypeMap type_map, PrintWriter writer, MethodDeclaration method, ParameterDeclaration param, Mode mode, boolean loopDeclared) {
235 NativeTypeTranslator translator = new NativeTypeTranslator(type_map, param);
277 strLoopDeclared = false;
278 ptrLoopDeclared = false;
279 for ( ParameterDeclaration param : method.getParameters() ) {
280 final Constant constant_annotation = param.getAnnotation(Constant.class);
281 if ( param.getAnnotation(Result.class) == null && (constant_annotation == null || !constant_annotation.isNative()) && Utils.isAddressableType(param.getType()))
282 generateBufferParameterAddress(type_map, writer, method, param, mode);
283 }
284 }
285
286 private static boolean strLoopDeclared;
287 private static boolean ptrLoopDeclared;
288
289 private static void generateBufferParameterAddress(TypeMap type_map, PrintWriter writer, MethodDeclaration method, ParameterDeclaration param, Mode mode) {
290 final Check check_annotation = param.getAnnotation(Check.class);
291 final PointerArray array_annotation = param.getAnnotation(PointerArray.class);
292 final Class java_type = Utils.getJavaType(param.getType());
293
294 final NativeTypeTranslator translator = new NativeTypeTranslator(type_map, param);
236295 param.getType().accept(translator);
237 writer.print("\t" + translator.getSignature() + param.getSimpleName());
238 writer.print(BUFFER_ADDRESS_POSTFIX + " = ((");
239 writer.print(translator.getSignature());
240 Check check_annotation = param.getAnnotation(Check.class);
241 writer.print(")");
242 if (mode == Mode.BUFFEROBJECT && param.getAnnotation(BufferObject.class) != null) {
243 writer.print("offsetToPointer(" + param.getSimpleName() + Utils.BUFFER_OBJECT_PARAMETER_POSTFIX + "))");
244 } else {
245 Class java_type = Utils.getJavaType(param.getType());
246 if (Buffer.class.isAssignableFrom(java_type) || java_type.equals(CharSequence.class) || java_type.equals(CharSequence[].class)) {
247 boolean explicitly_byte_sized = java_type.equals(Buffer.class) ||
248 translator.getAnnotationType().equals(type_map.getVoidType());
249 if (explicitly_byte_sized)
250 writer.print("(((char *)");
251 if (method.getAnnotation(GenerateAutos.class) != null || (check_annotation != null && check_annotation.canBeNull())) {
252 writer.print("safeGetBufferAddress(env, " + param.getSimpleName());
296 final String native_type = translator.getSignature();
297
298 if ( !java_type.isArray() || CharSequence.class.isAssignableFrom(java_type.getComponentType()) ) {
299 writer.print("\t" + native_type + param.getSimpleName());
300 writer.print(BUFFER_ADDRESS_POSTFIX + " = ((");
301 writer.print(native_type);
302 writer.print(")");
303
304 if (mode == Mode.BUFFEROBJECT && param.getAnnotation(BufferObject.class) != null) {
305 writer.print("offsetToPointer(" + param.getSimpleName() + Utils.BUFFER_OBJECT_PARAMETER_POSTFIX + "))");
306 } else {
307 if (Buffer.class.isAssignableFrom(java_type) || java_type.equals(CharSequence.class) || java_type.equals(CharSequence[].class) || PointerBuffer.class.isAssignableFrom(java_type) ) {
308 boolean explicitly_byte_sized = java_type.equals(Buffer.class) ||
309 translator.getAnnotationType().equals(type_map.getVoidType()) ||
310 param.getAnnotation(NativeType.class) != null;
311 if (explicitly_byte_sized)
312 writer.print("(((char *)");
313 if (method.getAnnotation(GenerateAutos.class) != null || (check_annotation != null && check_annotation.canBeNull())) {
314 writer.print("safeGetBufferAddress(env, " + param.getSimpleName());
315 } else {
316 writer.print("(*env)->GetDirectBufferAddress(env, " + param.getSimpleName());
317 }
318 writer.print("))");
319 writer.print(" + " + param.getSimpleName() + BUFFER_POSITION_POSTFIX);
320 if (explicitly_byte_sized)
321 writer.print("))");
322 } else if (java_type.equals(String.class)) {
323 writer.print("GetStringNativeChars(env, " + param.getSimpleName() + "))");
324 } else if ( array_annotation == null )
325 throw new RuntimeException("Illegal type " + java_type);
326 }
327 writer.println(";");
328 }
329
330 if ( array_annotation != null ) {
331 final String n = getPointerArrayName(java_type);
332 final String arrayType;
333 if ( POINTER_LIST_NAME.equals(n) ) {
334 if ( n.equals(param.getSimpleName()) )
335 throw new RuntimeException("The name '" + n + "' is not valid for object array arguments annotated with PointerArray");
336
337 arrayType = translator.getSignature(true) + (org.lwjgl.PointerWrapper.class.isAssignableFrom(java_type.getComponentType()) ? " " : "");
338
339 // Declare loop counters and allocate object array
340 if ( !ptrLoopDeclared ) {
341 writer.println("\tunsigned int " + n + "_i;");
342 writer.println("\tjobject " + n + "_object;");
343 ptrLoopDeclared = true;
344 }
345 } else {
346 if ( n.equals(param.getSimpleName()) )
347 throw new RuntimeException("The name '" + n + "' is not valid for arguments annotated with PointerArray");
348
349 arrayType = translator.getSignature(true);
350
351 // Declare loop counters and allocate string array
352 if ( !strLoopDeclared ) {
353 writer.println("\tunsigned int " + n + "_i;");
354 writer.println("\t" + arrayType + n + "_address;");
355 strLoopDeclared = true;
356 }
357 }
358
359 writer.print("\t" + arrayType + "*" + param.getSimpleName() + n + " = ");
360 if ( check_annotation != null && check_annotation.canBeNull() )
361 writer.print(array_annotation.value() + " == 0 ? NULL : ");
362 writer.println("(" + arrayType + "*) malloc(" + array_annotation.value() + " * sizeof(" + arrayType + "));");
363 }
364 }
365
366 private static String getPointerArrayName(final Class java_type) {
367 final Class<?> component_type = java_type.getComponentType();
368 if ( component_type != null && (Buffer.class.isAssignableFrom(component_type) || org.lwjgl.PointerWrapper.class.isAssignableFrom(component_type)) )
369 return POINTER_LIST_NAME;
370 else
371 return STRING_LIST_NAME;
372 }
373
374 private static boolean hasPointerArrayInits(Collection<ParameterDeclaration> params) {
375 for ( ParameterDeclaration param : params ) {
376 PointerArray pointerArray_annotation = param.getAnnotation(PointerArray.class);
377 if ( pointerArray_annotation != null )
378 return true;
379 }
380 return false;
381 }
382
383 private static void generatePointerArrayInits(TypeMap type_map, PrintWriter writer, Collection<ParameterDeclaration> params) {
384 for ( ParameterDeclaration param : params ) {
385 PointerArray pointerArray_annotation = param.getAnnotation(PointerArray.class);
386 if ( pointerArray_annotation != null ) {
387 final Class java_type = Utils.getJavaType(param.getType());
388 final Class<?> component_type = java_type.isArray() ? java_type.getComponentType() : null;
389 final NativeTypeTranslator translator = new NativeTypeTranslator(type_map, param);
390 param.getType().accept(translator);
391
392 final String n = getPointerArrayName(java_type);
393 if ( POINTER_LIST_NAME.equals(n) ) {
394 // Init vars
395 writer.println("\t" + n + "_i = 0;");
396 // Fill pointer array with the buffer pointers
397 writer.println("\twhile ( " + n + "_i < " + pointerArray_annotation.value() + " ) {");
398 if ( component_type.isAssignableFrom(Buffer.class) )
399 writer.println("\t\t" + n + "_object = (*env)->GetObjectArrayElement(env, " + param.getSimpleName() + ", " + n + "_i);");
400 else
401 writer.println("\t\t" + n + "_object = (*env)->GetObjectArrayElement(env, " + param.getSimpleName() + ", " + n + "_i);");
402 writer.println("\t\t" + param.getSimpleName() + n + "[" + n + "_i++] = (" + translator.getSignature(true) + ")(intptr_t)getPointerWrapperAddress(env, " + n + "_object);");
403 writer.println("\t}");
253404 } else {
254 writer.print("(*env)->GetDirectBufferAddress(env, " + param.getSimpleName());
405 final String lengths = pointerArray_annotation.lengths();
406
407 // Init vars
408 writer.println("\t" + n + "_i = 0;");
409 writer.println("\t" + n + "_address = (" + translator.getSignature(true) + ")" + param.getSimpleName() + BUFFER_ADDRESS_POSTFIX + ";");
410 // Fill string array with the string pointers
411 writer.println("\twhile ( " + n + "_i < " + pointerArray_annotation.value() + " ) {");
412 if ( lengths.length() == 0 ) {
413 writer.println("\t\t" + param.getSimpleName() + n + "[" + n + "_i++] = " + n + "_address;");
414 writer.println("\t\t" + n + "_address += strlen(" + n + "_address) + 1;");
415 } else {
416 writer.println("\t\t" + param.getSimpleName() + n + "[" + n + "_i] = " + n + "_address;");
417 writer.println("\t\t" + n + "_address += " + lengths + BUFFER_ADDRESS_POSTFIX + "[" + n + "_i++];");
418 }
419 writer.println("\t}");
255420 }
256 writer.print("))");
257 writer.print(" + " + param.getSimpleName() + BUFFER_POSITION_POSTFIX);
258 if (explicitly_byte_sized)
259 writer.print("))");
260 } else if (java_type.equals(String.class)) {
261 writer.print("GetStringNativeChars(env, " + param.getSimpleName() + "))");
262 } else
263 throw new RuntimeException("Illegal type " + java_type);
264 }
265 writer.println(";");
266
267 if ( param.getAnnotation(StringList.class) != null ) {
268 if ( Utils.getJavaType(param.getType()) != CharSequence[].class && (
269 param.getAnnotation(GLchar.class) == null ||
270 param.getAnnotation(NullTerminated.class) == null ||
271 param.getAnnotation(NullTerminated.class).value().length() == 0
272 )
273 )
274 throw new RuntimeException("StringList annotation can only be applied on null-terminated GLchar buffers.");
275
276 if ( "_str".equals(param.getSimpleName()) )
277 throw new RuntimeException("The name '_str' is not valid for arguments annotated with StringList");
278
279 // Declare loop counters and allocate string array
280 if ( !loopDeclared ) {
281 writer.println("\tunsigned int _str_i;");
282 writer.println("\tGLchar *_str_address;");
283 loopDeclared = true;
284 }
285 writer.println("\tGLchar **" + param.getSimpleName() + STRING_LIST_POSTFIX + " = (GLchar **) malloc(" + param.getAnnotation(StringList.class).value() + "*sizeof(GLchar*));");
286 }
287 return loopDeclared;
288 }
289
290 private static void generateStringListInits(PrintWriter writer, Collection<ParameterDeclaration> params) {
291 for ( ParameterDeclaration param : params ) {
292 StringList stringList_annotation = param.getAnnotation(StringList.class);
293 if ( stringList_annotation != null ) {
294 String lengths = stringList_annotation.lengths();
295
296 // Init vars
297 writer.println("\t_str_i = 0;");
298 writer.println("\t_str_address = (GLchar *)" + param.getSimpleName() + BUFFER_ADDRESS_POSTFIX + ";");
299 // Fill string array with the string pointers
300 writer.println("\twhile ( _str_i < " + stringList_annotation.value() + " ) {");
301 if ( lengths.length() == 0 ) {
302 writer.println("\t\t" + param.getSimpleName() + STRING_LIST_POSTFIX + "[_str_i++] = _str_address;");
303 writer.println("\t\t_str_address += strlen(_str_address) + 1;");
304 } else {
305 writer.println("\t\t" + param.getSimpleName() + STRING_LIST_POSTFIX + "[_str_i] = _str_address;");
306 writer.println("\t\t_str_address += " + lengths + BUFFER_ADDRESS_POSTFIX + "[_str_i++];");
307 }
308 writer.println("\t}");
309421 }
310422 }
311423 }
3636 * a native type.
3737 *
3838 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 2983 $
40 * $Id: NativeType.java 2983 2008-04-07 18:36:09Z matzon $
39 * @version $Revision: 3412 $
40 * $Id: NativeType.java 3412 2010-09-26 23:43:24Z spasi $
4141 */
4242
4343 import java.lang.annotation.Target;
4444 import java.lang.annotation.ElementType;
4545
46 @Target(ElementType.ANNOTATION_TYPE)
46 @Target({ElementType.ANNOTATION_TYPE, ElementType.PARAMETER})
4747 public @interface NativeType {
48 String value() default "";
4849 }
3737 * annotations) to the native type string.
3838 *
3939 * @author elias_naur <elias_naur@users.sourceforge.net>
40 * @version $Revision: 3281 $
41 * $Id: NativeTypeTranslator.java 3281 2010-03-12 21:55:13Z spasi $
40 * @version $Revision: 3412 $
41 * $Id: NativeTypeTranslator.java 3412 2010-09-26 23:43:24Z spasi $
4242 */
4343
44 import org.lwjgl.opengl.PointerWrapper;
45
46 import com.sun.mirror.declaration.*;
44 import org.lwjgl.PointerBuffer;
45
46 import java.lang.annotation.Annotation;
47 import java.nio.*;
48 import java.util.ArrayList;
49 import java.util.Collection;
50
51 import com.sun.mirror.declaration.AnnotationMirror;
52 import com.sun.mirror.declaration.Declaration;
4753 import com.sun.mirror.type.*;
48 import com.sun.mirror.util.*;
49
50 import java.util.Collection;
51 import java.util.ArrayList;
52
53 import java.nio.*;
54
55 import java.lang.annotation.Annotation;
54 import com.sun.mirror.util.TypeVisitor;
5655
5756 /**
58 * $Id: NativeTypeTranslator.java 3281 2010-03-12 21:55:13Z spasi $
59 *
57 * $Id: NativeTypeTranslator.java 3412 2010-09-26 23:43:24Z spasi $
58 * <p/>
6059 * A TypeVisitor that translates (annotated) TypeMirrors to
6160 * native types
6261 *
6362 * @author elias_naur <elias_naur@users.sourceforge.net>
64 * @version $Revision: 3281 $
63 * @version $Revision: 3412 $
6564 */
6665 public class NativeTypeTranslator implements TypeVisitor {
66
6767 private Collection<Class> native_types;
6868 private boolean is_indirect;
6969 private final Declaration declaration;
7575 }
7676
7777 public String getSignature() {
78 return getSignature(false);
79 }
80
81 public String getSignature(final boolean skipConst) {
7882 StringBuilder signature = new StringBuilder();
79 if (declaration.getAnnotation(Const.class) != null)
83 if ( !skipConst && declaration.getAnnotation(Const.class) != null )
8084 signature.append("const ");
8185
82 if ( declaration.getAnnotation(GLpointer.class) != null ) {
83 signature.append(declaration.getAnnotation(GLpointer.class).value());
86 if ( declaration.getAnnotation(PointerWrapper.class) != null ) {
87 signature.append(declaration.getAnnotation(PointerWrapper.class).value());
88 } else if ( declaration.getAnnotation(NativeType.class) != null ) {
89 signature.append(declaration.getAnnotation(NativeType.class).value());
8490 } else {
8591 // Use the name of the native type annotation as the C type name
8692 signature.append(getAnnotationType().getSimpleName());
8793 }
8894
89 if (is_indirect)
95 if ( is_indirect )
9096 signature.append(" *");
9197 return signature.toString();
9298 }
9399
94100 public Class getAnnotationType() {
95 if (native_types.size() != 1)
101 if ( native_types.size() != 1 )
96102 throw new RuntimeException("Expected only one native type for declaration " + declaration +
97 ", but got " + native_types.size());
103 ", but got " + native_types.size());
98104 return native_types.iterator().next();
99105 }
100106
103109 }
104110
105111 public void visitArrayType(ArrayType t) {
106 if ( "java.lang.CharSequence".equals(t.getComponentType().toString()) ) {
112 final Class<?> type = Utils.getJavaType(t).getComponentType();
113
114 if ( CharSequence.class.isAssignableFrom(type) ) {
107115 is_indirect = true;
108116 native_types = new ArrayList<Class>();
109 native_types.add(GLchar.class);
117 native_types.add(type_map.getStringArrayType());
118 } else if ( Buffer.class.isAssignableFrom(type) ) {
119 is_indirect = true;
120 native_types = new ArrayList<Class>();
121 native_types.add(type_map.getByteBufferArrayType());
122 } else if ( org.lwjgl.PointerWrapper.class.isAssignableFrom(type) ) {
123 is_indirect = false;
110124 } else
111125 throw new RuntimeException(t + " is not allowed");
112126 }
113127
114128 public static PrimitiveType.Kind getPrimitiveKindFromBufferClass(Class c) {
115 if (IntBuffer.class.equals(c))
129 if ( IntBuffer.class.equals(c) )
116130 return PrimitiveType.Kind.INT;
117 else if (DoubleBuffer.class.equals(c))
131 else if ( DoubleBuffer.class.equals(c) )
118132 return PrimitiveType.Kind.DOUBLE;
119 else if (ShortBuffer.class.equals(c))
133 else if ( ShortBuffer.class.equals(c) )
120134 return PrimitiveType.Kind.SHORT;
121 else if (ByteBuffer.class.equals(c))
135 else if ( ByteBuffer.class.equals(c) || PointerBuffer.class.equals(c) )
122136 return PrimitiveType.Kind.BYTE;
123 else if (FloatBuffer.class.equals(c))
137 else if ( FloatBuffer.class.equals(c) )
124138 return PrimitiveType.Kind.FLOAT;
125 else if (LongBuffer.class.equals(c))
139 else if ( LongBuffer.class.equals(c) )
126140 return PrimitiveType.Kind.LONG;
127141 else
128142 throw new RuntimeException(c + " is not allowed");
129143 }
130144
131 public static Class<?> getClassFromType(DeclaredType t) {
145 @SuppressWarnings("unchecked")
146 public static Class<? extends Annotation> getClassFromType(DeclaredType t) {
132147 try {
133 return Class.forName(t.getDeclaration().getQualifiedName());
148 return (Class<? extends Annotation>)Class.forName(t.getDeclaration().getQualifiedName());
134149 } catch (ClassNotFoundException e) {
135150 throw new RuntimeException(e);
136151 }
138153
139154 private void getNativeTypeFromAnnotatedPrimitiveType(PrimitiveType.Kind kind) {
140155 native_types = translateAnnotations();
141 if (native_types.size() == 0)
156 if ( native_types.size() == 0 )
142157 native_types.add(type_map.getNativeTypeFromPrimitiveType(kind));
143158 }
144159
146161 is_indirect = true;
147162
148163 Class<?> c = getClassFromType(t);
149 if (String.class.equals(c)) {
164 if ( String.class.equals(c) ) {
150165 native_types = new ArrayList<Class>();
151166 native_types.add(type_map.getStringElementType());
152 } else if (Buffer.class.equals(c)) {
167 } else if ( Buffer.class.equals(c) ) {
153168 native_types = new ArrayList<Class>();
154169 native_types.add(type_map.getVoidType());
155 } else if (Buffer.class.isAssignableFrom(c)) {
170 } else if ( Buffer.class.isAssignableFrom(c) ) {
156171 PrimitiveType.Kind kind = getPrimitiveKindFromBufferClass(c);
157172 getNativeTypeFromAnnotatedPrimitiveType(kind);
158 } else if ( PointerWrapper.class.isAssignableFrom(c) ) {
159 native_types = new ArrayList<Class>();
160 native_types.add(GLpointer.class);
173 } else if ( PointerBuffer.class.isAssignableFrom(c) ) {
174 native_types = new ArrayList<Class>();
175 native_types.add(PointerBuffer.class);
176 } else if ( org.lwjgl.PointerWrapper.class.isAssignableFrom(c) ) {
177 native_types = new ArrayList<Class>();
178 native_types.add(PointerWrapper.class);
161179
162180 is_indirect = false;
163181 } else
181199 }
182200
183201 // Check if the annotation is itself annotated with a certain annotation type
202
184203 public static <T extends Annotation> T getAnnotation(AnnotationMirror annotation, Class<T> type) {
185204 return annotation.getAnnotationType().getDeclaration().getAnnotation(type);
186205 }
187206
188207 private static Class translateAnnotation(AnnotationMirror annotation) {
189208 NativeType native_type = getAnnotation(annotation, NativeType.class);
190 if (native_type != null) {
209 if ( native_type != null ) {
191210 return getClassFromType(annotation.getAnnotationType());
192211 } else
193212 return null;
195214
196215 private Collection<Class> translateAnnotations() {
197216 Collection<Class> result = new ArrayList<Class>();
198 for (AnnotationMirror annotation : Utils.getSortedAnnotations(declaration.getAnnotationMirrors())) {
217 for ( AnnotationMirror annotation : Utils.getSortedAnnotations(declaration.getAnnotationMirrors()) ) {
199218 Class translated_result = translateAnnotation(annotation);
200 if (translated_result != null) {
219 if ( translated_result != null ) {
201220 result.add(translated_result);
202221 }
203222 }
218237
219238 public void visitVoidType(VoidType t) {
220239 native_types = translateAnnotations();
221 if (native_types.size() == 0)
240 if ( native_types.size() == 0 )
222241 native_types.add(void.class);
223242 }
224243
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 *
35 * @author spasi <spasi@users.sourceforge.net>
36 */
37
38 import java.lang.annotation.ElementType;
39 import java.lang.annotation.Target;
40
41 @Target({ElementType.PARAMETER, ElementType.METHOD})
42 public @interface PointerArray {
43 /** Number of values in the string list (name of native-side parameter) */
44 String value();
45 /** List of string lengths (name of native-side parameter) */
46 String lengths() default "";
47 }
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 * @author spasi <spasi@users.sourceforge.net>
35 */
36 import java.lang.annotation.Target;
37 import java.lang.annotation.ElementType;
38
39 @Target({ElementType.PARAMETER, ElementType.METHOD})
40 public @interface PointerWrapper {
41 String value(); // The native pointer type.
42 boolean canBeNull() default false; // Whether the pointer may be null.
43 String params() default ""; // Pass these extra parameters when constructing PointerWrapper objects.
44 String factory() default ""; // Use this factory method call instead of normal object construction.
45 }
3737 * postfixes.
3838 *
3939 * @author elias_naur <elias_naur@users.sourceforge.net>
40 * @version $Revision: 3287 $
41 * $Id: PostfixTranslator.java 3287 2010-03-14 23:24:40Z spasi $
40 * @version $Revision: 3412 $
41 * $Id: PostfixTranslator.java 3412 2010-09-26 23:43:24Z spasi $
4242 */
4343
4444 import com.sun.mirror.declaration.*;
4545 import com.sun.mirror.type.*;
4646 import com.sun.mirror.util.*;
4747
48 import java.lang.annotation.Annotation;
4849 import java.nio.*;
4950
5051 public class PostfixTranslator implements TypeVisitor {
107108 private boolean translateAnnotation(AnnotationMirror annotation) {
108109 NativeType native_type = NativeTypeTranslator.getAnnotation(annotation, NativeType.class);
109110 if (native_type != null) {
110 Class annotation_class = NativeTypeTranslator.getClassFromType(annotation.getAnnotationType());
111 Class<? extends Annotation> annotation_class = NativeTypeTranslator.getClassFromType(annotation.getAnnotationType());
111112 signature.append(type_map.translateAnnotation(annotation_class));
112113 return true;
113114 } else
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.util.generator;
32
33 /**
34 * Extension templates marked with <code>@Private</code> will result in classes without the <code>public</code> keyword.
35 *
36 * @author Spasi
37 */
38
39 import java.lang.annotation.ElementType;
40 import java.lang.annotation.Target;
41
42 @Target({ElementType.TYPE, ElementType.METHOD})
43 public @interface Private {
44
45 }
3636 * This class generates the initNatives native function.
3737 *
3838 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 3288 $
40 * $Id: RegisterStubsGenerator.java 3288 2010-03-16 17:58:48Z spasi $
39 * @version $Revision: 3418 $
40 * $Id: RegisterStubsGenerator.java 3418 2010-09-28 21:11:35Z spasi $
4141 */
42
43 import org.lwjgl.opencl.CLMem;
4244
4345 import com.sun.mirror.declaration.*;
4446 import com.sun.mirror.type.*;
5153 Iterator<? extends MethodDeclaration> it = d.getMethods().iterator();
5254 while (it.hasNext()) {
5355 MethodDeclaration method = it.next();
54 if ( method.getAnnotation(Alternate.class) != null )
56 Alternate alt_annotation = method.getAnnotation(Alternate.class);
57 if ( (alt_annotation != null && (!alt_annotation.nativeAlt() || alt_annotation.skipNative())) || method.getAnnotation(Reuse.class) != null )
5558 continue;
5659 EnumSet<Platform> platforms;
5760 PlatformDependent platform_annotation = method.getAnnotation(PlatformDependent.class);
8285 Collection<ParameterDeclaration> params = method.getParameters();
8386 String signature = "(";
8487 for (ParameterDeclaration param : params) {
85 if (param.getAnnotation(Result.class) != null)
88 if ( param.getAnnotation(Result.class) != null || (param.getAnnotation(Helper.class) != null && !param.getAnnotation(Helper.class).passToNative()) )
8689 continue;
87 if (mode == Mode.BUFFEROBJECT && param.getAnnotation(BufferObject.class) != null) {
90
91 final Constant constant_annotation = param.getAnnotation(Constant.class);
92 if ( constant_annotation != null && constant_annotation.isNative() )
93 continue;
94
95 if (mode == Mode.BUFFEROBJECT && param.getAnnotation(BufferObject.class) != null)
8896 signature += "I";
89 } else {
97 else
9098 signature += getTypeSignature(param.getType(), true);
91 }
9299 }
93 TypeMirror result_type = Utils.getMethodReturnType(method);
94 if (Utils.getNIOBufferType(result_type) != null)
95 signature += "I";
100
101 final TypeMirror result_type = Utils.getMethodReturnType(method);
102 final CachedResult cached_result_annotation = method.getAnnotation(CachedResult.class);
103 final AutoSize auto_size_annotation = method.getAnnotation(AutoSize.class);
104
105 if ( Utils.getNIOBufferType(result_type) != null && (auto_size_annotation == null || !auto_size_annotation.isNative()) )
106 signature += "J";
107
96108 String result_type_signature = getTypeSignature(result_type, false);
97 if (method.getAnnotation(CachedResult.class) != null)
109 if ( cached_result_annotation != null )
98110 signature += result_type_signature;
111
99112 signature += ")";
100113 signature += result_type_signature;
101114 return signature;
109122 writer.print(Utils.getQualifiedNativeMethodName(Utils.getQualifiedClassName(d), method, generate_error_checks, context_specific));
110123 if (mode == Mode.BUFFEROBJECT)
111124 writer.print(Utils.BUFFER_OBJECT_METHOD_POSTFIX);
112 String opengl_handle_name = method.getSimpleName().replaceFirst("gl", platform.getPrefix());
113 writer.print(", \"" + opengl_handle_name + "\", (void *)&" + method.getSimpleName() + "}");
125
126 final Alternate alt_annotation = method.getAnnotation(Alternate.class);
127 final String methodName = alt_annotation == null ? method.getSimpleName() : alt_annotation.value();
128 String opengl_handle_name = methodName.replaceFirst("gl", platform.getPrefix());
129 writer.print(", \"" + opengl_handle_name + "\", (void *)&" + methodName + "}");
114130 if (has_more)
115131 writer.println(",");
116132 }
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 import java.lang.annotation.ElementType;
34 import java.lang.annotation.Target;
35
36 /**
37 * Reuse can be used to annotate methods that duplicate functionality that has been already
38 * defined somewhere else. For example, this can be applied to OpenGL core functionality that
39 * exists as an ARB extension as well, but with the exact same entry points.
40 *
41 * @author Spasi
42 */
43 @Target(ElementType.METHOD)
44 public @interface Reuse {
45 /** The extension Class that defines the method. */
46 String value();
47
48 }
3636 * A TypeVisitor that translates types to JNI signatures.
3737 *
3838 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 2983 $
40 * $Id: SignatureTranslator.java 2983 2008-04-07 18:36:09Z matzon $
39 * @version $Revision: 3443 $
40 * $Id: SignatureTranslator.java 3443 2010-10-12 21:13:03Z spasi $
4141 */
42
43 import org.lwjgl.PointerBuffer;
4244
4345 import com.sun.mirror.type.*;
4446 import com.sun.mirror.util.*;
6668 }
6769
6870 public void visitArrayType(ArrayType t) {
69 throw new RuntimeException(t + " is not allowed");
71 final Class type = Utils.getJavaType(t.getComponentType());
72 if ( CharSequence.class.isAssignableFrom(type) )
73 signature.append("Ljava/nio/ByteBuffer;I");
74 else if ( Buffer.class.isAssignableFrom(type) )
75 signature.append("[Ljava/nio/ByteBuffer;");
76 else if ( org.lwjgl.PointerWrapper.class.isAssignableFrom(type) )
77 signature.append("[L" + getNativeNameFromClassName(type.getName()) + ";");
78 else
79 throw new RuntimeException(t + " is not allowed");
7080 }
7181
7282 public void visitClassType(ClassType t) {
73 String type_name = getNativeNameFromClassName(t.getDeclaration().getQualifiedName());
83 Class type = NativeTypeTranslator.getClassFromType(t);
84 String type_name;
85 if ( (CharSequence.class.isAssignableFrom(type) && !String.class.equals(type)) || CharSequence[].class.isAssignableFrom(type) || PointerBuffer.class.isAssignableFrom(type) )
86 type_name = ByteBuffer.class.getName();
87 else if ( org.lwjgl.PointerWrapper.class.isAssignableFrom(type) ) {
88 signature.append("J");
89 return;
90 } else
91 type_name = t.getDeclaration().getQualifiedName();
92
7493 signature.append("L");
75 signature.append(type_name);
94 signature.append(getNativeNameFromClassName(type_name));
7695 signature.append(";");
77 if (add_position_signature && Buffer.class.isAssignableFrom(NativeTypeTranslator.getClassFromType(t))) {
96 if ( add_position_signature && Utils.isAddressableType(type) && !String.class.equals(type) )
7897 signature.append("I");
79 }
8098 }
8199
82100 public void visitDeclaredType(DeclaredType t) {
3636 * TypeInfos in case of multityped parameters.
3737 *
3838 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 3279 $
40 * $Id: TypeInfo.java 3279 2010-03-11 21:06:49Z spasi $
39 * @version $Revision: 3412 $
40 * $Id: TypeInfo.java 3412 2010-09-26 23:43:24Z spasi $
4141 */
42
43 import org.lwjgl.util.generator.opengl.GLvoid;
4244
4345 import com.sun.mirror.declaration.*;
4446 import com.sun.mirror.type.*;
4547
48 import java.lang.annotation.Annotation;
4649 import java.util.*;
4750 import java.nio.*;
4851
9396 break;
9497 case BYTE:
9598 type = byte.class;
99 break;
100 case BOOLEAN:
101 type = boolean.class;
96102 break;
97103 default:
98104 throw new RuntimeException(kind + " is not allowed");
150156 for (AnnotationMirror annotation : annotations) {
151157 NativeType native_type_annotation = NativeTypeTranslator.getAnnotation(annotation, NativeType.class);
152158 if (native_type_annotation != null) {
153 Class annotation_type = NativeTypeTranslator.getClassFromType(annotation.getAnnotationType());
159 Class<? extends Annotation> annotation_type = NativeTypeTranslator.getClassFromType(annotation.getAnnotationType());
154160 Signedness signedness = type_map.getSignednessFromType(annotation_type);
155161 Class inverse_type = type_map.getInverseType(annotation_type);
156162 String auto_type = type_map.getAutoTypeFromAnnotation(annotation);
3636 * The interface to the OpenAL/OpenGL specific generator behaviour
3737 *
3838 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 2983 $
40 * $Id: TypeMap.java 2983 2008-04-07 18:36:09Z matzon $
39 * @version $Revision: 3412 $
40 * $Id: TypeMap.java 3412 2010-09-26 23:43:24Z spasi $
4141 */
4242
4343 import com.sun.mirror.declaration.*;
4444 import com.sun.mirror.type.*;
4545
4646 import java.io.*;
47 import java.lang.annotation.Annotation;
4748
4849 public interface TypeMap {
49 String getErrorCheckMethodName();
50 void printCapabilitiesInit(PrintWriter writer);
51 String getCapabilities();
52 void printErrorCheckMethod(PrintWriter writer, MethodDeclaration method, String tabs);
5053 String getRegisterNativesFunctionName();
51 PrimitiveType.Kind getPrimitiveTypeFromNativeType(Class native_type);
52 String getTypedefPrefix();
54 PrimitiveType.Kind getPrimitiveTypeFromNativeType(Class<? extends Annotation> native_type);
55 String getTypedefPostfix();
56 String getFunctionPrefix();
5357 void printNativeIncludes(PrintWriter writer);
54 Class getStringElementType();
58 Class<? extends Annotation> getStringElementType();
59 Class<? extends Annotation> getStringArrayType();
60 Class<? extends Annotation> getByteBufferArrayType();
5561 Class[] getValidAnnotationTypes(Class type);
56 Class getVoidType();
57 String translateAnnotation(Class annotation_type);
62 Class<? extends Annotation> getVoidType();
63 String translateAnnotation(Class<? extends Annotation> annotation_type);
5864 Class getNativeTypeFromPrimitiveType(PrimitiveType.Kind kind);
5965 String getAutoTypeFromAnnotation(AnnotationMirror annotation);
60 Class getInverseType(Class type);
61 Signedness getSignednessFromType(Class type);
66 Class<? extends Annotation> getInverseType(Class<? extends Annotation> type);
67 Signedness getSignednessFromType(Class<? extends Annotation> type);
6268 }
3636 * A TypeVisitor that generates the native typedefs.
3737 *
3838 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 3281 $
40 * $Id: TypedefsGenerator.java 3281 2010-03-12 21:55:13Z spasi $
39 * @version $Revision: 3412 $
40 * $Id: TypedefsGenerator.java 3412 2010-09-26 23:43:24Z spasi $
4141 */
4242
4343 import com.sun.mirror.declaration.*;
5050 private static void generateNativeTypedefs(TypeMap type_map, PrintWriter writer, MethodDeclaration method) {
5151 TypeMirror return_type = method.getReturnType();
5252 writer.print("typedef ");
53 writer.print(type_map.getTypedefPostfix());
5354 NativeTypeTranslator translator = new NativeTypeTranslator(type_map, method);
5455 return_type.accept(translator);
5556 writer.print(translator.getSignature());
5657 writer.print(" (");
57 writer.print(type_map.getTypedefPrefix());
58 writer.print(type_map.getFunctionPrefix());
5859 writer.print(" *" + Utils.getTypedefName(method) + ") (");
5960 generateNativeTypedefsParameters(type_map, writer, method.getParameters());
6061 writer.println(");");
6263
6364 private static void generateNativeTypedefsParameters(TypeMap type_map, PrintWriter writer, Collection<ParameterDeclaration> params) {
6465 if (params.size() > 0) {
65 Iterator<ParameterDeclaration> it = params.iterator();
66 generateNativeTypedefsParameter(type_map, writer, it.next());
67 while (it.hasNext()) {
68 writer.print(", ");
69 generateNativeTypedefsParameter(type_map, writer, it.next());
66 boolean first = true;
67 for ( ParameterDeclaration param : params ) {
68 if ( param.getAnnotation(Helper.class) != null )
69 continue;
70
71 if ( first )
72 first = false;
73 else
74 writer.print(", ");
75
76 generateNativeTypedefsParameter(type_map, writer, param);
7077 }
7178 }
7279 }
7582 NativeTypeTranslator translator = new NativeTypeTranslator(type_map, param);
7683 param.getType().accept(translator);
7784 writer.print(translator.getSignature());
78 if (param.getAnnotation(Result.class) != null || param.getAnnotation(Indirect.class) != null || param.getAnnotation(StringList.class) != null)
85 if (param.getAnnotation(Result.class) != null || param.getAnnotation(Indirect.class) != null || param.getAnnotation(PointerArray.class) != null)
7986 writer.print("*");
8087 writer.print(" " + param.getSimpleName());
8188 }
8289
8390 public static void generateNativeTypedefs(TypeMap type_map, PrintWriter writer, Collection<? extends MethodDeclaration> methods) {
8491 for (MethodDeclaration method : methods) {
85 if ( method.getAnnotation(Alternate.class) == null )
92 if ( method.getAnnotation(Alternate.class) == null && method.getAnnotation(Reuse.class) == null )
8693 generateNativeTypedefs(type_map, writer, method);
8794 }
8895 }
3535 * Various utility methods to the generator.
3636 *
3737 * @author elias_naur <elias_naur@users.sourceforge.net>
38 * @version $Revision: 3339 $
39 * $Id: Utils.java 3339 2010-05-07 17:03:36Z spasi $
38 * @version $Revision: 3443 $
39 * $Id: Utils.java 3443 2010-10-12 21:13:03Z spasi $
4040 */
41
42 import org.lwjgl.PointerBuffer;
43 import org.lwjgl.util.generator.opengl.GLboolean;
44 import org.lwjgl.util.generator.opengl.GLchar;
45 import org.lwjgl.util.generator.opengl.GLcharARB;
46 import org.lwjgl.util.generator.opengl.GLreturn;
4147
4248 import java.io.PrintWriter;
4349 import java.nio.Buffer;
7480 }
7581
7682 public static String getFunctionAddressName(InterfaceDeclaration interface_decl, MethodDeclaration method, boolean forceAlt) {
77 Alternate alt_annotation = method.getAnnotation(Alternate.class);
83 final Alternate alt_annotation = method.getAnnotation(Alternate.class);
84
85 /* Removed prefix so that we can identify reusable entry points, removed postfix because it's not needed and looks nicer.
86 String interfaceName = interface_decl.getSimpleName(); // If we add this back, we need to fix @Reuse (add a param for the template name)
7887 if ( alt_annotation == null || (alt_annotation.nativeAlt() && !forceAlt) )
79 return interface_decl.getSimpleName() + "_" + method.getSimpleName() + FUNCTION_POINTER_POSTFIX;
88 return interfaceName + "_" + method.getSimpleName() + FUNCTION_POINTER_POSTFIX;
8089 else
81 return interface_decl.getSimpleName() + "_" + alt_annotation.value() + FUNCTION_POINTER_POSTFIX;
90 return interfaceName + "_" + alt_annotation.value() + FUNCTION_POINTER_POSTFIX;
91 */
92 if ( alt_annotation == null || (alt_annotation.nativeAlt() && !forceAlt) )
93 return method.getSimpleName();
94 else
95 return alt_annotation.value();
8296 }
8397
8498 public static boolean isFinal(InterfaceDeclaration d) {
114128 }
115129
116130 public static boolean isAddressableType(Class type) {
117 return Buffer.class.isAssignableFrom(type) || String.class.equals(type) || CharSequence.class.equals(type) || CharSequence[].class.equals(type);
131 if ( type.isArray() ) {
132 final Class component_type = type.getComponentType();
133 return isAddressableTypeImpl(component_type) || org.lwjgl.PointerWrapper.class.isAssignableFrom(component_type);
134 }
135 return isAddressableTypeImpl(type);
136 }
137
138 private static boolean isAddressableTypeImpl(Class type) {
139 return Buffer.class.isAssignableFrom(type) || PointerBuffer.class.isAssignableFrom(type) || CharSequence.class.isAssignableFrom(type);
118140 }
119141
120142 public static Class getJavaType(TypeMirror type_mirror) {
146168 }
147169
148170 public static void printDocComment(PrintWriter writer, Declaration decl) {
171 final String overloadsComment;
172 if ( (decl instanceof MethodDeclaration) && decl.getAnnotation(Alternate.class) != null )
173 overloadsComment = "Overloads " + decl.getAnnotation(Alternate.class).value() + ".";
174 else
175 overloadsComment = null;
176
149177 String doc_comment = decl.getDocComment();
150178 if (doc_comment != null) {
151 String tab = decl instanceof InterfaceDeclaration ? "" : "\t";
179 final String tab = decl instanceof InterfaceDeclaration ? "" : "\t";
152180 writer.println(tab + "/**");
153 StringTokenizer doc_lines = new StringTokenizer(doc_comment, "\n");
154 while (doc_lines.hasMoreTokens())
155 writer.println(tab + " * " + doc_lines.nextToken());
181
182 if ( overloadsComment != null ) {
183 writer.println("\t * " + overloadsComment);
184 writer.println("\t * <p>");
185 }
186
187 final StringTokenizer doc_lines = new StringTokenizer(doc_comment, "\n", true);
188 boolean lastWasNL = false;
189 while (doc_lines.hasMoreTokens()) {
190 final String t = doc_lines.nextToken();
191 if ( "\n".equals(t) ) {
192 if ( lastWasNL )
193 writer.println(tab + " * <p>");
194 lastWasNL = true;
195 } else {
196 writer.println(tab + " * " + t);
197 lastWasNL = false;
198 }
199 }
200
156201 writer.println(tab + " */");
157 } else if ( (decl instanceof MethodDeclaration) && decl.getAnnotation(Alternate.class) != null )
158 writer.println("\t/** Overloads " + decl.getAnnotation(Alternate.class).value() + " */");
202 } else if ( overloadsComment != null )
203 writer.println("\t/** " + overloadsComment + " */");
159204 }
160205
161206 public static AnnotationMirror getParameterAutoAnnotation(ParameterDeclaration param) {
240285 }
241286
242287 public static boolean needResultSize(MethodDeclaration method) {
243 return getNIOBufferType(getMethodReturnType(method)) != null && method.getAnnotation(AutoResultSize.class) == null;
288 return getNIOBufferType(getMethodReturnType(method)) != null && method.getAnnotation(AutoSize.class) == null;
244289 }
245290
246291 public static void printExtraCallArguments(PrintWriter writer, MethodDeclaration method, String size_parameter_name) {
288333 Class<?> param_type = getJavaType(t);
289334 if (Buffer.class.isAssignableFrom(param_type))
290335 return param_type;
291 else if ( param_type == CharSequence.class || param_type == CharSequence[].class )
336 else if ( param_type == CharSequence.class || param_type == CharSequence[].class || param_type == PointerBuffer.class )
292337 return ByteBuffer.class;
293338 else
294339 return null;
336381
337382 } else if ( type.equals(CharSequence[].class) ) {
338383 if ( offset == null )
339 offset = "APIUtils.getTotalLength(" + p.getSimpleName() + ")";
384 offset = "APIUtil.getTotalLength(" + p.getSimpleName() + ")";
340385 else
341 offset += " + APIUtils.getTotalLength(" + p.getSimpleName() + ")";
386 offset += " + APIUtil.getTotalLength(" + p.getSimpleName() + ")";
342387 if ( p.getAnnotation(NullTerminated.class) != null ) offset += " + " + p.getSimpleName() + ".length";
343388 }
344389
351396
352397 if ( "String".equals(return_type) ) {
353398 if ( !return_annotation.forceMaxLength() ) {
354 writer.println("IntBuffer " + return_annotation.value() + "_length = APIUtils.getLengths();");
399 writer.println("IntBuffer " + return_annotation.value() + "_length = APIUtil.getLengths();");
355400 writer.print("\t\t");
356401 }
357 writer.print("ByteBuffer " + return_annotation.value() + " = APIUtils.getBufferByte(" + return_annotation.maxLength());
402 writer.print("ByteBuffer " + return_annotation.value() + " = APIUtil.getBufferByte(" + return_annotation.maxLength());
358403 /*
359404 Params that use the return buffer will advance its position while filling it. When we return, the position will be
360405 at the right spot for grabbing the returned string bytes. We only have to make sure that the original buffer was
366411 writer.println(");");
367412 } else {
368413 final String buffer_type = "Boolean".equals(return_type) ? "Byte" : return_type;
369 writer.print(buffer_type + "Buffer " + return_annotation.value() + " = APIUtils.getBuffer" + buffer_type + "(");
414 writer.print(buffer_type + "Buffer " + return_annotation.value() + " = APIUtil.getBuffer" + buffer_type + "(");
370415 if ( "Byte".equals(buffer_type) )
371416 writer.print('1');
372417 writer.println(");");
373418 }
374419
375 writer.print("\t\t");
420 final Code code_annotation = method.getAnnotation(Code.class);
421 if ( code_annotation != null && code_annotation.tryBlock() ) {
422 writer.println("\t\ttry {");
423 writer.print("\t\t\t");
424 } else
425 writer.print("\t\t");
376426 }
377427
378428 static void printGLReturnPost(PrintWriter writer, MethodDeclaration method, GLreturn return_annotation) {
388438 else
389439 writer.print(return_annotation.value() + "_length.get(0)");
390440 writer.println(");");
391 writer.println("\t\treturn APIUtils.getString(" + return_annotation.value() + ");");
441 writer.println("\t\treturn APIUtil.getString(" + return_annotation.value() + ");");
392442 } else {
393443 writer.print("\t\treturn " + return_annotation.value() + ".get(0)");
394444 if ( "Boolean".equals(return_type) )
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 package org.lwjgl.util.generator.openal;
33
34 /**
35 *
36 * The OpenAL specific generator behaviour
37 *
38 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 2983 $
40 * $Id: ALTypeMap.java 2983 2008-04-07 18:36:09Z matzon $
41 */
42
43 import org.lwjgl.util.generator.Signedness;
44 import org.lwjgl.util.generator.TypeMap;
45
46 import com.sun.mirror.declaration.*;
47 import com.sun.mirror.type.*;
48
49 import java.io.*;
50 import java.lang.annotation.Annotation;
51 import java.util.*;
52 import java.nio.*;
53
54 public class ALTypeMap implements TypeMap {
55 private static final Map<Class, PrimitiveType.Kind> native_types_to_primitive;
56
57 static {
58 native_types_to_primitive = new HashMap<Class, PrimitiveType.Kind>();
59 native_types_to_primitive.put(ALboolean.class, PrimitiveType.Kind.BOOLEAN);
60 native_types_to_primitive.put(ALbyte.class, PrimitiveType.Kind.BYTE);
61 native_types_to_primitive.put(ALenum.class, PrimitiveType.Kind.INT);
62 native_types_to_primitive.put(ALfloat.class, PrimitiveType.Kind.FLOAT);
63 native_types_to_primitive.put(ALdouble.class, PrimitiveType.Kind.DOUBLE);
64 native_types_to_primitive.put(ALint.class, PrimitiveType.Kind.INT);
65 native_types_to_primitive.put(ALshort.class, PrimitiveType.Kind.SHORT);
66 native_types_to_primitive.put(ALsizei.class, PrimitiveType.Kind.INT);
67 native_types_to_primitive.put(ALubyte.class, PrimitiveType.Kind.BYTE);
68 native_types_to_primitive.put(ALuint.class, PrimitiveType.Kind.INT);
69 native_types_to_primitive.put(ALvoid.class, PrimitiveType.Kind.BYTE);
70 }
71
72 public PrimitiveType.Kind getPrimitiveTypeFromNativeType(Class native_type) {
73 PrimitiveType.Kind kind = native_types_to_primitive.get(native_type);
74 if (kind == null)
75 throw new RuntimeException("Unsupported type " + native_type);
76 return kind;
77 }
78
79 public Signedness getSignednessFromType(Class type) {
80 if (ALuint.class.equals(type))
81 return Signedness.UNSIGNED;
82 else if (ALint.class.equals(type))
83 return Signedness.SIGNED;
84 else if (ALshort.class.equals(type))
85 return Signedness.SIGNED;
86 else if (ALbyte.class.equals(type))
87 return Signedness.SIGNED;
88 else
89 return Signedness.NONE;
90 }
91
92 public String translateAnnotation(Class annotation_type) {
93 if (annotation_type.equals(ALuint.class))
94 return "i";
95 else if (annotation_type.equals(ALint.class))
96 return "i";
97 else if (annotation_type.equals(ALshort.class))
98 return "s";
99 else if (annotation_type.equals(ALbyte.class))
100 return "b";
101 else if (annotation_type.equals(ALfloat.class))
102 return "f";
103 else if (annotation_type.equals(ALdouble.class))
104 return "d";
105 else if (annotation_type.equals(ALboolean.class) || annotation_type.equals(ALvoid.class))
106 return "";
107 else
108 throw new RuntimeException(annotation_type + " is not allowed");
109 }
110
111 public Class getNativeTypeFromPrimitiveType(PrimitiveType.Kind kind) {
112 Class type;
113 switch (kind) {
114 case INT:
115 type = ALint.class;
116 break;
117 case FLOAT:
118 type = ALfloat.class;
119 break;
120 case DOUBLE:
121 type = ALdouble.class;
122 break;
123 case SHORT:
124 type = ALshort.class;
125 break;
126 case BYTE:
127 type = ALbyte.class;
128 break;
129 case BOOLEAN:
130 type = ALboolean.class;
131 break;
132 default:
133 throw new RuntimeException(kind + " is not allowed");
134 }
135 return type;
136 }
137
138 private static Class[] getValidBufferTypes(Class type) {
139 if (type.equals(IntBuffer.class))
140 return new Class[]{ALenum.class, ALint.class, ALsizei.class, ALuint.class};
141 else if (type.equals(FloatBuffer.class))
142 return new Class[]{ALfloat.class};
143 else if (type.equals(ByteBuffer.class))
144 return new Class[]{ALboolean.class, ALbyte.class, ALvoid.class};
145 else if (type.equals(ShortBuffer.class))
146 return new Class[]{ALshort.class};
147 else if (type.equals(DoubleBuffer.class))
148 return new Class[]{ALdouble.class};
149 else
150 return new Class[]{};
151 }
152
153 private static Class[] getValidPrimitiveTypes(Class type) {
154 if (type.equals(int.class))
155 return new Class[]{ALenum.class, ALint.class, ALsizei.class, ALuint.class};
156 else if (type.equals(double.class))
157 return new Class[]{ALdouble.class};
158 else if (type.equals(float.class))
159 return new Class[]{ALfloat.class};
160 else if (type.equals(short.class))
161 return new Class[]{ALshort.class};
162 else if (type.equals(byte.class))
163 return new Class[]{ALbyte.class};
164 else if (type.equals(boolean.class))
165 return new Class[]{ALboolean.class};
166 else if (type.equals(void.class))
167 return new Class[]{ALvoid.class};
168 else
169 return new Class[]{};
170 }
171
172 public void printCapabilitiesInit(final PrintWriter writer) {
173 throw new UnsupportedOperationException();
174 }
175
176 public String getCapabilities() {
177 throw new UnsupportedOperationException();
178 }
179
180 public void printErrorCheckMethod(final PrintWriter writer, final MethodDeclaration method, final String tabs) {
181 writer.println(tabs + "Util.checkALError();");
182 }
183
184 public String getRegisterNativesFunctionName() {
185 return "extal_InitializeClass";
186 }
187
188 public String getTypedefPostfix() {
189 return "";
190 }
191
192 public String getFunctionPrefix() {
193 return "ALAPIENTRY";
194 }
195
196 public void printNativeIncludes(PrintWriter writer) {
197 writer.println("#include \"extal.h\"");
198 }
199
200 public Class<? extends Annotation> getStringElementType() {
201 return ALubyte.class;
202 }
203
204 public Class<? extends Annotation> getStringArrayType() {
205 return ALubyte.class;
206 }
207
208 public Class<? extends Annotation> getByteBufferArrayType() {
209 return ALubyte.class;
210 }
211
212 public Class[] getValidAnnotationTypes(Class type) {
213 Class[] valid_types;
214 if (Buffer.class.isAssignableFrom(type))
215 valid_types = getValidBufferTypes(type);
216 else if (type.isPrimitive())
217 valid_types = getValidPrimitiveTypes(type);
218 else if (type.equals(String.class))
219 valid_types = new Class[]{ALubyte.class};
220 else
221 valid_types = new Class[]{};
222 return valid_types;
223 }
224
225 public Class<? extends Annotation> getVoidType() {
226 return ALvoid.class;
227 }
228
229 public Class<? extends Annotation> getInverseType(Class type) {
230 if (ALuint.class.equals(type))
231 return ALint.class;
232 else if (ALint.class.equals(type))
233 return ALuint.class;
234 else
235 return null;
236 }
237
238 public String getAutoTypeFromAnnotation(AnnotationMirror annotation) {
239 return null;
240 }
241 }
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.openal;
32
33 /**
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2983 $
37 * $Id: ALboolean.java 2983 2008-04-07 18:36:09Z matzon $
38 */
39
40 import org.lwjgl.util.generator.NativeType;
41
42 import java.lang.annotation.Target;
43 import java.lang.annotation.ElementType;
44
45 @NativeType
46 @Target({ElementType.PARAMETER, ElementType.METHOD})
47 public @interface ALboolean {
48 }
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.openal;
32
33 /**
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2983 $
37 * $Id: ALbyte.java 2983 2008-04-07 18:36:09Z matzon $
38 */
39
40 import org.lwjgl.util.generator.NativeType;
41
42 import java.lang.annotation.Target;
43 import java.lang.annotation.ElementType;
44
45 @NativeType
46 @Target({ElementType.PARAMETER, ElementType.METHOD})
47 public @interface ALbyte {
48 }
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.openal;
32
33 /**
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2983 $
37 * $Id: ALdouble.java 2983 2008-04-07 18:36:09Z matzon $
38 */
39
40 import org.lwjgl.util.generator.NativeType;
41
42 import java.lang.annotation.Target;
43 import java.lang.annotation.ElementType;
44
45 @NativeType
46 @Target({ElementType.PARAMETER, ElementType.METHOD})
47 public @interface ALdouble {
48 }
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.openal;
32
33 /**
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2983 $
37 * $Id: ALenum.java 2983 2008-04-07 18:36:09Z matzon $
38 */
39
40 import org.lwjgl.util.generator.NativeType;
41
42 import java.lang.annotation.Target;
43 import java.lang.annotation.ElementType;
44
45 @NativeType
46 @Target({ElementType.PARAMETER, ElementType.METHOD})
47 public @interface ALenum {
48 }
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.openal;
32
33 /**
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2983 $
37 * $Id: ALfloat.java 2983 2008-04-07 18:36:09Z matzon $
38 */
39
40 import org.lwjgl.util.generator.NativeType;
41
42 import java.lang.annotation.Target;
43 import java.lang.annotation.ElementType;
44
45 @NativeType
46 @Target({ElementType.PARAMETER, ElementType.METHOD})
47 public @interface ALfloat {
48 }
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.openal;
32
33 /**
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2983 $
37 * $Id: ALint.java 2983 2008-04-07 18:36:09Z matzon $
38 */
39
40 import org.lwjgl.util.generator.NativeType;
41
42 import java.lang.annotation.Target;
43 import java.lang.annotation.ElementType;
44
45 @NativeType
46 @Target({ElementType.PARAMETER, ElementType.METHOD})
47 public @interface ALint {
48 }
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.openal;
32
33 /**
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2983 $
37 * $Id: ALshort.java 2983 2008-04-07 18:36:09Z matzon $
38 */
39
40 import org.lwjgl.util.generator.NativeType;
41
42 import java.lang.annotation.Target;
43 import java.lang.annotation.ElementType;
44
45 @NativeType
46 @Target({ElementType.PARAMETER, ElementType.METHOD})
47 public @interface ALshort {
48 }
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.openal;
32
33 /**
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2983 $
37 * $Id: ALsizei.java 2983 2008-04-07 18:36:09Z matzon $
38 */
39
40 import org.lwjgl.util.generator.NativeType;
41
42 import java.lang.annotation.Target;
43 import java.lang.annotation.ElementType;
44
45 @NativeType
46 @Target({ElementType.PARAMETER, ElementType.METHOD})
47 public @interface ALsizei {
48 }
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.openal;
32
33 /**
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2983 $
37 * $Id: ALubyte.java 2983 2008-04-07 18:36:09Z matzon $
38 */
39
40 import org.lwjgl.util.generator.NativeType;
41
42 import java.lang.annotation.Target;
43 import java.lang.annotation.ElementType;
44
45 @NativeType
46 @Target({ElementType.PARAMETER, ElementType.METHOD})
47 public @interface ALubyte {
48 }
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.openal;
32
33 /**
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2983 $
37 * $Id: ALuint.java 2983 2008-04-07 18:36:09Z matzon $
38 */
39
40 import org.lwjgl.util.generator.NativeType;
41
42 import java.lang.annotation.Target;
43 import java.lang.annotation.ElementType;
44
45 @NativeType
46 @Target({ElementType.PARAMETER, ElementType.METHOD})
47 public @interface ALuint {
48 }
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.openal;
32
33 /**
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2983 $
37 * $Id: ALvoid.java 2983 2008-04-07 18:36:09Z matzon $
38 */
39
40 import org.lwjgl.util.generator.NativeType;
41
42 import java.lang.annotation.Target;
43 import java.lang.annotation.ElementType;
44
45 @NativeType
46 @Target({ElementType.PARAMETER, ElementType.METHOD})
47 public @interface ALvoid {
48 }
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 package org.lwjgl.util.generator.opencl;
33
34 import org.lwjgl.util.generator.*;
35
36 import java.io.PrintWriter;
37 import java.util.Collection;
38 import java.util.Iterator;
39
40 import com.sun.mirror.declaration.InterfaceDeclaration;
41 import com.sun.mirror.declaration.MethodDeclaration;
42 import com.sun.mirror.declaration.TypeDeclaration;
43
44 /**
45 * CLCapabilities generator.
46 *
47 * @author Spasi
48 */
49 public class CLCapabilitiesGenerator {
50
51 static void generateClassPrologue(final PrintWriter writer) {
52 writer.println("public final class " + CLGeneratorProcessorFactory.CLCAPS_CLASS_NAME + " {");
53 writer.println();
54 }
55
56 static void generateSymbolAddresses(final PrintWriter writer, final InterfaceDeclaration d) {
57 final Alias alias_annotation = d.getAnnotation(Alias.class);
58 final boolean aliased = alias_annotation != null && alias_annotation.postfix().length() > 0;
59
60 boolean foundNative = false;
61 for ( final MethodDeclaration method : d.getMethods() ) {
62 if ( method.getAnnotation(Alternate.class) != null || method.getAnnotation(Reuse.class) != null )
63 continue;
64
65 if ( !foundNative ) {
66 //writer.println("\t// " + d.getSimpleName());
67 writer.println("\tstatic final boolean " + CLGeneratorProcessorFactory.getExtensionName(d.getSimpleName()) + ";");
68 foundNative = true;
69 }
70 writer.print("\tstatic final long " + Utils.getFunctionAddressName(d, method) + " = CL.getFunctionAddress(");
71
72 if ( aliased )
73 writer.println("new String [] {\"" + Utils.getFunctionAddressName(d, method) + "\",\"" + method.getSimpleName() + alias_annotation.postfix() + "\"});");
74 else
75 writer.println("\"" + Utils.getFunctionAddressName(d, method) + "\");");
76 }
77
78 if ( foundNative )
79 writer.println();
80 }
81
82 static void generateConstructor(final PrintWriter writer, final Collection<TypeDeclaration> interface_decls) {
83 writer.println("\tprivate " + CLGeneratorProcessorFactory.CLCAPS_CLASS_NAME + "() {}");
84 writer.println();
85 writer.println("\tstatic {");
86
87 for ( final TypeDeclaration d : interface_decls ) {
88 if ( d.getMethods().isEmpty() )
89 continue;
90
91 //writer.println("\t\tif ( " + getExtensionSupportedName(d.getSimpleName()) + "() )");
92 //writer.println("\t\t\t" + SUPPORTED_EXTS + ".add(\"" + CLGeneratorProcessorFactory.getExtensionName(d.getSimpleName()) + "\");");
93 writer.println("\t\t" + CLGeneratorProcessorFactory.getExtensionName(d.getSimpleName()) + " = " + getExtensionSupportedName(d.getSimpleName()) + "();");
94 }
95
96 writer.println("\t}\n");
97 }
98
99 static void generateExtensionChecks(final PrintWriter writer, final InterfaceDeclaration d) {
100 Iterator<? extends MethodDeclaration> methods = d.getMethods().iterator();
101 if ( !methods.hasNext() )
102 return;
103
104 writer.println("\tprivate static boolean " + getExtensionSupportedName(d.getSimpleName()) + "() {");
105 writer.println("\t\treturn ");
106
107 boolean first = true;
108 while ( methods.hasNext() ) {
109 MethodDeclaration method = methods.next();
110 if ( method.getAnnotation(Alternate.class) != null )
111 continue;
112
113 if ( !first )
114 writer.println(" &");
115 else
116 first = false;
117
118 final boolean optional = method.getAnnotation(Optional.class) != null;
119
120 writer.print("\t\t\t");
121 if ( optional )
122 writer.print('(');
123 writer.print(Utils.getFunctionAddressName(d, method) + " != 0");
124 if ( optional )
125 writer.print(" || true)");
126 }
127 writer.println(";");
128 writer.println("\t}");
129 writer.println();
130 }
131
132 private static String getExtensionSupportedName(final String class_name) {
133 return "is" + class_name + "Supported";
134 }
135
136 public static void generateCapabilitiesGetters(final PrintWriter writer) {
137 writer.println("\tpublic static CLPlatformCapabilities getPlatformCapabilities(final CLPlatform platform) {\n" +
138 "\t\tplatform.checkValid();\n" +
139 "\n" +
140 "\t\tCLPlatformCapabilities caps = (CLPlatformCapabilities)platform.getCapabilities();\n" +
141 "\t\tif ( caps == null )\n" +
142 "\t\t\tplatform.setCapabilities(caps = new CLPlatformCapabilities(platform));\n" +
143 "\n" +
144 "\t\treturn caps;\n" +
145 "\t}\n");
146
147 writer.println("\tpublic static CLDeviceCapabilities getDeviceCapabilities(final CLDevice device) {\n" +
148 "\t\tdevice.checkValid();\n" +
149 "\n" +
150 "\t\tCLDeviceCapabilities caps = (CLDeviceCapabilities)device.getCapabilities();\n" +
151 "\t\tif ( caps == null )\n" +
152 "\t\t\tdevice.setCapabilities(caps = new CLDeviceCapabilities(device));\n" +
153 "\n" +
154 "\t\treturn caps;\n" +
155 "\t}\n");
156
157 }
158 }
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.util.generator.opencl;
32
33 import java.lang.annotation.ElementType;
34 import java.lang.annotation.Target;
35
36 /** Extension templates marked with @CLDeviceExtension will be considered CL device extensions. */
37 @Target(ElementType.TYPE)
38 public @interface CLDeviceExtension {
39
40 }
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 package org.lwjgl.util.generator.opencl;
33
34 import org.lwjgl.PointerWrapper;
35 import org.lwjgl.opencl.CLDevice;
36 import org.lwjgl.opencl.CLPlatform;
37
38 import java.io.File;
39 import java.io.IOException;
40 import java.io.PrintWriter;
41 import java.lang.annotation.Annotation;
42 import java.util.Arrays;
43 import java.util.Collection;
44 import java.util.Set;
45
46 import com.sun.mirror.apt.*;
47 import com.sun.mirror.declaration.AnnotationTypeDeclaration;
48 import com.sun.mirror.declaration.InterfaceDeclaration;
49 import com.sun.mirror.declaration.TypeDeclaration;
50 import com.sun.mirror.util.DeclarationFilter;
51
52 import static java.util.Collections.*;
53
54 /**
55 * Generator tool for creating the OpenCL capabilities classes
56 *
57 * @author Spasi
58 */
59 public class CLGeneratorProcessorFactory implements AnnotationProcessorFactory, RoundCompleteListener {
60
61 public static final String CLCAPS_CLASS_NAME = "CLCapabilities";
62 public static final String PLATFORM_CAPS_CLASS_NAME = "CLPlatformCapabilities";
63 public static final String DEVICE_CAPS_CLASS_NAME = "CLDeviceCapabilities";
64
65 private static final String EXTENSION_PREFIX = "CL_";
66 private static final String CORE_PREFIX = "Open";
67
68 private static boolean first_round = true;
69
70 // Process any set of annotations
71 private static final Collection<String> supportedAnnotations = unmodifiableCollection(Arrays.asList("*"));
72
73 public Collection<String> supportedAnnotationTypes() {
74 return supportedAnnotations;
75 }
76
77 public Collection<String> supportedOptions() {
78 return unmodifiableCollection(Arrays.asList("-Acontextspecific"));
79 }
80
81 public void roundComplete(RoundCompleteEvent event) {
82 first_round = false;
83 }
84
85 public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds, AnnotationProcessorEnvironment env) {
86 // Only process the initial types, not the generated ones
87 if ( first_round ) {
88 env.addListener(this);
89 return new GeneratorProcessor(env);
90 } else
91 return AnnotationProcessors.NO_OP;
92 }
93
94 static String getExtensionName(String interface_name) {
95 if ( interface_name.startsWith("CL") )
96 return CORE_PREFIX + interface_name;
97 else
98 return EXTENSION_PREFIX + interface_name;
99 }
100
101 private static class GeneratorProcessor implements AnnotationProcessor {
102
103 private final AnnotationProcessorEnvironment env;
104
105 GeneratorProcessor(AnnotationProcessorEnvironment env) {
106 this.env = env;
107 }
108
109 public void process() {
110 try {
111 generateCLCapabilitiesSource();
112 generateCLPDCapabilitiesSource(CLPlatformExtension.class, PLATFORM_CAPS_CLASS_NAME, CLPlatform.class, "platform");
113 generateCLPDCapabilitiesSource(CLDeviceExtension.class, DEVICE_CAPS_CLASS_NAME, CLDevice.class, "device");
114 } catch (IOException e) {
115 throw new RuntimeException(e);
116 }
117 }
118
119 private static void printHeader(final PrintWriter writer) {
120 writer.println("/* MACHINE GENERATED FILE, DO NOT EDIT */");
121 writer.println();
122 writer.println("package org.lwjgl.opencl;");
123 writer.println();
124 }
125
126 private void generateCLCapabilitiesSource() throws IOException {
127 final PrintWriter writer = env.getFiler().createTextFile(Filer.Location.SOURCE_TREE, "org.lwjgl.opencl", new File(CLCAPS_CLASS_NAME + ".java"), null);
128 printHeader(writer);
129
130 CLCapabilitiesGenerator.generateClassPrologue(writer);
131
132 final Collection<TypeDeclaration> templates = DeclarationFilter.getFilter(InterfaceDeclaration.class).filter(env.getSpecifiedTypeDeclarations());
133
134 for ( final TypeDeclaration t : templates ) {
135 if ( t.getAnnotation(CLPlatformExtension.class) == null && t.getAnnotation(CLDeviceExtension.class) == null && !t.getSimpleName().startsWith("CL") )
136 throw new RuntimeException("An OpenCL extension is missing an extension type annotation: " + t.getSimpleName());
137
138 CLCapabilitiesGenerator.generateSymbolAddresses(writer, (InterfaceDeclaration)t);
139 }
140 writer.println();
141
142 CLCapabilitiesGenerator.generateConstructor(writer, templates);
143
144 CLCapabilitiesGenerator.generateCapabilitiesGetters(writer);
145
146 for ( final TypeDeclaration template : templates )
147 CLCapabilitiesGenerator.generateExtensionChecks(writer, (InterfaceDeclaration)template);
148
149 writer.println("}");
150 writer.close();
151 }
152
153 private void generateCLPDCapabilitiesSource(final Class<? extends Annotation> capsType, final String capsName, final Class<? extends PointerWrapper> objectType, final String objectName) throws IOException {
154 final PrintWriter writer = env.getFiler().createTextFile(Filer.Location.SOURCE_TREE, "org.lwjgl.opencl", new File(capsName + ".java"), null);
155 printHeader(writer);
156 writer.println("import java.util.*;");
157 writer.println();
158
159 CLPDCapabilitiesGenerator.generateClassPrologue(writer, capsName);
160
161 final Collection<TypeDeclaration> templates = DeclarationFilter.getFilter(InterfaceDeclaration.class).filter(env.getSpecifiedTypeDeclarations());
162
163 for ( final TypeDeclaration t : templates ) {
164 if ( t.getAnnotation(capsType) != null )
165 CLPDCapabilitiesGenerator.generateExtensions(writer, (InterfaceDeclaration)t);
166 }
167 writer.println();
168
169 CLPDCapabilitiesGenerator.generateConstructor(writer, templates, capsType, capsName, objectType, objectName);
170
171 CLPDCapabilitiesGenerator.generateGetters(writer);
172
173 CLPDCapabilitiesGenerator.generateToString(writer, templates, capsType);
174
175 writer.println("}");
176 writer.close();
177 }
178
179 }
180 }
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 package org.lwjgl.util.generator.opencl;
33
34 import org.lwjgl.PointerWrapper;
35 import org.lwjgl.util.generator.Private;
36
37 import java.io.PrintWriter;
38 import java.lang.annotation.Annotation;
39 import java.util.Collection;
40
41 import com.sun.mirror.declaration.InterfaceDeclaration;
42 import com.sun.mirror.declaration.TypeDeclaration;
43
44 /**
45 * CL platform/device capabilities generator.
46 *
47 * @author Spasi
48 */
49 public class CLPDCapabilitiesGenerator {
50
51 // TODO: Add future versions here
52 private static final int[][] CL_VERSIONS = {
53 { 1 }, // OpenCL 1
54 };
55
56 static void generateClassPrologue(final PrintWriter writer, final String name) {
57 writer.println("public class " + name + " {");
58 writer.println();
59 writer.println("\tpublic final int majorVersion;");
60 writer.println("\tpublic final int minorVersion;");
61 writer.println();
62 for ( int major = 1; major <= CL_VERSIONS.length; major++ ) {
63 for ( final int minor : CL_VERSIONS[major - 1] )
64 writer.println("\tpublic final boolean OpenCL" + Integer.toString(major) + Integer.toString(minor) + ";");
65 }
66 writer.println();
67 }
68
69 static void generateExtensions(final PrintWriter writer, final InterfaceDeclaration d) {
70 writer.print("\t");
71
72 if ( d.getAnnotation(Private.class) == null )
73 writer.print("public ");
74
75 writer.println("final boolean " + CLGeneratorProcessorFactory.getExtensionName(d.getSimpleName()) + ";");
76 }
77
78 static void generateConstructor(final PrintWriter writer, final Collection<TypeDeclaration> templates,
79 final Class<? extends Annotation> capsType, final String capsName,
80 final Class<? extends PointerWrapper> objectType, final String objectName) {
81 writer.println("\tpublic " + capsName + "(final " + objectType.getSimpleName() + ' ' + objectName + ") {");
82
83 writer.println("\t\tfinal String extensionList = " + objectName + ".getInfoString(CL10.CL_" + objectName.toUpperCase() + "_EXTENSIONS);\n" +
84 "\t\tfinal String version = " + objectName + ".getInfoString(CL10.CL_" + objectName.toUpperCase() + "_VERSION);\n" +
85 "\t\tif ( !version.startsWith(\"OpenCL \") )\n" +
86 "\t\t\tthrow new RuntimeException(\"Invalid OpenCL version string: \" + version);\n\n" +
87 "\t\ttry {\n" +
88 "\t\t\tfinal StringTokenizer tokenizer = new StringTokenizer(version.substring(7), \". \");\n" +
89 "\n" +
90 "\t\t\tmajorVersion = Integer.parseInt(tokenizer.nextToken());\n" +
91 "\t\t\tminorVersion = Integer.parseInt(tokenizer.nextToken());\n");
92
93 for ( int major = 1; major <= CL_VERSIONS.length; major++ ) {
94 for ( final int minor : CL_VERSIONS[major - 1] )
95 writer.println("\t\t\tOpenCL" + Integer.toString(major) + Integer.toString(minor) + " = " + major + " < majorVersion || (" + major + " == majorVersion && " + minor + " <= minorVersion);");
96 }
97
98 writer.println("\t\t} catch (RuntimeException e) {\n" +
99 "\t\t\tthrow new RuntimeException(\"The major and/or minor OpenCL version \\\"\" + version + \"\\\" is malformed: \" + e.getMessage());\n" +
100 "\t\t}\n");
101
102 writer.println("\t\tfinal Set<String> extensions = APIUtil.getExtensions(extensionList);");
103
104 for ( final TypeDeclaration t : templates ) {
105 if ( t.getAnnotation(capsType) == null )
106 continue;
107
108 final String extName = CLGeneratorProcessorFactory.getExtensionName(t.getSimpleName());
109
110 writer.print("\t\t" + extName + " = extensions.contains(\"" + extName.toLowerCase() + "\")");
111 if ( !t.getMethods().isEmpty() )
112 writer.print(" && CLCapabilities." + extName);
113 writer.println(";");
114 }
115
116 writer.println("\t}\n");
117 }
118
119 public static void generateGetters(final PrintWriter writer) {
120 writer.println("\tpublic int getMajorVersion() {");
121 writer.println("\t\treturn majorVersion;");
122 writer.println("\t}\n");
123
124 writer.println("\tpublic int getMinorVersion() {");
125 writer.println("\t\treturn minorVersion;");
126 writer.println("\t}\n");
127 }
128
129 public static void generateToString(final PrintWriter writer, final Collection<TypeDeclaration> templates, final Class<? extends Annotation> capsType) {
130 writer.println("\tpublic String toString() {");
131 writer.println("\t\tfinal StringBuilder buf = new StringBuilder();\n");
132
133 writer.println("\t\tbuf.append(\"OpenCL \").append(majorVersion).append('.').append(minorVersion);");
134 writer.println();
135 writer.println("\t\tbuf.append(\" - Extensions: \");");
136 for ( final TypeDeclaration t : templates ) {
137 if ( t.getAnnotation(capsType) == null )
138 continue;
139
140 writer.println("\t\tif ( " + CLGeneratorProcessorFactory.getExtensionName(t.getSimpleName()) + " ) buf.append(\"" + CLGeneratorProcessorFactory.getExtensionName(t.getSimpleName()).toLowerCase() + " \");");
141 }
142
143 writer.println("\n\t\treturn buf.toString();");
144 writer.println("\t}\n");
145 }
146
147 }
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.util.generator.opencl;
32
33 import java.lang.annotation.ElementType;
34 import java.lang.annotation.Target;
35
36 /** Extension templates marked with @CLPlatformExtension will be considered CL platform extensions. */
37 @Target(ElementType.TYPE)
38 public @interface CLPlatformExtension {
39
40 }
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
32 package org.lwjgl.util.generator.opencl;
33
34 /**
35 *
36 * OpenCL specific generator behaviour
37 *
38 * @author Spasi
39 */
40
41 import org.lwjgl.PointerBuffer;
42 import org.lwjgl.util.generator.*;
43 import org.lwjgl.util.generator.opengl.GLreturn;
44
45 import java.io.PrintWriter;
46 import java.lang.annotation.Annotation;
47 import java.nio.*;
48 import java.util.HashMap;
49 import java.util.Map;
50
51 import com.sun.mirror.declaration.AnnotationMirror;
52 import com.sun.mirror.declaration.MethodDeclaration;
53 import com.sun.mirror.declaration.ParameterDeclaration;
54 import com.sun.mirror.type.PrimitiveType;
55
56 public class CLTypeMap implements TypeMap {
57
58 private static final Map<Class, PrimitiveType.Kind> native_types_to_primitive;
59
60 static {
61 native_types_to_primitive = new HashMap<Class, PrimitiveType.Kind>();
62 native_types_to_primitive.put(cl_void.class, PrimitiveType.Kind.BYTE);
63 native_types_to_primitive.put(cl_byte.class, PrimitiveType.Kind.BYTE);
64 native_types_to_primitive.put(cl_char.class, PrimitiveType.Kind.BYTE);
65 native_types_to_primitive.put(cl_uchar.class, PrimitiveType.Kind.BYTE);
66 native_types_to_primitive.put(cl_short.class, PrimitiveType.Kind.SHORT);
67 native_types_to_primitive.put(cl_bool.class, PrimitiveType.Kind.INT);
68 native_types_to_primitive.put(cl_int.class, PrimitiveType.Kind.INT);
69 native_types_to_primitive.put(cl_uint.class, PrimitiveType.Kind.INT);
70 native_types_to_primitive.put(cl_long.class, PrimitiveType.Kind.LONG);
71 native_types_to_primitive.put(size_t.class, PrimitiveType.Kind.LONG);
72 native_types_to_primitive.put(cl_bitfield.class, PrimitiveType.Kind.LONG);
73 native_types_to_primitive.put(cl_float.class, PrimitiveType.Kind.FLOAT);
74 native_types_to_primitive.put(cl_double.class, PrimitiveType.Kind.DOUBLE);
75 }
76
77 public PrimitiveType.Kind getPrimitiveTypeFromNativeType(Class native_type) {
78 PrimitiveType.Kind kind = native_types_to_primitive.get(native_type);
79 if ( kind == null )
80 throw new RuntimeException("Unsupported type " + native_type);
81 return kind;
82 }
83
84 public void printCapabilitiesInit(final PrintWriter writer) {
85 }
86
87 public String getCapabilities() {
88 return "CLCapabilities";
89 }
90
91 public void printErrorCheckMethod(final PrintWriter writer, final MethodDeclaration method, final String tabs) {
92 final Check check = method.getAnnotation(Check.class);
93 if ( check != null ) // Get the error code from an IntBuffer output parameter
94 writer.println(tabs + "Util.checkCLError(" + check.value() + ".get(" + check.value() + ".position()));");
95 else {
96 final Class return_type = Utils.getJavaType(method.getReturnType());
97 if ( return_type == int.class )
98 writer.println(tabs + "Util.checkCLError(__result);");
99 else {
100 boolean hasErrCodeParam = false;
101 for ( final ParameterDeclaration param : method.getParameters() ) {
102 if ( "errcode_ret".equals(param.getSimpleName()) && Utils.getJavaType(param.getType()) == IntBuffer.class ) {
103 hasErrCodeParam = true;
104 break;
105 }
106 }
107 if ( hasErrCodeParam )
108 throw new RuntimeException("A method is missing the @Check annotation: " + method.toString());
109 }
110 }
111 }
112
113 public String getRegisterNativesFunctionName() {
114 return "extcl_InitializeClass";
115 }
116
117 public Signedness getSignednessFromType(Class type) {
118 if ( cl_uint.class.equals(type) )
119 return Signedness.UNSIGNED;
120 else if ( cl_int.class.equals(type) )
121 return Signedness.SIGNED;
122 else
123 return Signedness.NONE;
124 }
125
126 public String translateAnnotation(Class annotation_type) {
127 if ( annotation_type.equals(cl_uint.class) || annotation_type.equals(cl_int.class) )
128 return "i";
129 else if ( annotation_type.equals(cl_short.class) )
130 return "s";
131 else if ( annotation_type.equals(cl_byte.class) )
132 return "b";
133 else if ( annotation_type.equals(cl_float.class) )
134 return "f";
135 else if ( annotation_type.equals(cl_double.class) )
136 return "d";
137 else
138 throw new RuntimeException(annotation_type + " is not allowed");
139 }
140
141 public Class getNativeTypeFromPrimitiveType(PrimitiveType.Kind kind) {
142 Class type;
143 switch ( kind ) {
144 case INT:
145 type = cl_int.class;
146 break;
147 case DOUBLE:
148 type = cl_double.class;
149 break;
150 case FLOAT:
151 type = cl_float.class;
152 break;
153 case SHORT:
154 type = cl_short.class;
155 break;
156 case BYTE:
157 type = cl_byte.class;
158 break;
159 case LONG:
160 type = cl_long.class;
161 break;
162 case BOOLEAN:
163 type = cl_bool.class;
164 break;
165 default:
166 throw new RuntimeException(kind + " is not allowed");
167 }
168 return type;
169 }
170
171 public Class<? extends Annotation> getVoidType() {
172 return cl_void.class;
173 }
174
175 public Class<? extends Annotation> getStringElementType() {
176 return cl_char.class;
177 }
178
179 public Class<? extends Annotation> getStringArrayType() {
180 return cl_char.class;
181 }
182
183 public Class<? extends Annotation> getByteBufferArrayType() {
184 return cl_uchar.class;
185 }
186
187 private static Class[] getValidBufferTypes(Class type) {
188 if ( type.equals(IntBuffer.class) )
189 return new Class[] { cl_int.class, cl_uint.class };
190 else if ( type.equals(FloatBuffer.class) )
191 return new Class[] { cl_float.class };
192 else if ( type.equals(ByteBuffer.class) )
193 return new Class[] { cl_byte.class, cl_char.class, cl_uchar.class, cl_void.class };
194 else if ( type.equals(ShortBuffer.class) )
195 return new Class[] { cl_short.class };
196 else if ( type.equals(DoubleBuffer.class) )
197 return new Class[] { cl_double.class };
198 else if ( type.equals(LongBuffer.class) )
199 return new Class[] { cl_long.class };
200 else if ( type.equals(PointerBuffer.class) )
201 return new Class[] { size_t.class };
202 else
203 return new Class[] { };
204 }
205
206 private static Class[] getValidPrimitiveTypes(Class type) {
207 if ( type.equals(long.class) )
208 return new Class[] { cl_long.class, size_t.class, cl_bitfield.class };
209 else if ( type.equals(int.class) )
210 return new Class[] { cl_int.class, cl_uint.class, cl_bool.class };
211 else if ( type.equals(double.class) )
212 return new Class[] { cl_double.class };
213 else if ( type.equals(float.class) )
214 return new Class[] { cl_float.class };
215 else if ( type.equals(short.class) )
216 return new Class[] { cl_short.class };
217 else if ( type.equals(byte.class) )
218 return new Class[] { cl_byte.class, cl_char.class, cl_uchar.class };
219 else if ( type.equals(boolean.class) )
220 return new Class[] { cl_bool.class };
221 else if ( type.equals(void.class) )
222 return new Class[] { cl_void.class };
223 else
224 return new Class[] { };
225 }
226
227 public String getTypedefPostfix() {
228 return "CL_API_ENTRY ";
229 }
230
231 public String getFunctionPrefix() {
232 return "CL_API_CALL";
233 }
234
235 public void printNativeIncludes(PrintWriter writer) {
236 writer.println("#include \"extcl.h\"");
237 }
238
239 public Class[] getValidAnnotationTypes(Class type) {
240 Class[] valid_types;
241 if ( Buffer.class.isAssignableFrom(type) || PointerBuffer.class.isAssignableFrom(type) )
242 valid_types = getValidBufferTypes(type);
243 else if ( type.isPrimitive() )
244 valid_types = getValidPrimitiveTypes(type);
245 else if ( String.class.equals(type) )
246 valid_types = new Class[] { cl_byte.class };
247 else if ( org.lwjgl.PointerWrapper.class.isAssignableFrom(type) )
248 valid_types = new Class[] { PointerWrapper.class };
249 else if ( ByteBuffer[].class == type )
250 valid_types = new Class[] { cl_char.class, cl_uchar.class };
251 else if ( void.class.equals(type) )
252 valid_types = new Class[] { GLreturn.class };
253 else
254 valid_types = new Class[] { };
255 return valid_types;
256 }
257
258 public Class<? extends Annotation> getInverseType(Class type) {
259 return null;
260 }
261
262 public String getAutoTypeFromAnnotation(AnnotationMirror annotation) {
263 return null;
264 }
265 }
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.util.generator.opencl;
32
33 import org.lwjgl.util.generator.NativeType;
34
35 import java.lang.annotation.ElementType;
36 import java.lang.annotation.Target;
37
38 @NativeType
39 @Target({ ElementType.PARAMETER })
40 public @interface cl_bitfield {
41 String alias() default "";
42 }
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.util.generator.opencl;
32
33 import org.lwjgl.util.generator.NativeType;
34
35 import java.lang.annotation.ElementType;
36 import java.lang.annotation.Target;
37
38 @NativeType
39 @Target({ ElementType.PARAMETER })
40 public @interface cl_bool {
41
42 }
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.util.generator.opencl;
32
33 import org.lwjgl.util.generator.NativeType;
34
35 import java.lang.annotation.ElementType;
36 import java.lang.annotation.Target;
37
38 @NativeType
39 @Target({ ElementType.PARAMETER, ElementType.METHOD })
40 public @interface cl_byte {
41
42 }
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.util.generator.opencl;
32
33 import org.lwjgl.util.generator.NativeType;
34
35 import java.lang.annotation.ElementType;
36 import java.lang.annotation.Target;
37
38 @NativeType
39 @Target({ ElementType.PARAMETER })
40 public @interface cl_char {
41
42 }
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.util.generator.opencl;
32
33 import org.lwjgl.util.generator.NativeType;
34
35 import java.lang.annotation.ElementType;
36 import java.lang.annotation.Target;
37
38 @NativeType
39 @Target({ ElementType.PARAMETER, ElementType.METHOD })
40 public @interface cl_double {
41
42 }
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.util.generator.opencl;
32
33 import org.lwjgl.util.generator.NativeType;
34
35 import java.lang.annotation.ElementType;
36 import java.lang.annotation.Target;
37
38 @NativeType
39 @Target({ ElementType.PARAMETER, ElementType.METHOD })
40 public @interface cl_float {
41
42 }
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.util.generator.opencl;
32
33 import org.lwjgl.util.generator.NativeType;
34
35 import java.lang.annotation.ElementType;
36 import java.lang.annotation.Target;
37
38 @NativeType
39 @Target({ ElementType.PARAMETER, ElementType.METHOD })
40 public @interface cl_int {
41 }
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.util.generator.opencl;
32
33 import org.lwjgl.util.generator.NativeType;
34
35 import java.lang.annotation.ElementType;
36 import java.lang.annotation.Target;
37
38 @NativeType
39 @Target({ ElementType.PARAMETER })
40 public @interface cl_long {
41
42 }
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.util.generator.opencl;
32
33 import org.lwjgl.util.generator.NativeType;
34
35 import java.lang.annotation.ElementType;
36 import java.lang.annotation.Target;
37
38 @NativeType
39 @Target({ ElementType.PARAMETER, ElementType.METHOD })
40 public @interface cl_short {
41
42 }
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.util.generator.opencl;
32
33 import org.lwjgl.util.generator.NativeType;
34
35 import java.lang.annotation.ElementType;
36 import java.lang.annotation.Target;
37
38 @NativeType
39 @Target({ ElementType.PARAMETER })
40 public @interface cl_uchar {
41
42 }
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.util.generator.opencl;
32
33 import org.lwjgl.util.generator.NativeType;
34
35 import java.lang.annotation.ElementType;
36 import java.lang.annotation.Target;
37
38 @NativeType
39 @Target({ ElementType.PARAMETER, ElementType.METHOD })
40 public @interface cl_uint {
41 }
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.util.generator.opencl;
32
33 import org.lwjgl.util.generator.NativeType;
34
35 import java.lang.annotation.ElementType;
36 import java.lang.annotation.Target;
37
38 import com.sun.mirror.type.PrimitiveType;
39
40 @NativeType
41 @Target({ ElementType.PARAMETER, ElementType.METHOD })
42 public @interface cl_void {
43 PrimitiveType.Kind value() default PrimitiveType.Kind.BYTE;
44 }
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.util.generator.opencl;
32
33 import org.lwjgl.util.generator.NativeType;
34
35 import java.lang.annotation.ElementType;
36 import java.lang.annotation.Target;
37
38 @NativeType
39 @Target({ ElementType.PARAMETER })
40 public @interface size_t {
41
42 }
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 package org.lwjgl.util.generator.opengl;
33
34 import org.lwjgl.util.generator.*;
35
36 import java.io.PrintWriter;
37 import java.util.Arrays;
38 import java.util.Collection;
39 import java.util.EnumSet;
40 import java.util.Iterator;
41
42 import com.sun.mirror.declaration.InterfaceDeclaration;
43 import com.sun.mirror.declaration.MethodDeclaration;
44 import com.sun.mirror.type.InterfaceType;
45
46 /**
47 * Generator visitor for the context capabilities generator tool
48 *
49 * @author elias_naur <elias_naur@users.sourceforge.net>
50 * @version $Revision: 3355 $
51 * $Id: ContextCapabilitiesGenerator.java 3355 2010-05-27 22:56:29Z spasi $
52 */
53 public class GLCapabilitiesGenerator {
54
55 private static final String STUBS_LOADED_NAME = "loaded_stubs";
56 private static final String ALL_INIT_METHOD_NAME = "initAllStubs";
57 private static final String POINTER_INITIALIZER_POSTFIX = "_initNativeFunctionAddresses";
58 private static final String CACHED_EXTS_VAR_NAME = "supported_extensions";
59 private static final String PROFILE_MASK_VAR_NAME = "profileMask";
60 private static final String EXTENSION_PREFIX = "GL_";
61 private static final String CORE_PREFIX = "Open";
62
63 public static void generateClassPrologue(PrintWriter writer, boolean context_specific, boolean generate_error_checks) {
64 writer.println("public class " + Utils.CONTEXT_CAPS_CLASS_NAME + " {");
65 writer.println("\tstatic final boolean DEBUG = " + Boolean.toString(generate_error_checks) + ";");
66 writer.println("\tfinal StateTracker tracker = new StateTracker();");
67 writer.println();
68 if ( !context_specific ) {
69 writer.println("\tprivate static boolean " + STUBS_LOADED_NAME + " = false;");
70 }
71 }
72
73 public static void generateInitializerPrologue(PrintWriter writer) {
74 writer.println("\t" + Utils.CONTEXT_CAPS_CLASS_NAME + "(boolean forwardCompatible) throws LWJGLException {");
75 writer.println("\t\tSet<String> " + CACHED_EXTS_VAR_NAME + " = " + ALL_INIT_METHOD_NAME + "(forwardCompatible);");
76 }
77
78 private static String translateFieldName(String interface_name) {
79 if ( interface_name.startsWith("GL") )
80 return CORE_PREFIX + interface_name;
81 else
82 return EXTENSION_PREFIX + interface_name;
83 }
84
85 public static void generateSuperClassAdds(PrintWriter writer, InterfaceDeclaration d) {
86 Collection<InterfaceType> super_interfaces = d.getSuperinterfaces();
87 if ( super_interfaces.size() > 1 )
88 throw new RuntimeException(d + " extends more than one other interface");
89 if ( super_interfaces.size() == 1 ) {
90 InterfaceType super_interface = super_interfaces.iterator().next();
91 writer.print("\t\tif (" + CACHED_EXTS_VAR_NAME + ".contains(\"");
92 writer.println(translateFieldName(d.getSimpleName()) + "\"))");
93 writer.print("\t\t\t");
94 generateAddExtension(writer, super_interface.getDeclaration());
95 }
96 }
97
98 public static void generateInitializer(PrintWriter writer, InterfaceDeclaration d) {
99 String translated_field_name = translateFieldName(d.getSimpleName());
100 writer.print("\t\tthis." + translated_field_name + " = ");
101 writer.print(CACHED_EXTS_VAR_NAME + ".contains(\"");
102 writer.print(translated_field_name + "\")");
103 Collection<InterfaceType> super_interfaces = d.getSuperinterfaces();
104 if ( super_interfaces.size() > 1 )
105 throw new RuntimeException(d + " extends more than one other interface");
106 if ( super_interfaces.size() == 1 ) {
107 InterfaceType super_interface = super_interfaces.iterator().next();
108 writer.println();
109 writer.print("\t\t\t&& " + CACHED_EXTS_VAR_NAME + ".contains(\"");
110 writer.print(translateFieldName(super_interface.getDeclaration().getSimpleName()) + "\")");
111 }
112 Alias alias_annotation = d.getAnnotation(Alias.class);
113 if ( alias_annotation != null ) {
114 writer.println();
115 writer.print("\t\t\t|| " + CACHED_EXTS_VAR_NAME + ".contains(\"");
116 writer.print(translateFieldName(alias_annotation.value()) + "\")");
117 }
118 writer.println(";");
119 }
120
121 private static String getAddressesInitializerName(String class_name) {
122 return class_name + POINTER_INITIALIZER_POSTFIX;
123 }
124
125 public static void generateInitStubsPrologue(PrintWriter writer, boolean context_specific) {
126 writer.println("\tprivate Set<String> " + ALL_INIT_METHOD_NAME + "(boolean forwardCompatible) throws LWJGLException {");
127
128 // Load the basic pointers we need to detect OpenGL version and supported extensions.
129 writer.println("\t\tglGetError = GLContext.getFunctionAddress(\"glGetError\");");
130 writer.println("\t\tglGetString = GLContext.getFunctionAddress(\"glGetString\");");
131
132 // Initialize GL11.glGetIntegerv and GL30.glGetStringi here, in case we have created an OpenGL 3.0 context.
133 // (they will be used in GLContext.getSupportedExtensions)
134 writer.println("\t\tglGetIntegerv = GLContext.getFunctionAddress(\"glGetIntegerv\");");
135 writer.println("\t\tglGetStringi = GLContext.getFunctionAddress(\"glGetStringi\");");
136
137 // Get the supported extensions set.
138 writer.println("\t\tGLContext.setCapabilities(this);");
139 writer.println("\t\tSet<String> " + CACHED_EXTS_VAR_NAME + " = new HashSet<String>(256);");
140 writer.println("\t\tint " + PROFILE_MASK_VAR_NAME + " = GLContext.getSupportedExtensions(" + CACHED_EXTS_VAR_NAME + ");");
141
142 // Force forward compatible mode when OpenGL version is 3.1 or higher and ARB_compatibility is not available.
143 writer.println("\t\tif ( supported_extensions.contains(\"OpenGL31\") && !(supported_extensions.contains(\"GL_ARB_compatibility\") || (profileMask & GL32.GL_CONTEXT_COMPATIBILITY_PROFILE_BIT) != 0) )");
144 writer.println("\t\t\tforwardCompatible = true;");
145
146 if ( !context_specific ) {
147 writer.println("\t\tif (" + STUBS_LOADED_NAME + ")");
148 writer.println("\t\t\treturn GLContext.getSupportedExtensions();");
149 writer.println("\t\torg.lwjgl.opengl.GL11." + Utils.STUB_INITIALIZER_NAME + "();");
150 } else {
151 writer.println("\t\tif (!" + getAddressesInitializerName("GL11") + "(forwardCompatible))");
152 writer.println("\t\t\tthrow new LWJGLException(\"GL11 not supported\");");
153 }
154 }
155
156 public static void generateInitStubsEpilogue(PrintWriter writer, boolean context_specific) {
157 if ( !context_specific ) {
158 writer.println("\t\t" + STUBS_LOADED_NAME + " = true;");
159 }
160 writer.println("\t\treturn " + CACHED_EXTS_VAR_NAME + ";");
161 writer.println("\t}");
162 }
163
164 public static void generateUnloadStubs(PrintWriter writer, InterfaceDeclaration d) {
165 if ( d.getMethods().size() > 0 ) {
166 writer.print("\t\tGLContext.resetNativeStubs(" + Utils.getSimpleClassName(d));
167 writer.println(".class);");
168 }
169 }
170
171 public static void generateInitStubs(PrintWriter writer, InterfaceDeclaration d, boolean context_specific) {
172 if ( d.getMethods().size() > 0 ) {
173 if ( context_specific ) {
174 final Alias alias_annotation = d.getAnnotation(Alias.class);
175
176 if ( d.getAnnotation(ForceInit.class) != null )
177 writer.println("\t\t" + CACHED_EXTS_VAR_NAME + ".add(\"" + translateFieldName(d.getSimpleName()) + "\");");
178 writer.print("\t\tif (");
179 if ( alias_annotation != null )
180 writer.print("(");
181 writer.print(CACHED_EXTS_VAR_NAME + ".contains(\"");
182 writer.print(translateFieldName(d.getSimpleName()) + "\")");
183 if ( alias_annotation != null ) {
184 writer.print(" || " + CACHED_EXTS_VAR_NAME + ".contains(\"");
185 writer.print(translateFieldName(alias_annotation.value()) + "\"))");
186 }
187 writer.print(" && !" + getAddressesInitializerName(d.getSimpleName()) + "(");
188 if ( d.getAnnotation(DeprecatedGL.class) != null )
189 writer.print("forwardCompatible");
190 if ( d.getAnnotation(Dependent.class) != null ) {
191 if ( d.getAnnotation(DeprecatedGL.class) != null )
192 writer.print(",");
193 writer.print("supported_extensions");
194 }
195 if ( alias_annotation != null ) {
196 writer.println(")) {");
197 writer.print("\t\t\tremove(" + CACHED_EXTS_VAR_NAME + ", \"");
198 writer.println(translateFieldName(alias_annotation.value()) + "\");");
199 } else
200 writer.println("))");
201 writer.print("\t\t\tremove(" + CACHED_EXTS_VAR_NAME + ", \"");
202 writer.println(translateFieldName(d.getSimpleName()) + "\");");
203 if ( alias_annotation != null )
204 writer.println("\t\t}");
205 } else {
206 writer.print("\t\tGLContext." + Utils.STUB_INITIALIZER_NAME + "(" + Utils.getSimpleClassName(d));
207 writer.println(".class, " + CACHED_EXTS_VAR_NAME + ", \"" + translateFieldName(d.getSimpleName()) + "\");");
208 }
209 }
210 }
211
212 private static void generateAddExtension(PrintWriter writer, InterfaceDeclaration d) {
213 writer.print(CACHED_EXTS_VAR_NAME + ".add(\"");
214 writer.println(translateFieldName(d.getSimpleName()) + "\");");
215 }
216
217 public static void generateAddressesInitializers(PrintWriter writer, InterfaceDeclaration d) {
218 Iterator<? extends MethodDeclaration> methods = d.getMethods().iterator();
219 if ( !methods.hasNext() )
220 return;
221
222 writer.print("\tprivate boolean " + getAddressesInitializerName(d.getSimpleName()) + "(");
223
224 boolean optional;
225 boolean deprecated = d.getAnnotation(DeprecatedGL.class) != null;
226 Dependent dependent = d.getAnnotation(Dependent.class);
227 if ( deprecated )
228 writer.print("boolean forwardCompatible");
229 if ( dependent != null ) {
230 if ( deprecated )
231 writer.print(",");
232 writer.print("Set<String> supported_extensions");
233 }
234
235 Alias alias_annotation = d.getAnnotation(Alias.class);
236 boolean aliased = alias_annotation != null && alias_annotation.postfix().length() > 0;
237
238 writer.println(") {");
239 writer.println("\t\treturn ");
240
241 boolean first = true;
242 while ( methods.hasNext() ) {
243 MethodDeclaration method = methods.next();
244 if ( method.getAnnotation(Alternate.class) != null )
245 continue;
246
247 if ( !first )
248 writer.println(" &");
249 else
250 first = false;
251
252 optional = method.getAnnotation(Optional.class) != null;
253 deprecated = method.getAnnotation(DeprecatedGL.class) != null;
254 dependent = method.getAnnotation(Dependent.class);
255
256 writer.print("\t\t\t(");
257 if ( optional )
258 writer.print('(');
259 if ( deprecated )
260 writer.print("forwardCompatible || ");
261 if ( dependent != null ) {
262 if ( dependent.value().indexOf(',') == -1 )
263 writer.print("!supported_extensions.contains(\"" + dependent.value() + "\") || ");
264 else {
265 writer.print("!(false");
266 for ( String extension : dependent.value().split(",") )
267 writer.print(" || supported_extensions.contains(\"" + extension + "\")");
268 writer.print(") || ");
269 }
270 }
271 if ( deprecated || dependent != null )
272 writer.print('(');
273 writer.print(Utils.getFunctionAddressName(d, method) + " = ");
274 PlatformDependent platform_dependent = method.getAnnotation(PlatformDependent.class);
275 if ( platform_dependent != null ) {
276 EnumSet<Platform> platform_set = EnumSet.copyOf(Arrays.asList(platform_dependent.value()));
277 writer.print("GLContext.getPlatformSpecificFunctionAddress(\"");
278 writer.print(Platform.ALL.getPrefix() + "\", ");
279 writer.print("new String[]{");
280 Iterator<Platform> platforms = platform_set.iterator();
281 while ( platforms.hasNext() ) {
282 writer.print("\"" + platforms.next().getOSPrefix() + "\"");
283 if ( platforms.hasNext() )
284 writer.print(", ");
285 }
286 writer.print("}, new String[]{");
287 platforms = platform_set.iterator();
288 while ( platforms.hasNext() ) {
289 writer.print("\"" + platforms.next().getPrefix() + "\"");
290 if ( platforms.hasNext() )
291 writer.print(", ");
292 }
293 writer.print("}, ");
294 } else if ( aliased ) {
295 writer.print("GLContext.getFunctionAddress(new String[] {\"" + method.getSimpleName() + "\",\"" + method.getSimpleName() + alias_annotation.postfix() + "\"})) != 0");
296 } else
297 writer.print("GLContext.getFunctionAddress(");
298 if ( !aliased )
299 writer.print("\"" + method.getSimpleName() + "\")) != 0");
300 if ( deprecated || dependent != null )
301 writer.print(')');
302 if ( optional )
303 writer.print(" || true)");
304 }
305 writer.println(";");
306 writer.println("\t}");
307 writer.println();
308 }
309
310 public static void generateSymbolAddresses(PrintWriter writer, InterfaceDeclaration d) {
311 boolean first = true;
312 for ( final MethodDeclaration method : d.getMethods() ) {
313 if ( method.getAnnotation(Alternate.class) != null || method.getAnnotation(Reuse.class) != null )
314 continue;
315
316 if ( first ) {
317 writer.println("\t// " + d.getSimpleName());
318 first = false;
319 }
320 writer.println("\tlong " + Utils.getFunctionAddressName(d, method) + ";");
321 }
322 }
323
324 public static void generateField(PrintWriter writer, InterfaceDeclaration d) {
325 writer.println("\tpublic final boolean " + translateFieldName(d.getSimpleName()) + ";");
326 }
327 }
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 package org.lwjgl.util.generator.opengl;
33
34 import org.lwjgl.util.generator.Utils;
35
36 import static java.util.Collections.unmodifiableCollection;
37
38 import java.io.File;
39 import java.io.IOException;
40 import java.io.PrintWriter;
41 import java.util.Arrays;
42 import java.util.Collection;
43 import java.util.Map;
44 import java.util.Set;
45
46 import com.sun.mirror.apt.AnnotationProcessor;
47 import com.sun.mirror.apt.AnnotationProcessorEnvironment;
48 import com.sun.mirror.apt.AnnotationProcessorFactory;
49 import com.sun.mirror.apt.AnnotationProcessors;
50 import com.sun.mirror.apt.Filer;
51 import com.sun.mirror.apt.RoundCompleteEvent;
52 import com.sun.mirror.apt.RoundCompleteListener;
53 import com.sun.mirror.declaration.AnnotationTypeDeclaration;
54 import com.sun.mirror.declaration.InterfaceDeclaration;
55 import com.sun.mirror.declaration.TypeDeclaration;
56 import com.sun.mirror.util.DeclarationFilter;
57
58 /**
59 *
60 * Generator tool for creating the ContexCapabilities class
61 *
62 * @author elias_naur <elias_naur@users.sourceforge.net>
63 * @version $Revision: 3316 $
64 * $Id: ContextGeneratorProcessorFactory.java 3316 2010-04-09 23:57:40Z spasi $
65 */
66 public class GLGeneratorProcessorFactory implements AnnotationProcessorFactory, RoundCompleteListener {
67 private static boolean first_round = true;
68
69 // Process any set of annotations
70 private static final Collection<String> supportedAnnotations =
71 unmodifiableCollection(Arrays.asList("*"));
72
73 public Collection<String> supportedAnnotationTypes() {
74 return supportedAnnotations;
75 }
76
77 public Collection<String> supportedOptions() {
78 return unmodifiableCollection(Arrays.asList("-Acontextspecific", "-Ageneratechecks"));
79 }
80
81 public void roundComplete(RoundCompleteEvent event) {
82 first_round = false;
83 }
84
85 public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds, AnnotationProcessorEnvironment env) {
86 // Only process the initial types, not the generated ones
87 if (first_round) {
88 env.addListener(this);
89 return new GeneratorProcessor(env);
90 } else
91 return AnnotationProcessors.NO_OP;
92 }
93
94 private static class GeneratorProcessor implements AnnotationProcessor {
95 private final AnnotationProcessorEnvironment env;
96
97 GeneratorProcessor(AnnotationProcessorEnvironment env) {
98 this.env = env;
99 }
100
101 public void process() {
102 Map<String, String> options = env.getOptions();
103 boolean generate_error_checks = options.containsKey("-Ageneratechecks");
104 boolean context_specific = options.containsKey("-Acontextspecific");
105 try {
106 generateContextCapabilitiesSource(context_specific, generate_error_checks);
107 } catch (IOException e) {
108 throw new RuntimeException(e);
109 }
110 }
111
112 private void generateContextCapabilitiesSource(boolean context_specific, boolean generate_error_checks) throws IOException {
113 PrintWriter writer = env.getFiler().createTextFile(Filer.Location.SOURCE_TREE, "org.lwjgl.opengl", new File(Utils.CONTEXT_CAPS_CLASS_NAME + ".java"), null);
114 writer.println("/* MACHINE GENERATED FILE, DO NOT EDIT */");
115 writer.println();
116 writer.println("package org.lwjgl.opengl;");
117 writer.println();
118 writer.println("import org.lwjgl.LWJGLException;");
119 writer.println("import org.lwjgl.LWJGLUtil;");
120 writer.println("import java.util.Set;");
121 writer.println("import java.util.HashSet;");
122 writer.println();
123 GLCapabilitiesGenerator.generateClassPrologue(writer, context_specific, generate_error_checks);
124 DeclarationFilter filter = DeclarationFilter.getFilter(InterfaceDeclaration.class);
125 Collection<TypeDeclaration> interface_decls = filter.filter(env.getSpecifiedTypeDeclarations());
126 for (TypeDeclaration typedecl : interface_decls) {
127 InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl;
128 if (Utils.isFinal(interface_decl))
129 GLCapabilitiesGenerator.generateField(writer, interface_decl);
130 }
131 writer.println();
132 for (TypeDeclaration typedecl : interface_decls) {
133 InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl;
134 GLCapabilitiesGenerator.generateSymbolAddresses(writer, interface_decl);
135 }
136 writer.println();
137 if (context_specific) {
138 for (TypeDeclaration typedecl : interface_decls) {
139 InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl;
140 GLCapabilitiesGenerator.generateAddressesInitializers(writer, interface_decl);
141 }
142 writer.println();
143 }
144
145 writer.println("\tprivate static void remove(Set supported_extensions, String extension) {");
146 writer.println("\t\tLWJGLUtil.log(extension + \" was reported as available but an entry point is missing\");");
147 writer.println("\t\tsupported_extensions.remove(extension);");
148 writer.println("\t}\n");
149
150 GLCapabilitiesGenerator.generateInitStubsPrologue(writer, context_specific);
151 for (TypeDeclaration typedecl : interface_decls) {
152 InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl;
153 GLCapabilitiesGenerator.generateSuperClassAdds(writer, interface_decl);
154 }
155 for (TypeDeclaration typedecl : interface_decls) {
156 InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl;
157 String simple_name = interface_decl.getSimpleName();
158 if ( "GL11".equals(simple_name) )
159 continue;
160 GLCapabilitiesGenerator.generateInitStubs(writer, interface_decl, context_specific);
161 }
162 GLCapabilitiesGenerator.generateInitStubsEpilogue(writer, context_specific);
163 writer.println();
164 writer.println("\tstatic void unloadAllStubs() {");
165 if (!context_specific) {
166 writer.println("\t\tif (!loaded_stubs)");
167 writer.println("\t\t\treturn;");
168 for (TypeDeclaration typedecl : interface_decls) {
169 InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl;
170 GLCapabilitiesGenerator.generateUnloadStubs(writer, interface_decl);
171 }
172 writer.println("\t\tloaded_stubs = false;");
173 }
174 writer.println("\t}");
175 writer.println();
176 GLCapabilitiesGenerator.generateInitializerPrologue(writer);
177 for (TypeDeclaration typedecl : interface_decls) {
178 InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl;
179 if (Utils.isFinal(interface_decl))
180 GLCapabilitiesGenerator.generateInitializer(writer, interface_decl);
181 }
182 writer.println("\t\ttracker.init();");
183 writer.println("\t}");
184 writer.println("}");
185 writer.close();
186 }
187 }
188 }
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 package org.lwjgl.util.generator.opengl;
33
34 import org.lwjgl.util.generator.CachedReference;
35 import org.lwjgl.util.generator.Utils;
36
37 import static java.util.Collections.emptyList;
38 import static java.util.Collections.unmodifiableCollection;
39
40 import java.io.File;
41 import java.io.IOException;
42 import java.io.PrintWriter;
43 import java.util.Arrays;
44 import java.util.Collection;
45 import java.util.Set;
46
47 import com.sun.mirror.apt.AnnotationProcessor;
48 import com.sun.mirror.apt.AnnotationProcessorEnvironment;
49 import com.sun.mirror.apt.AnnotationProcessorFactory;
50 import com.sun.mirror.apt.AnnotationProcessors;
51 import com.sun.mirror.apt.Filer;
52 import com.sun.mirror.apt.RoundCompleteEvent;
53 import com.sun.mirror.apt.RoundCompleteListener;
54 import com.sun.mirror.declaration.AnnotationTypeDeclaration;
55 import com.sun.mirror.declaration.InterfaceDeclaration;
56 import com.sun.mirror.declaration.MethodDeclaration;
57 import com.sun.mirror.declaration.ParameterDeclaration;
58 import com.sun.mirror.declaration.TypeDeclaration;
59 import com.sun.mirror.util.DeclarationFilter;
60
61 /**
62 *
63 * Generator tool for creating the References class
64 *
65 * @author elias_naur <elias_naur@users.sourceforge.net>
66 * @version $Revision: 3237 $
67 * $Id: ReferencesGeneratorProcessorFactory.java 3237 2009-09-08 15:07:15Z spasi $
68 */
69 public class GLReferencesGeneratorProcessorFactory implements AnnotationProcessorFactory, RoundCompleteListener {
70 private static final String REFERENCES_CLASS_NAME = "References";
71 private static final String REFERENCES_PARAMETER_NAME = "references";
72
73 private static boolean first_round = true;
74
75 // Process any set of annotations
76 private static final Collection<String> supportedAnnotations =
77 unmodifiableCollection(Arrays.asList("*"));
78
79 public Collection<String> supportedAnnotationTypes() {
80 return supportedAnnotations;
81 }
82
83 public Collection<String> supportedOptions() {
84 return emptyList();
85 }
86
87 public void roundComplete(RoundCompleteEvent event) {
88 first_round = false;
89 }
90
91 public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds, AnnotationProcessorEnvironment env) {
92 // Only process the initial types, not the generated ones
93 if (first_round) {
94 env.addListener(this);
95 return new GeneratorProcessor(env);
96 } else
97 return AnnotationProcessors.NO_OP;
98 }
99
100 private static class GeneratorProcessor implements AnnotationProcessor {
101 private final AnnotationProcessorEnvironment env;
102
103 GeneratorProcessor(AnnotationProcessorEnvironment env) {
104 this.env = env;
105 }
106
107 public void process() {
108 try {
109 generateReferencesSource();
110 } catch (IOException e) {
111 throw new RuntimeException(e);
112 }
113 }
114
115 private static void generateClearsFromParameters(PrintWriter writer, InterfaceDeclaration interface_decl, MethodDeclaration method) {
116 for (ParameterDeclaration param : method.getParameters()) {
117 CachedReference cached_reference_annotation = param.getAnnotation(CachedReference.class);
118 if (cached_reference_annotation != null && cached_reference_annotation.name().length() == 0) {
119 Class nio_type = Utils.getNIOBufferType(param.getType());
120 String reference_name = Utils.getReferenceName(interface_decl, method, param);
121 writer.println("\t\tthis." + reference_name + " = null;");
122 }
123 }
124 }
125
126 private static void generateCopiesFromParameters(PrintWriter writer, InterfaceDeclaration interface_decl, MethodDeclaration method) {
127 for (ParameterDeclaration param : method.getParameters()) {
128 CachedReference cached_reference_annotation = param.getAnnotation(CachedReference.class);
129 if (cached_reference_annotation != null && cached_reference_annotation.name().length() == 0) {
130 Class nio_type = Utils.getNIOBufferType(param.getType());
131 String reference_name = Utils.getReferenceName(interface_decl, method, param);
132 writer.print("\t\t\tthis." + reference_name + " = ");
133 writer.println(REFERENCES_PARAMETER_NAME + "." + reference_name + ";");
134 }
135 }
136 }
137
138 private static void generateClearsFromMethods(PrintWriter writer, InterfaceDeclaration interface_decl) {
139 for (MethodDeclaration method : interface_decl.getMethods()) {
140 generateClearsFromParameters(writer, interface_decl, method);
141 }
142 }
143
144 private static void generateCopiesFromMethods(PrintWriter writer, InterfaceDeclaration interface_decl) {
145 for (MethodDeclaration method : interface_decl.getMethods()) {
146 generateCopiesFromParameters(writer, interface_decl, method);
147 }
148 }
149
150 private static void generateReferencesFromParameters(PrintWriter writer, InterfaceDeclaration interface_decl, MethodDeclaration method) {
151 for (ParameterDeclaration param : method.getParameters()) {
152 CachedReference cached_reference_annotation = param.getAnnotation(CachedReference.class);
153 if (cached_reference_annotation != null && cached_reference_annotation.name().length() == 0) {
154 Class nio_type = Utils.getNIOBufferType(param.getType());
155 if (nio_type == null)
156 throw new RuntimeException(param + " in method " + method + " in " + interface_decl + " is annotated with "
157 + cached_reference_annotation.annotationType().getSimpleName() + " but the parameter is not a NIO buffer");
158 writer.print("\t" + nio_type.getName() + " " + Utils.getReferenceName(interface_decl, method, param));
159 writer.println(";");
160 }
161 }
162 }
163
164 private static void generateReferencesFromMethods(PrintWriter writer, InterfaceDeclaration interface_decl) {
165 for (MethodDeclaration method : interface_decl.getMethods()) {
166 generateReferencesFromParameters(writer, interface_decl, method);
167 }
168 }
169
170 private void generateReferencesSource() throws IOException {
171 PrintWriter writer = env.getFiler().createTextFile(Filer.Location.SOURCE_TREE, "org.lwjgl.opengl", new File(REFERENCES_CLASS_NAME + ".java"), null);
172 writer.println("/* MACHINE GENERATED FILE, DO NOT EDIT */");
173 writer.println();
174 writer.println("package org.lwjgl.opengl;");
175 writer.println();
176 writer.println("class " + REFERENCES_CLASS_NAME + " extends BaseReferences {");
177 writer.println("\t" + REFERENCES_CLASS_NAME + "(ContextCapabilities caps) {");
178 writer.println("\t\tsuper(caps);");
179 writer.println("\t}");
180 DeclarationFilter filter = DeclarationFilter.getFilter(InterfaceDeclaration.class);
181 Collection<TypeDeclaration> interface_decls = filter.filter(env.getSpecifiedTypeDeclarations());
182 for (TypeDeclaration typedecl : interface_decls) {
183 InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl;
184 generateReferencesFromMethods(writer, interface_decl);
185 }
186 writer.println();
187 writer.println("\tvoid copy(" + REFERENCES_CLASS_NAME + " " + REFERENCES_PARAMETER_NAME + ", int mask) {");
188 writer.println("\t\tsuper.copy(" + REFERENCES_PARAMETER_NAME + ", mask);");
189 writer.println("\t\tif ( (mask & GL11.GL_CLIENT_VERTEX_ARRAY_BIT) != 0 ) {");
190 for (TypeDeclaration typedecl : interface_decls) {
191 InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl;
192 generateCopiesFromMethods(writer, interface_decl);
193 }
194 writer.println("\t\t}");
195 writer.println("\t}");
196 writer.println("\tvoid clear() {");
197 writer.println("\t\tsuper.clear();");
198 for (TypeDeclaration typedecl : interface_decls) {
199 InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl;
200 generateClearsFromMethods(writer, interface_decl);
201 }
202 writer.println("\t}");
203 writer.println("}");
204 writer.close();
205 }
206 }
207 }
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 package org.lwjgl.util.generator.opengl;
33
34 /**
35 *
36 * OpenGL sepcific generator behaviour
37 *
38 * @author elias_naur <elias_naur@users.sourceforge.net>
39 * @version $Revision: 3392 $
40 * $Id: GLTypeMap.java 3392 2010-07-27 15:33:22Z spasi $
41 */
42
43 import org.lwjgl.util.generator.NativeTypeTranslator;
44 import org.lwjgl.util.generator.PointerWrapper;
45 import org.lwjgl.util.generator.Signedness;
46 import org.lwjgl.util.generator.TypeMap;
47
48 import java.io.PrintWriter;
49 import java.lang.annotation.Annotation;
50 import java.nio.*;
51 import java.util.HashMap;
52 import java.util.Map;
53
54 import com.sun.mirror.declaration.AnnotationMirror;
55 import com.sun.mirror.declaration.MethodDeclaration;
56 import com.sun.mirror.type.PrimitiveType;
57
58 public class GLTypeMap implements TypeMap {
59
60 private static final Map<Class, PrimitiveType.Kind> native_types_to_primitive;
61
62 static {
63 native_types_to_primitive = new HashMap<Class, PrimitiveType.Kind>();
64 native_types_to_primitive.put(GLbitfield.class, PrimitiveType.Kind.INT);
65 native_types_to_primitive.put(GLcharARB.class, PrimitiveType.Kind.BYTE);
66 native_types_to_primitive.put(GLclampf.class, PrimitiveType.Kind.FLOAT);
67 native_types_to_primitive.put(GLfloat.class, PrimitiveType.Kind.FLOAT);
68 native_types_to_primitive.put(GLint.class, PrimitiveType.Kind.INT);
69 native_types_to_primitive.put(GLshort.class, PrimitiveType.Kind.SHORT);
70 native_types_to_primitive.put(GLsizeiptr.class, PrimitiveType.Kind.LONG);
71 native_types_to_primitive.put(GLuint.class, PrimitiveType.Kind.INT);
72 native_types_to_primitive.put(GLboolean.class, PrimitiveType.Kind.BOOLEAN);
73 native_types_to_primitive.put(GLchar.class, PrimitiveType.Kind.BYTE);
74 native_types_to_primitive.put(GLdouble.class, PrimitiveType.Kind.DOUBLE);
75 native_types_to_primitive.put(GLhalf.class, PrimitiveType.Kind.SHORT);
76 native_types_to_primitive.put(GLintptrARB.class, PrimitiveType.Kind.LONG);
77 native_types_to_primitive.put(GLsizei.class, PrimitiveType.Kind.INT);
78 native_types_to_primitive.put(GLushort.class, PrimitiveType.Kind.SHORT);
79 native_types_to_primitive.put(GLbyte.class, PrimitiveType.Kind.BYTE);
80 native_types_to_primitive.put(GLclampd.class, PrimitiveType.Kind.DOUBLE);
81 native_types_to_primitive.put(GLenum.class, PrimitiveType.Kind.INT);
82 native_types_to_primitive.put(GLhandleARB.class, PrimitiveType.Kind.INT);
83 native_types_to_primitive.put(GLintptr.class, PrimitiveType.Kind.LONG);
84 native_types_to_primitive.put(GLsizeiptrARB.class, PrimitiveType.Kind.LONG);
85 native_types_to_primitive.put(GLubyte.class, PrimitiveType.Kind.BYTE);
86 native_types_to_primitive.put(GLvoid.class, PrimitiveType.Kind.BYTE);
87 native_types_to_primitive.put(GLint64EXT.class, PrimitiveType.Kind.LONG);
88 native_types_to_primitive.put(GLuint64EXT.class, PrimitiveType.Kind.LONG);
89 native_types_to_primitive.put(GLint64.class, PrimitiveType.Kind.LONG);
90 native_types_to_primitive.put(GLuint64.class, PrimitiveType.Kind.LONG);
91 }
92
93 public PrimitiveType.Kind getPrimitiveTypeFromNativeType(Class native_type) {
94 PrimitiveType.Kind kind = native_types_to_primitive.get(native_type);
95 if ( kind == null )
96 throw new RuntimeException("Unsupported type " + native_type);
97 return kind;
98 }
99
100 public void printCapabilitiesInit(final PrintWriter writer) {
101 writer.println("\t\tContextCapabilities caps = GLContext.getCapabilities();");
102 }
103
104 public String getCapabilities() {
105 return "caps";
106 }
107
108 public void printErrorCheckMethod(final PrintWriter writer, final MethodDeclaration method, final String tabs) {
109 writer.println(tabs + "Util.checkGLError();");
110 }
111
112 public String getRegisterNativesFunctionName() {
113 return "extgl_InitializeClass";
114 }
115
116 public Signedness getSignednessFromType(Class type) {
117 if ( GLuint.class.equals(type) )
118 return Signedness.UNSIGNED;
119 else if ( GLint.class.equals(type) )
120 return Signedness.SIGNED;
121 else if ( GLushort.class.equals(type) )
122 return Signedness.UNSIGNED;
123 else if ( GLshort.class.equals(type) )
124 return Signedness.SIGNED;
125 else if ( GLubyte.class.equals(type) )
126 return Signedness.UNSIGNED;
127 else if ( GLbyte.class.equals(type) )
128 return Signedness.SIGNED;
129 else if ( GLuint64EXT.class.equals(type) )
130 return Signedness.UNSIGNED;
131 else if ( GLint64EXT.class.equals(type) )
132 return Signedness.SIGNED;
133 else if ( GLuint64.class.equals(type) )
134 return Signedness.UNSIGNED;
135 else if ( GLint64.class.equals(type) )
136 return Signedness.SIGNED;
137 else
138 return Signedness.NONE;
139 }
140
141 public String translateAnnotation(Class annotation_type) {
142 if ( annotation_type.equals(GLuint.class) || annotation_type.equals(GLint.class) )
143 return "i";
144 else if ( annotation_type.equals(GLushort.class) || annotation_type.equals(GLshort.class) )
145 return "s";
146 else if ( annotation_type.equals(GLubyte.class) || annotation_type.equals(GLbyte.class) )
147 return "b";
148 else if ( annotation_type.equals(GLfloat.class) || annotation_type.equals(GLclampf.class) )
149 return "f";
150 else if ( annotation_type.equals(GLdouble.class) || annotation_type.equals(GLclampd.class) )
151 return "d";
152 else if ( annotation_type.equals(GLhalf.class) )
153 return "h";
154 else if ( annotation_type.equals(GLuint64EXT.class) || annotation_type.equals(GLint64EXT.class) || annotation_type.equals(GLuint64.class) || annotation_type.equals(GLint64.class) )
155 return "i64";
156 else if ( annotation_type.equals(GLboolean.class) || annotation_type.equals(GLvoid.class) )
157 return "";
158 else
159 throw new RuntimeException(annotation_type + " is not allowed");
160 }
161
162 public Class getNativeTypeFromPrimitiveType(PrimitiveType.Kind kind) {
163 Class type;
164 switch ( kind ) {
165 case INT:
166 type = GLint.class;
167 break;
168 case DOUBLE:
169 type = GLdouble.class;
170 break;
171 case FLOAT:
172 type = GLfloat.class;
173 break;
174 case SHORT:
175 type = GLshort.class;
176 break;
177 case BYTE:
178 type = GLbyte.class;
179 break;
180 case LONG:
181 type = GLint64EXT.class;
182 break;
183 case BOOLEAN:
184 type = GLboolean.class;
185 break;
186 default:
187 throw new RuntimeException(kind + " is not allowed");
188 }
189 return type;
190 }
191
192 public Class<? extends Annotation> getVoidType() {
193 return GLvoid.class;
194 }
195
196 public Class<? extends Annotation> getStringElementType() {
197 return GLubyte.class;
198 }
199
200 public Class<? extends Annotation> getStringArrayType() {
201 return GLchar.class;
202 }
203
204 public Class<? extends Annotation> getByteBufferArrayType() {
205 return GLchar.class;
206 }
207
208 private static Class[] getValidBufferTypes(Class type) {
209 if ( type.equals(IntBuffer.class) )
210 return new Class[] { GLbitfield.class, GLenum.class, GLhandleARB.class, GLint.class,
211 GLsizei.class, GLuint.class, GLvoid.class };
212 else if ( type.equals(FloatBuffer.class) )
213 return new Class[] { GLclampf.class, GLfloat.class };
214 else if ( type.equals(ByteBuffer.class) )
215 return new Class[] { GLboolean.class, GLbyte.class, GLcharARB.class, GLchar.class, GLubyte.class, GLvoid.class };
216 else if ( type.equals(ShortBuffer.class) )
217 return new Class[] { GLhalf.class, GLshort.class, GLushort.class };
218 else if ( type.equals(DoubleBuffer.class) )
219 return new Class[] { GLclampd.class, GLdouble.class };
220 else if ( type.equals(LongBuffer.class) )
221 return new Class[] { GLint64EXT.class, GLuint64EXT.class, GLint64.class, GLuint64.class };
222 else
223 return new Class[] { };
224 }
225
226 private static Class[] getValidPrimitiveTypes(Class type) {
227 if ( type.equals(long.class) )
228 return new Class[] { GLintptrARB.class, GLuint.class, GLintptr.class, GLsizeiptrARB.class, GLsizeiptr.class, GLint64EXT.class, GLuint64EXT.class, GLint64.class, GLuint64.class };
229 else if ( type.equals(int.class) )
230 return new Class[] { GLbitfield.class, GLenum.class, GLhandleARB.class, GLint.class, GLuint.class,
231 GLsizei.class };
232 else if ( type.equals(double.class) )
233 return new Class[] { GLclampd.class, GLdouble.class };
234 else if ( type.equals(float.class) )
235 return new Class[] { GLclampf.class, GLfloat.class };
236 else if ( type.equals(short.class) )
237 return new Class[] { GLhalf.class, GLshort.class, GLushort.class };
238 else if ( type.equals(byte.class) )
239 return new Class[] { GLbyte.class, GLcharARB.class, GLchar.class, GLubyte.class };
240 else if ( type.equals(boolean.class) )
241 return new Class[] { GLboolean.class };
242 else if ( type.equals(void.class) )
243 return new Class[] { GLvoid.class, GLreturn.class };
244 else
245 return new Class[] { };
246 }
247
248 public String getTypedefPostfix() {
249 return "";
250 }
251
252 public String getFunctionPrefix() {
253 return "APIENTRY";
254 }
255
256 public void printNativeIncludes(PrintWriter writer) {
257 writer.println("#include \"extgl.h\"");
258 }
259
260 public Class[] getValidAnnotationTypes(Class type) {
261 Class[] valid_types;
262 if ( Buffer.class.isAssignableFrom(type) )
263 valid_types = getValidBufferTypes(type);
264 else if ( type.isPrimitive() )
265 valid_types = getValidPrimitiveTypes(type);
266 else if ( String.class.equals(type) )
267 valid_types = new Class[] { GLubyte.class };
268 else if ( org.lwjgl.PointerWrapper.class.isAssignableFrom(type) )
269 valid_types = new Class[] { PointerWrapper.class };
270 else if (void.class.equals(type) )
271 valid_types = new Class[] { GLreturn.class };
272 else
273 valid_types = new Class[] { };
274 return valid_types;
275 }
276
277 public Class<? extends Annotation> getInverseType(Class type) {
278 if ( GLuint.class.equals(type) )
279 return GLint.class;
280 else if ( GLint.class.equals(type) )
281 return GLuint.class;
282 else if ( GLushort.class.equals(type) )
283 return GLshort.class;
284 else if ( GLshort.class.equals(type) )
285 return GLushort.class;
286 else if ( GLubyte.class.equals(type) )
287 return GLbyte.class;
288 else if ( GLbyte.class.equals(type) )
289 return GLubyte.class;
290 else if ( GLuint64EXT.class.equals(type) )
291 return GLint64EXT.class;
292 else if ( GLint64EXT.class.equals(type) )
293 return GLuint64EXT.class;
294 else if ( GLuint64.class.equals(type) )
295 return GLint64.class;
296 else if ( GLint64.class.equals(type) )
297 return GLuint64.class;
298 else
299 return null;
300 }
301
302 public String getAutoTypeFromAnnotation(AnnotationMirror annotation) {
303 Class annotation_class = NativeTypeTranslator.getClassFromType(annotation.getAnnotationType());
304 if ( annotation_class.equals(GLint.class) )
305 return "GL11.GL_INT";
306 else if ( annotation_class.equals(GLbyte.class) )
307 return "GL11.GL_BYTE";
308 else if ( annotation_class.equals(GLshort.class) )
309 return "GL11.GL_SHORT";
310 if ( annotation_class.equals(GLuint.class) )
311 return "GL11.GL_UNSIGNED_INT";
312 else if ( annotation_class.equals(GLubyte.class) )
313 return "GL11.GL_UNSIGNED_BYTE";
314 else if ( annotation_class.equals(GLushort.class) )
315 return "GL11.GL_UNSIGNED_SHORT";
316 else if ( annotation_class.equals(GLfloat.class) )
317 return "GL11.GL_FLOAT";
318 else if ( annotation_class.equals(GLdouble.class) )
319 return "GL11.GL_DOUBLE";
320 else
321 return null;
322 }
323 }
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.opengl;
32
33 /**
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2983 $
37 * $Id: GLbitfield.java 2983 2008-04-07 18:36:09Z matzon $
38 */
39
40 import org.lwjgl.util.generator.NativeType;
41
42 import java.lang.annotation.Target;
43 import java.lang.annotation.ElementType;
44
45 @NativeType
46 @Target({ElementType.PARAMETER, ElementType.METHOD})
47 public @interface GLbitfield {
48 }
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.opengl;
32
33 /**
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2983 $
37 * $Id: GLboolean.java 2983 2008-04-07 18:36:09Z matzon $
38 */
39
40 import org.lwjgl.util.generator.NativeType;
41
42 import java.lang.annotation.Target;
43 import java.lang.annotation.ElementType;
44
45 @NativeType
46 @Target({ElementType.PARAMETER, ElementType.METHOD})
47 public @interface GLboolean {
48 }
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.opengl;
32
33 /**
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2983 $
37 * $Id: GLbyte.java 2983 2008-04-07 18:36:09Z matzon $
38 */
39
40 import org.lwjgl.util.generator.NativeType;
41
42 import java.lang.annotation.Target;
43 import java.lang.annotation.ElementType;
44
45 @NativeType
46 @Target({ElementType.PARAMETER, ElementType.METHOD})
47 public @interface GLbyte {
48 }
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.opengl;
32
33 /**
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2983 $
37 * $Id: GLchar.java 2983 2008-04-07 18:36:09Z matzon $
38 */
39
40 import org.lwjgl.util.generator.NativeType;
41
42 import java.lang.annotation.Target;
43 import java.lang.annotation.ElementType;
44
45 @NativeType
46 @Target({ElementType.PARAMETER, ElementType.METHOD})
47 public @interface GLchar {
48 }
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.opengl;
32
33 /**
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2983 $
37 * $Id: GLcharARB.java 2983 2008-04-07 18:36:09Z matzon $
38 */
39
40 import org.lwjgl.util.generator.NativeType;
41
42 import java.lang.annotation.Target;
43 import java.lang.annotation.ElementType;
44
45 @NativeType
46 @Target({ElementType.PARAMETER, ElementType.METHOD})
47 public @interface GLcharARB {
48 }
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.opengl;
32
33 /**
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2983 $
37 * $Id: GLclampd.java 2983 2008-04-07 18:36:09Z matzon $
38 */
39
40 import org.lwjgl.util.generator.NativeType;
41
42 import java.lang.annotation.Target;
43 import java.lang.annotation.ElementType;
44
45 @NativeType
46 @Target({ElementType.PARAMETER, ElementType.METHOD})
47 public @interface GLclampd {
48 }
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.opengl;
32
33 /**
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2983 $
37 * $Id: GLclampf.java 2983 2008-04-07 18:36:09Z matzon $
38 */
39
40 import org.lwjgl.util.generator.NativeType;
41
42 import java.lang.annotation.Target;
43 import java.lang.annotation.ElementType;
44
45 @NativeType
46 @Target({ElementType.PARAMETER, ElementType.METHOD})
47 public @interface GLclampf {
48 }
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.opengl;
32
33 /**
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2983 $
37 * $Id: GLdouble.java 2983 2008-04-07 18:36:09Z matzon $
38 */
39
40 import org.lwjgl.util.generator.NativeType;
41
42 import java.lang.annotation.Target;
43 import java.lang.annotation.ElementType;
44
45 @NativeType
46 @Target({ElementType.PARAMETER, ElementType.METHOD})
47 public @interface GLdouble {
48 }
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.opengl;
32
33 /**
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2983 $
37 * $Id: GLenum.java 2983 2008-04-07 18:36:09Z matzon $
38 */
39
40 import org.lwjgl.util.generator.NativeType;
41
42 import java.lang.annotation.Target;
43 import java.lang.annotation.ElementType;
44
45 @NativeType
46 @Target({ElementType.PARAMETER, ElementType.METHOD})
47 public @interface GLenum {
48 }
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.opengl;
32
33 /**
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2983 $
37 * $Id: GLfloat.java 2983 2008-04-07 18:36:09Z matzon $
38 */
39
40 import org.lwjgl.util.generator.NativeType;
41
42 import java.lang.annotation.Target;
43 import java.lang.annotation.ElementType;
44
45 @NativeType
46 @Target({ElementType.PARAMETER, ElementType.METHOD})
47 public @interface GLfloat {
48 }
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.opengl;
32
33 /**
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2983 $
37 * $Id: GLhalf.java 2983 2008-04-07 18:36:09Z matzon $
38 */
39
40 import org.lwjgl.util.generator.NativeType;
41
42 import java.lang.annotation.Target;
43 import java.lang.annotation.ElementType;
44
45 @NativeType
46 @Target({ElementType.PARAMETER, ElementType.METHOD})
47 public @interface GLhalf {
48 }
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.opengl;
32
33 /**
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2983 $
37 * $Id: GLhandleARB.java 2983 2008-04-07 18:36:09Z matzon $
38 */
39
40 import org.lwjgl.util.generator.NativeType;
41
42 import java.lang.annotation.Target;
43 import java.lang.annotation.ElementType;
44
45 @NativeType
46 @Target({ElementType.PARAMETER, ElementType.METHOD})
47 public @interface GLhandleARB {
48 }
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.opengl;
32
33 /**
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2983 $
37 * $Id: GLint.java 2983 2008-04-07 18:36:09Z matzon $
38 */
39
40 import org.lwjgl.util.generator.NativeType;
41
42 import java.lang.annotation.Target;
43 import java.lang.annotation.ElementType;
44
45 @NativeType
46 @Target({ElementType.PARAMETER, ElementType.METHOD})
47 public @interface GLint {
48 }
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.opengl;
32
33 import org.lwjgl.util.generator.NativeType;
34
35 import java.lang.annotation.Target;
36 import java.lang.annotation.ElementType;
37
38 @NativeType
39 @Target({ElementType.PARAMETER, ElementType.METHOD})
40 public @interface GLint64 {
41 }
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.opengl;
32
33 import org.lwjgl.util.generator.NativeType;
34
35 import java.lang.annotation.Target;
36 import java.lang.annotation.ElementType;
37
38 @NativeType
39 @Target({ElementType.PARAMETER, ElementType.METHOD})
40 public @interface GLint64EXT {
41 }
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.opengl;
32
33 /**
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2983 $
37 * $Id: GLintptr.java 2983 2008-04-07 18:36:09Z matzon $
38 */
39
40 import org.lwjgl.util.generator.NativeType;
41
42 import java.lang.annotation.Target;
43 import java.lang.annotation.ElementType;
44
45 @NativeType
46 @Target({ElementType.PARAMETER, ElementType.METHOD})
47 public @interface GLintptr {
48 }
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.opengl;
32
33 /**
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2983 $
37 * $Id: GLintptrARB.java 2983 2008-04-07 18:36:09Z matzon $
38 */
39
40 import org.lwjgl.util.generator.NativeType;
41
42 import java.lang.annotation.Target;
43 import java.lang.annotation.ElementType;
44
45 @NativeType
46 @Target({ElementType.PARAMETER, ElementType.METHOD})
47 public @interface GLintptrARB {
48 }
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.opengl;
32
33 /**
34 * When a method is annonated with @GLreturn, the specified output Buffer parameter
35 * will be used to return a single value. The primitive type will match the Buffer type.
36 * String will be returned if the Buffer is a ByteBuffer annotated with @GLchar.
37 *
38 * @author spasi
39 */
40 import org.lwjgl.util.generator.NativeType;
41
42 import java.lang.annotation.ElementType;
43 import java.lang.annotation.Target;
44
45 @NativeType
46 @Target({ ElementType.METHOD })
47 public @interface GLreturn {
48 /** The Buffer parameter to use as the method result. */
49 String value();
50 /** The argument that specifies the maximum number of bytes that may be read (String results only). */
51 String maxLength() default "";
52 /** If true, the maxLength value is going to be used when creating the String. */
53 boolean forceMaxLength() default false;
54 ///** If we use the byte buffer for another parameter, an offset must be used. */
55 //String offset() default "";
56 }
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.opengl;
32
33 /**
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2983 $
37 * $Id: GLshort.java 2983 2008-04-07 18:36:09Z matzon $
38 */
39
40 import org.lwjgl.util.generator.NativeType;
41
42 import java.lang.annotation.Target;
43 import java.lang.annotation.ElementType;
44
45 @NativeType
46 @Target({ElementType.PARAMETER, ElementType.METHOD})
47 public @interface GLshort {
48 }
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.opengl;
32
33 /**
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2983 $
37 * $Id: GLsizei.java 2983 2008-04-07 18:36:09Z matzon $
38 */
39
40 import org.lwjgl.util.generator.NativeType;
41
42 import java.lang.annotation.Target;
43 import java.lang.annotation.ElementType;
44
45 @NativeType
46 @Target({ElementType.PARAMETER, ElementType.METHOD})
47 public @interface GLsizei {
48 }
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.opengl;
32
33 /**
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2983 $
37 * $Id: GLsizeiptr.java 2983 2008-04-07 18:36:09Z matzon $
38 */
39
40 import org.lwjgl.util.generator.NativeType;
41
42 import java.lang.annotation.Target;
43 import java.lang.annotation.ElementType;
44
45 @NativeType
46 @Target({ElementType.PARAMETER, ElementType.METHOD})
47 public @interface GLsizeiptr {
48 }
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.opengl;
32
33 /**
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2983 $
37 * $Id: GLsizeiptrARB.java 2983 2008-04-07 18:36:09Z matzon $
38 */
39
40 import org.lwjgl.util.generator.NativeType;
41
42 import java.lang.annotation.Target;
43 import java.lang.annotation.ElementType;
44
45 @NativeType
46 @Target({ElementType.PARAMETER, ElementType.METHOD})
47 public @interface GLsizeiptrARB {
48 }
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.opengl;
32
33 /**
34 * Unsigned binary representing an absolute absolute or relative time interval.
35 * Precision is nanoseconds but accuracy is implementation-dependent.
36 *
37 * @author spasi <spasi@users.sourceforge.net>
38 */
39
40 import org.lwjgl.util.generator.NativeType;
41
42 import java.lang.annotation.ElementType;
43 import java.lang.annotation.Target;
44
45 @NativeType
46 @Target({ElementType.PARAMETER, ElementType.METHOD})
47 public @interface GLtime {
48 }
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.opengl;
32
33 /**
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2983 $
37 * $Id: GLubyte.java 2983 2008-04-07 18:36:09Z matzon $
38 */
39
40 import org.lwjgl.util.generator.NativeType;
41
42 import java.lang.annotation.Target;
43 import java.lang.annotation.ElementType;
44
45 @NativeType
46 @Target({ElementType.PARAMETER, ElementType.METHOD})
47 public @interface GLubyte {
48 }
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.opengl;
32
33 /**
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2983 $
37 * $Id: GLuint.java 2983 2008-04-07 18:36:09Z matzon $
38 */
39
40 import org.lwjgl.util.generator.NativeType;
41
42 import java.lang.annotation.Target;
43 import java.lang.annotation.ElementType;
44
45 @NativeType
46 @Target({ElementType.PARAMETER, ElementType.METHOD})
47 public @interface GLuint {
48 }
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.opengl;
32
33 import org.lwjgl.util.generator.NativeType;
34
35 import java.lang.annotation.Target;
36 import java.lang.annotation.ElementType;
37
38 @NativeType
39 @Target({ElementType.PARAMETER, ElementType.METHOD})
40 public @interface GLuint64 {
41 }
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.opengl;
32
33 import org.lwjgl.util.generator.NativeType;
34
35 import java.lang.annotation.Target;
36 import java.lang.annotation.ElementType;
37
38 @NativeType
39 @Target({ElementType.PARAMETER, ElementType.METHOD})
40 public @interface GLuint64EXT {
41 }
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.opengl;
32
33 /**
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2983 $
37 * $Id: GLushort.java 2983 2008-04-07 18:36:09Z matzon $
38 */
39
40 import org.lwjgl.util.generator.NativeType;
41
42 import java.lang.annotation.Target;
43 import java.lang.annotation.ElementType;
44
45 @NativeType
46 @Target({ElementType.PARAMETER, ElementType.METHOD})
47 public @interface GLushort {
48 }
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.opengl;
32
33 /**
34 *
35 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 3279 $
37 * $Id: GLvoid.java 3279 2010-03-11 21:06:49Z spasi $
38 */
39
40 import org.lwjgl.util.generator.NativeType;
41
42 import java.lang.annotation.Target;
43 import java.lang.annotation.ElementType;
44
45 import com.sun.mirror.type.PrimitiveType;
46
47 @NativeType
48 @Target({ElementType.PARAMETER, ElementType.METHOD})
49 public @interface GLvoid {
50 PrimitiveType.Kind value() default PrimitiveType.Kind.BYTE;
51 }
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 package org.lwjgl.util.glu;
3232
33 import org.lwjgl.opengl.GL11;
33 import static org.lwjgl.opengl.GL11.*;
34 import static org.lwjgl.util.glu.GLU.*;
3435
3536 /**
3637 * Cylinder.java
37 *
38 *
38 *
39 *
3940 * Created 23-dec-2003
4041 * @author Erik Duijs
4142 */
7980 float x, y, z, nz, nsign;
8081 int i, j;
8182
82 if (super.orientation == GLU.GLU_INSIDE) {
83 if (super.orientation == GLU_INSIDE) {
8384 nsign = -1.0f;
8485 } else {
8586 nsign = 1.0f;
8687 }
8788
88 da = 2.0f * GLU.PI / slices;
89 da = 2.0f * PI / slices;
8990 dr = (topRadius - baseRadius) / stacks;
9091 dz = height / stacks;
9192 nz = (baseRadius - topRadius) / height;
9293 // Z component of normal vectors
9394
94 if (super.drawStyle == GLU.GLU_POINT) {
95 GL11.glBegin(GL11.GL_POINTS);
95 if (super.drawStyle == GLU_POINT) {
96 glBegin(GL_POINTS);
9697 for (i = 0; i < slices; i++) {
9798 x = cos((i * da));
9899 y = sin((i * da));
101102 z = 0.0f;
102103 r = baseRadius;
103104 for (j = 0; j <= stacks; j++) {
104 GL11.glVertex3f((x * r), (y * r), z);
105 glVertex3f((x * r), (y * r), z);
105106 z += dz;
106107 r += dr;
107108 }
108109 }
109 GL11.glEnd();
110 } else if (super.drawStyle == GLU.GLU_LINE || super.drawStyle == GLU.GLU_SILHOUETTE) {
110 glEnd();
111 } else if (super.drawStyle == GLU_LINE || super.drawStyle == GLU_SILHOUETTE) {
111112 // Draw rings
112 if (super.drawStyle == GLU.GLU_LINE) {
113 if (super.drawStyle == GLU_LINE) {
113114 z = 0.0f;
114115 r = baseRadius;
115116 for (j = 0; j <= stacks; j++) {
116 GL11.glBegin(GL11.GL_LINE_LOOP);
117 glBegin(GL_LINE_LOOP);
117118 for (i = 0; i < slices; i++) {
118119 x = cos((i * da));
119120 y = sin((i * da));
120121 normal3f(x * nsign, y * nsign, nz * nsign);
121 GL11.glVertex3f((x * r), (y * r), z);
122 }
123 GL11.glEnd();
122 glVertex3f((x * r), (y * r), z);
123 }
124 glEnd();
124125 z += dz;
125126 r += dr;
126127 }
127128 } else {
128129 // draw one ring at each end
129130 if (baseRadius != 0.0) {
130 GL11.glBegin(GL11.GL_LINE_LOOP);
131 glBegin(GL_LINE_LOOP);
131132 for (i = 0; i < slices; i++) {
132133 x = cos((i * da));
133134 y = sin((i * da));
134135 normal3f(x * nsign, y * nsign, nz * nsign);
135 GL11.glVertex3f((x * baseRadius), (y * baseRadius), 0.0f);
136 }
137 GL11.glEnd();
138 GL11.glBegin(GL11.GL_LINE_LOOP);
136 glVertex3f((x * baseRadius), (y * baseRadius), 0.0f);
137 }
138 glEnd();
139 glBegin(GL_LINE_LOOP);
139140 for (i = 0; i < slices; i++) {
140141 x = cos((i * da));
141142 y = sin((i * da));
142143 normal3f(x * nsign, y * nsign, nz * nsign);
143 GL11.glVertex3f((x * topRadius), (y * topRadius), height);
144 }
145 GL11.glEnd();
144 glVertex3f((x * topRadius), (y * topRadius), height);
145 }
146 glEnd();
146147 }
147148 }
148149 // draw length lines
149 GL11.glBegin(GL11.GL_LINES);
150 glBegin(GL_LINES);
150151 for (i = 0; i < slices; i++) {
151152 x = cos((i * da));
152153 y = sin((i * da));
153154 normal3f(x * nsign, y * nsign, nz * nsign);
154 GL11.glVertex3f((x * baseRadius), (y * baseRadius), 0.0f);
155 GL11.glVertex3f((x * topRadius), (y * topRadius), (height));
155 glVertex3f((x * baseRadius), (y * baseRadius), 0.0f);
156 glVertex3f((x * topRadius), (y * topRadius), (height));
156157 }
157 GL11.glEnd();
158 } else if (super.drawStyle == GLU.GLU_FILL) {
158 glEnd();
159 } else if (super.drawStyle == GLU_FILL) {
159160 float ds = 1.0f / slices;
160161 float dt = 1.0f / stacks;
161162 float t = 0.0f;
163164 r = baseRadius;
164165 for (j = 0; j < stacks; j++) {
165166 float s = 0.0f;
166 GL11.glBegin(GL11.GL_QUAD_STRIP);
167 glBegin(GL_QUAD_STRIP);
167168 for (i = 0; i <= slices; i++) {
168169 if (i == slices) {
169170 x = sin(0.0f);
175176 if (nsign == 1.0f) {
176177 normal3f((x * nsign), (y * nsign), (nz * nsign));
177178 TXTR_COORD(s, t);
178 GL11.glVertex3f((x * r), (y * r), z);
179 glVertex3f((x * r), (y * r), z);
179180 normal3f((x * nsign), (y * nsign), (nz * nsign));
180181 TXTR_COORD(s, t + dt);
181 GL11.glVertex3f((x * (r + dr)), (y * (r + dr)), (z + dz));
182 glVertex3f((x * (r + dr)), (y * (r + dr)), (z + dz));
182183 } else {
183184 normal3f(x * nsign, y * nsign, nz * nsign);
184185 TXTR_COORD(s, t);
185 GL11.glVertex3f((x * r), (y * r), z);
186 glVertex3f((x * r), (y * r), z);
186187 normal3f(x * nsign, y * nsign, nz * nsign);
187188 TXTR_COORD(s, t + dt);
188 GL11.glVertex3f((x * (r + dr)), (y * (r + dr)), (z + dz));
189 glVertex3f((x * (r + dr)), (y * (r + dr)), (z + dz));
189190 }
190191 s += ds;
191192 } // for slices
192 GL11.glEnd();
193 glEnd();
193194 r += dr;
194195 t += dt;
195196 z += dz;
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 package org.lwjgl.util.glu;
3232
33 import org.lwjgl.opengl.GL11;
33 import static org.lwjgl.opengl.GL11.*;
34 import static org.lwjgl.util.glu.GLU.*;
3435
3536 /**
3637 * Disk.java
37 *
38 *
38 *
39 *
3940 * Created 23-dec-2003
4041 * @author Erik Duijs
4142 */
7172 float da, dr;
7273
7374 /* Normal vectors */
74 if (super.normals != GLU.GLU_NONE) {
75 if (super.orientation == GLU.GLU_OUTSIDE) {
76 GL11.glNormal3f(0.0f, 0.0f, +1.0f);
75 if (super.normals != GLU_NONE) {
76 if (super.orientation == GLU_OUTSIDE) {
77 glNormal3f(0.0f, 0.0f, +1.0f);
7778 }
7879 else {
79 GL11.glNormal3f(0.0f, 0.0f, -1.0f);
80 glNormal3f(0.0f, 0.0f, -1.0f);
8081 }
8182 }
82
83 da = 2.0f * GLU.PI / slices;
83
84 da = 2.0f * PI / slices;
8485 dr = (outerRadius - innerRadius) / loops;
85
86
8687 switch (super.drawStyle) {
87 case GLU.GLU_FILL:
88 case GLU_FILL:
8889 {
8990 /* texture of a gluDisk is a cut out of the texture unit square
9091 * x, y in [-outerRadius, +outerRadius]; s, t in [0, 1]
9697 int l;
9798 for (l = 0; l < loops; l++) {
9899 float r2 = r1 + dr;
99 if (super.orientation == GLU.GLU_OUTSIDE) {
100 if (super.orientation == GLU_OUTSIDE) {
100101 int s;
101 GL11.glBegin(GL11.GL_QUAD_STRIP);
102 glBegin(GL_QUAD_STRIP);
102103 for (s = 0; s <= slices; s++) {
103104 float a;
104105 if (s == slices)
108109 sa = sin(a);
109110 ca = cos(a);
110111 TXTR_COORD(0.5f + sa * r2 / dtc, 0.5f + ca * r2 / dtc);
111 GL11.glVertex2f(r2 * sa, r2 * ca);
112 glVertex2f(r2 * sa, r2 * ca);
112113 TXTR_COORD(0.5f + sa * r1 / dtc, 0.5f + ca * r1 / dtc);
113 GL11.glVertex2f(r1 * sa, r1 * ca);
114 glVertex2f(r1 * sa, r1 * ca);
114115 }
115 GL11.glEnd();
116 glEnd();
116117 }
117118 else {
118119 int s;
119 GL11.glBegin(GL11.GL_QUAD_STRIP);
120 glBegin(GL_QUAD_STRIP);
120121 for (s = slices; s >= 0; s--) {
121122 float a;
122123 if (s == slices)
126127 sa = sin(a);
127128 ca = cos(a);
128129 TXTR_COORD(0.5f - sa * r2 / dtc, 0.5f + ca * r2 / dtc);
129 GL11.glVertex2f(r2 * sa, r2 * ca);
130 glVertex2f(r2 * sa, r2 * ca);
130131 TXTR_COORD(0.5f - sa * r1 / dtc, 0.5f + ca * r1 / dtc);
131 GL11.glVertex2f(r1 * sa, r1 * ca);
132 glVertex2f(r1 * sa, r1 * ca);
132133 }
133 GL11.glEnd();
134 glEnd();
134135 }
135136 r1 = r2;
136137 }
137138 break;
138139 }
139 case GLU.GLU_LINE:
140 case GLU_LINE:
140141 {
141142 int l, s;
142143 /* draw loops */
143144 for (l = 0; l <= loops; l++) {
144145 float r = innerRadius + l * dr;
145 GL11.glBegin(GL11.GL_LINE_LOOP);
146 glBegin(GL_LINE_LOOP);
146147 for (s = 0; s < slices; s++) {
147148 float a = s * da;
148 GL11.glVertex2f(r * sin(a), r * cos(a));
149 }
150 GL11.glEnd();
149 glVertex2f(r * sin(a), r * cos(a));
150 }
151 glEnd();
151152 }
152153 /* draw spokes */
153154 for (s = 0; s < slices; s++) {
154155 float a = s * da;
155156 float x = sin(a);
156157 float y = cos(a);
157 GL11.glBegin(GL11.GL_LINE_STRIP);
158 glBegin(GL_LINE_STRIP);
158159 for (l = 0; l <= loops; l++) {
159160 float r = innerRadius + l * dr;
160 GL11.glVertex2f(r * x, r * y);
161 }
162 GL11.glEnd();
163 }
164 break;
165 }
166 case GLU.GLU_POINT:
161 glVertex2f(r * x, r * y);
162 }
163 glEnd();
164 }
165 break;
166 }
167 case GLU_POINT:
167168 {
168169 int s;
169 GL11.glBegin(GL11.GL_POINTS);
170 glBegin(GL_POINTS);
170171 for (s = 0; s < slices; s++) {
171172 float a = s * da;
172173 float x = sin(a);
174175 int l;
175176 for (l = 0; l <= loops; l++) {
176177 float r = innerRadius * l * dr;
177 GL11.glVertex2f(r * x, r * y);
178 }
179 }
180 GL11.glEnd();
181 break;
182 }
183 case GLU.GLU_SILHOUETTE:
178 glVertex2f(r * x, r * y);
179 }
180 }
181 glEnd();
182 break;
183 }
184 case GLU_SILHOUETTE:
184185 {
185186 if (innerRadius != 0.0) {
186187 float a;
187 GL11.glBegin(GL11.GL_LINE_LOOP);
188 for (a = 0.0f; a < 2.0 * GLU.PI; a += da) {
188 glBegin(GL_LINE_LOOP);
189 for (a = 0.0f; a < 2.0 * PI; a += da) {
189190 float x = innerRadius * sin(a);
190191 float y = innerRadius * cos(a);
191 GL11.glVertex2f(x, y);
192 }
193 GL11.glEnd();
192 glVertex2f(x, y);
193 }
194 glEnd();
194195 }
195196 {
196197 float a;
197 GL11.glBegin(GL11.GL_LINE_LOOP);
198 for (a = 0; a < 2.0f * GLU.PI; a += da) {
198 glBegin(GL_LINE_LOOP);
199 for (a = 0; a < 2.0f * PI; a += da) {
199200 float x = outerRadius * sin(a);
200201 float y = outerRadius * cos(a);
201 GL11.glVertex2f(x, y);
202 }
203 GL11.glEnd();
202 glVertex2f(x, y);
203 }
204 glEnd();
204205 }
205206 break;
206207 }
3434 import java.nio.FloatBuffer;
3535 import java.nio.IntBuffer;
3636
37 import org.lwjgl.opengl.GL11;
3837 import org.lwjgl.opengl.Util;
3938 import org.lwjgl.util.glu.tessellation.GLUtessellatorImpl;
39
40 import static org.lwjgl.opengl.GL11.*;
4041
4142 /**
4243 * GLU.java
265266 float bottom,
266267 float top) {
267268
268 GL11.glOrtho(left, right, bottom, top, -1.0, 1.0);
269 glOrtho(left, right, bottom, top, -1.0, 1.0);
269270 }
270271
271272 /**
411412
412413 public static String gluErrorString(int error_code) {
413414 switch (error_code) {
414 case GLU.GLU_INVALID_ENUM:
415 case GLU_INVALID_ENUM:
415416 return "Invalid enum (glu)";
416 case GLU.GLU_INVALID_VALUE:
417 case GLU_INVALID_VALUE:
417418 return "Invalid value (glu)";
418 case GLU.GLU_OUT_OF_MEMORY:
419 case GLU_OUT_OF_MEMORY:
419420 return "Out of memory (glu)";
420421 default:
421422 return Util.translateGLErrorString(error_code);
422423 }
423424 }
424
425
425426 public static GLUtessellator gluNewTess() {
426427 return new GLUtessellatorImpl();
427428 }
3333
3434 public interface GLUtessellator {
3535
36 public abstract void gluDeleteTess();
36 void gluDeleteTess();
3737
38 public abstract void gluTessProperty(int which, double value);
38 void gluTessProperty(int which, double value);
3939
4040 /* Returns tessellator property */
41 public abstract void gluGetTessProperty(int which, double[] value,
41 void gluGetTessProperty(int which, double[] value,
4242 int value_offset); /* gluGetTessProperty() */
4343
44 public abstract void gluTessNormal(double x, double y, double z);
44 void gluTessNormal(double x, double y, double z);
4545
46 public abstract void gluTessCallback(int which,
46 void gluTessCallback(int which,
4747 GLUtessellatorCallback aCallback);
4848
49 public abstract void gluTessVertex(double[] coords, int coords_offset,
49 void gluTessVertex(double[] coords, int coords_offset,
5050 Object vertexData);
5151
52 public abstract void gluTessBeginPolygon(Object data);
52 void gluTessBeginPolygon(Object data);
5353
54 public abstract void gluTessBeginContour();
54 void gluTessBeginContour();
5555
56 public abstract void gluTessEndContour();
56 void gluTessEndContour();
5757
58 public abstract void gluTessEndPolygon();
58 void gluTessEndPolygon();
5959
6060 /*******************************************************/
6161
6262 /* Obsolete calls -- for backward compatibility */
6363
64 public abstract void gluBeginPolygon();
64 void gluBeginPolygon();
6565
6666 /*ARGSUSED*/
67 public abstract void gluNextContour(int type);
67 void gluNextContour(int type);
6868
69 public abstract void gluEndPolygon();
69 void gluEndPolygon();
7070
7171 }
111111 * @see #end end
112112 * @see #begin begin
113113 */
114 public void begin(int type);
114 void begin(int type);
115115
116116 /**
117117 * The same as the {@link #begin begin} callback method except that
130130 * @see #endData endData
131131 * @see #begin begin
132132 */
133 public void beginData(int type, Object polygonData);
133 void beginData(int type, Object polygonData);
134134
135135
136136 /**
157157 * @see GLU#gluTessCallback gluTessCallback
158158 * @see #edgeFlagData edgeFlagData
159159 */
160 public void edgeFlag(boolean boundaryEdge);
160 void edgeFlag(boolean boundaryEdge);
161161
162162
163163 /**
174174 * @see GLU#gluTessCallback gluTessCallback
175175 * @see #edgeFlag edgeFlag
176176 */
177 public void edgeFlagData(boolean boundaryEdge, Object polygonData);
177 void edgeFlagData(boolean boundaryEdge, Object polygonData);
178178
179179
180180 /**
194194 * @see GLU#gluTessCallback gluTessCallback
195195 * @see #vertexData vertexData
196196 */
197 public void vertex(Object vertexData);
197 void vertex(Object vertexData);
198198
199199
200200 /**
212212 * @see GLU#gluTessCallback gluTessCallback
213213 * @see #vertex vertex
214214 */
215 public void vertexData(Object vertexData, Object polygonData);
215 void vertexData(Object vertexData, Object polygonData);
216216
217217
218218 /**
224224 * @see #begin begin
225225 * @see #endData endData
226226 */
227 public void end();
227 void end();
228228
229229
230230 /**
240240 * @see #beginData beginData
241241 * @see #end end
242242 */
243 public void endData(Object polygonData);
243 void endData(Object polygonData);
244244
245245
246246 /**
307307 * @see GLU#gluTessCallback gluTessCallback
308308 * @see #combineData combineData
309309 */
310 public void combine(double[] coords, Object[] data,
311 float[] weight, Object[] outData);
310 void combine(double[] coords, Object[] data,
311 float[] weight, Object[] outData);
312312
313313
314314 /**
331331 * @see GLU#gluTessCallback gluTessCallback
332332 * @see #combine combine
333333 */
334 public void combineData(double[] coords, Object[] data,
335 float[] weight, Object[] outData,
336 Object polygonData);
334 void combineData(double[] coords, Object[] data,
335 float[] weight, Object[] outData,
336 Object polygonData);
337337
338338
339339 /**
364364 * @see GLU#gluTessCallback gluTessCallback
365365 * @see #errorData errorData
366366 */
367 public void error(int errnum);
367 void error(int errnum);
368368
369369
370370 /**
381381 * @see GLU#gluTessCallback gluTessCallback
382382 * @see #error error
383383 */
384 public void errorData(int errnum, Object polygonData);
384 void errorData(int errnum, Object polygonData);
385385
386386 //void mesh(com.sun.opengl.impl.tessellator.GLUmesh mesh);
387387 }
3333 import java.nio.ByteBuffer;
3434
3535 import org.lwjgl.BufferUtils;
36 import org.lwjgl.opengl.GL11;
36
37 import static org.lwjgl.opengl.GL11.*;
38 import static org.lwjgl.util.glu.GLU.*;
3739
3840 /**
3941 * MipMap.java
5961 public static int gluBuild2DMipmaps(final int target,
6062 final int components, final int width, final int height,
6163 final int format, final int type, final ByteBuffer data) {
62 if ( width < 1 || height < 1 ) return GLU.GLU_INVALID_VALUE;
64 if ( width < 1 || height < 1 ) return GLU_INVALID_VALUE;
6365
6466 final int bpp = bytesPerPixel(format, type);
6567 if ( bpp == 0 )
66 return GLU.GLU_INVALID_ENUM;
67
68 final int maxSize = glGetIntegerv(GL11.GL_MAX_TEXTURE_SIZE);
68 return GLU_INVALID_ENUM;
69
70 final int maxSize = glGetIntegerv(GL_MAX_TEXTURE_SIZE);
6971
7072 int w = nearestPower(width);
7173 if ( w > maxSize )
7981 PixelStoreState pss = new PixelStoreState();
8082
8183 // set pixel packing
82 GL11.glPixelStorei(GL11.GL_PACK_ROW_LENGTH, 0);
83 GL11.glPixelStorei(GL11.GL_PACK_ALIGNMENT, 1);
84 GL11.glPixelStorei(GL11.GL_PACK_SKIP_ROWS, 0);
85 GL11.glPixelStorei(GL11.GL_PACK_SKIP_PIXELS, 0);
84 glPixelStorei(GL_PACK_ROW_LENGTH, 0);
85 glPixelStorei(GL_PACK_ALIGNMENT, 1);
86 glPixelStorei(GL_PACK_SKIP_ROWS, 0);
87 glPixelStorei(GL_PACK_SKIP_PIXELS, 0);
8688
8789 ByteBuffer image;
8890 int retVal = 0;
98100 }
99101
100102 /* set pixel unpacking */
101 GL11.glPixelStorei(GL11.GL_UNPACK_ROW_LENGTH, 0);
102 GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);
103 GL11.glPixelStorei(GL11.GL_UNPACK_SKIP_ROWS, 0);
104 GL11.glPixelStorei(GL11.GL_UNPACK_SKIP_PIXELS, 0);
103 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
104 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
105 glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
106 glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
105107 } else {
106108 image = data;
107109 }
113115 while ( !done ) {
114116 if (image != data) {
115117 /* set pixel unpacking */
116 GL11.glPixelStorei(GL11.GL_UNPACK_ROW_LENGTH, 0);
117 GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);
118 GL11.glPixelStorei(GL11.GL_UNPACK_SKIP_ROWS, 0);
119 GL11.glPixelStorei(GL11.GL_UNPACK_SKIP_PIXELS, 0);
120 }
121
122 GL11.glTexImage2D(target, level, components, w, h, 0, format, type, image);
118 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
119 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
120 glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
121 glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
122 }
123
124 glTexImage2D(target, level, components, w, h, 0, format, type, image);
123125
124126 if ( w == 1 && h == 1 )
125127 break;
176178
177179 final int components = compPerPix(format);
178180 if ( components == -1 )
179 return GLU.GLU_INVALID_ENUM;
181 return GLU_INVALID_ENUM;
180182
181183 int i, j, k;
182184 float[] tempIn, tempOut;
190192
191193 // Determine bytes per input type
192194 switch ( typein ) {
193 case GL11.GL_UNSIGNED_BYTE:
195 case GL_UNSIGNED_BYTE:
194196 sizein = 1;
195197 break;
196 case GL11.GL_FLOAT:
198 case GL_FLOAT:
197199 sizein = 4;
198 break;
200 break;
199201 default:
200 return GL11.GL_INVALID_ENUM;
202 return GL_INVALID_ENUM;
201203 }
202204
203205 // Determine bytes per output type
204206 switch ( typeOut ) {
205 case GL11.GL_UNSIGNED_BYTE:
207 case GL_UNSIGNED_BYTE:
206208 sizeout = 1;
207209 break;
208 case GL11.GL_FLOAT:
210 case GL_FLOAT:
209211 sizeout = 4;
210 break;
212 break;
211213 default:
212 return GL11.GL_INVALID_ENUM;
214 return GL_INVALID_ENUM;
213215 }
214216
215217 // Get glPixelStore state
227229 rowstride = pss.unpackAlignment / sizein * ceil(components * rowlen * sizein, pss.unpackAlignment);
228230
229231 switch ( typein ) {
230 case GL11.GL_UNSIGNED_BYTE:
232 case GL_UNSIGNED_BYTE:
231233 k = 0;
232234 dataIn.rewind();
233235 for ( i = 0; i < heightIn; i++ ) {
237239 }
238240 }
239241 break;
240 case GL11.GL_FLOAT:
242 case GL_FLOAT:
241243 k = 0;
242244 dataIn.rewind();
243245 for ( i = 0; i < heightIn; i++ )
249251 fptr += 4;
250252 }
251253 }
252 break;
254 break;
253255 default:
254 return GLU.GLU_INVALID_ENUM;
256 return GLU_INVALID_ENUM;
255257 }
256258
257259 // Do scaling
320322 rowstride = pss.packAlignment / sizeout * ceil(components * rowlen * sizeout, pss.packAlignment);
321323
322324 switch ( typeOut ) {
323 case GL11.GL_UNSIGNED_BYTE:
325 case GL_UNSIGNED_BYTE:
324326 k = 0;
325327 for ( i = 0; i < heightOut; i++ ) {
326328 int ubptr = i * rowstride + pss.packSkipRows * rowstride + pss.packSkipPixels * components;
330332 }
331333 }
332334 break;
333 case GL11.GL_FLOAT:
335 case GL_FLOAT:
334336 k = 0;
335337 for ( i = 0; i < heightOut; i++ ) {
336338 int fptr = 4 * (i * rowstride + pss.unpackSkipRows * rowstride + pss.unpackSkipPixels * components);
337
339
338340 for ( j = 0; j < widthOut * components; j++ ) {
339341 dataOut.putFloat(fptr, tempOut[k++]);
340342 fptr += 4;
341343 }
342344 }
343 break;
345 break;
344346 default:
345 return GLU.GLU_INVALID_ENUM;
347 return GLU_INVALID_ENUM;
346348 }
347349
348350 return 0;
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 package org.lwjgl.util.glu;
3232
33 import org.lwjgl.opengl.GL11;
33 import static org.lwjgl.opengl.GL11.*;
34 import static org.lwjgl.util.glu.GLU.*;
3435
3536 /**
3637 * PartialDisk.java
37 *
38 *
38 *
39 *
3940 * Created 23-dec-2003
40 *
41 *
4142 * @author Erik Duijs
4243 */
4344 public class PartialDisk extends Quadric {
5758 * through startAngle + sweepAngle is included (where 0 degrees is along
5859 * the +y axis, 90 degrees along the +x axis, 180 along the -y axis, and
5960 * 270 along the -x axis).
60 *
61 *
6162 * The partial disk has a radius of outerRadius, and contains a concentric
6263 * circular hole with a radius of innerRadius. If innerRadius is zero, then
6364 * no hole is generated. The partial disk is subdivided around the z axis
6465 * into slices (like pizza slices), and also about the z axis into rings
6566 * (as specified by slices and loops, respectively).
66 *
67 *
6768 * With respect to orientation, the +z side of the partial disk is
6869 * considered to be outside (see gluQuadricOrientation). This means that if
6970 * the orientation is set to GLU.GLU_OUTSIDE, then any normals generated point
7071 * along the +z axis. Otherwise, they point along the -z axis.
71 *
72 *
7273 * If texturing is turned on (with gluQuadricTexture), texture coordinates
7374 * are generated linearly such that where r=outerRadius, the value at (r, 0, 0)
7475 * is (1, 0.5), at (0, r, 0) it is (0.5, 1), at (-r, 0, 0) it is (0, 0.5),
126127
127128 /* Cache is the vertex locations cache */
128129
129 angleOffset = startAngle / 180.0f * GLU.PI;
130 angleOffset = startAngle / 180.0f * PI;
130131 for (i = 0; i <= slices; i++) {
131 angle = angleOffset + ((GLU.PI * sweepAngle) / 180.0f) * i / slices;
132 angle = angleOffset + ((PI * sweepAngle) / 180.0f) * i / slices;
132133 sinCache[i] = sin(angle);
133134 cosCache[i] = cos(angle);
134135 }
139140 }
140141
141142 switch (super.normals) {
142 case GLU.GLU_FLAT :
143 case GLU.GLU_SMOOTH :
144 if (super.orientation == GLU.GLU_OUTSIDE) {
145 GL11.glNormal3f(0.0f, 0.0f, 1.0f);
143 case GLU_FLAT :
144 case GLU_SMOOTH :
145 if (super.orientation == GLU_OUTSIDE) {
146 glNormal3f(0.0f, 0.0f, 1.0f);
146147 } else {
147 GL11.glNormal3f(0.0f, 0.0f, -1.0f);
148 glNormal3f(0.0f, 0.0f, -1.0f);
148149 }
149150 break;
150151 default :
151 case GLU.GLU_NONE :
152 case GLU_NONE :
152153 break;
153154 }
154155
155156 switch (super.drawStyle) {
156 case GLU.GLU_FILL :
157 case GLU_FILL :
157158 if (innerRadius == .0f) {
158159 finish = loops - 1;
159160 /* Triangle strip for inner polygons */
160 GL11.glBegin(GL11.GL_TRIANGLE_FAN);
161 if (super.textureFlag) {
162 GL11.glTexCoord2f(0.5f, 0.5f);
163 }
164 GL11.glVertex3f(0.0f, 0.0f, 0.0f);
161 glBegin(GL_TRIANGLE_FAN);
162 if (super.textureFlag) {
163 glTexCoord2f(0.5f, 0.5f);
164 }
165 glVertex3f(0.0f, 0.0f, 0.0f);
165166 radiusLow = outerRadius - deltaRadius * ((float) (loops - 1) / loops);
166167 if (super.textureFlag) {
167168 texLow = radiusLow / outerRadius / 2;
168169 }
169170
170 if (super.orientation == GLU.GLU_OUTSIDE) {
171 if (super.orientation == GLU_OUTSIDE) {
171172 for (i = slices; i >= 0; i--) {
172173 if (super.textureFlag) {
173 GL11.glTexCoord2f(
174 texLow * sinCache[i] + 0.5f,
175 texLow * cosCache[i] + 0.5f);
176 }
177 GL11.glVertex3f(radiusLow * sinCache[i], radiusLow * cosCache[i], 0.0f);
174 glTexCoord2f(
175 texLow * sinCache[i] + 0.5f,
176 texLow * cosCache[i] + 0.5f);
177 }
178 glVertex3f(radiusLow * sinCache[i], radiusLow * cosCache[i], 0.0f);
178179 }
179180 } else {
180181 for (i = 0; i <= slices; i++) {
181182 if (super.textureFlag) {
182 GL11.glTexCoord2f(
183 texLow * sinCache[i] + 0.5f,
184 texLow * cosCache[i] + 0.5f);
185 }
186 GL11.glVertex3f(radiusLow * sinCache[i], radiusLow * cosCache[i], 0.0f);
187 }
188 }
189 GL11.glEnd();
183 glTexCoord2f(
184 texLow * sinCache[i] + 0.5f,
185 texLow * cosCache[i] + 0.5f);
186 }
187 glVertex3f(radiusLow * sinCache[i], radiusLow * cosCache[i], 0.0f);
188 }
189 }
190 glEnd();
190191 } else {
191192 finish = loops;
192193 }
198199 texHigh = radiusHigh / outerRadius / 2;
199200 }
200201
201 GL11.glBegin(GL11.GL_QUAD_STRIP);
202 glBegin(GL_QUAD_STRIP);
202203 for (i = 0; i <= slices; i++) {
203 if (super.orientation == GLU.GLU_OUTSIDE) {
204 if (super.textureFlag) {
205 GL11.glTexCoord2f(
206 texLow * sinCache[i] + 0.5f,
207 texLow * cosCache[i] + 0.5f);
208 }
209 GL11.glVertex3f(radiusLow * sinCache[i], radiusLow * cosCache[i], 0.0f);
210
211 if (super.textureFlag) {
212 GL11.glTexCoord2f(
204 if (super.orientation == GLU_OUTSIDE) {
205 if (super.textureFlag) {
206 glTexCoord2f(
207 texLow * sinCache[i] + 0.5f,
208 texLow * cosCache[i] + 0.5f);
209 }
210 glVertex3f(radiusLow * sinCache[i], radiusLow * cosCache[i], 0.0f);
211
212 if (super.textureFlag) {
213 glTexCoord2f(
213214 texHigh * sinCache[i] + 0.5f,
214215 texHigh * cosCache[i] + 0.5f);
215216 }
216 GL11.glVertex3f(
217 glVertex3f(
217218 radiusHigh * sinCache[i],
218219 radiusHigh * cosCache[i],
219220 0.0f);
220221 } else {
221222 if (super.textureFlag) {
222 GL11.glTexCoord2f(
223 glTexCoord2f(
223224 texHigh * sinCache[i] + 0.5f,
224225 texHigh * cosCache[i] + 0.5f);
225226 }
226 GL11.glVertex3f(
227 glVertex3f(
227228 radiusHigh * sinCache[i],
228229 radiusHigh * cosCache[i],
229230 0.0f);
230231
231232 if (super.textureFlag) {
232 GL11.glTexCoord2f(
233 texLow * sinCache[i] + 0.5f,
234 texLow * cosCache[i] + 0.5f);
235 }
236 GL11.glVertex3f(radiusLow * sinCache[i], radiusLow * cosCache[i], 0.0f);
237 }
238 }
239 GL11.glEnd();
240 }
241 break;
242 case GLU.GLU_POINT :
243 GL11.glBegin(GL11.GL_POINTS);
233 glTexCoord2f(
234 texLow * sinCache[i] + 0.5f,
235 texLow * cosCache[i] + 0.5f);
236 }
237 glVertex3f(radiusLow * sinCache[i], radiusLow * cosCache[i], 0.0f);
238 }
239 }
240 glEnd();
241 }
242 break;
243 case GLU_POINT :
244 glBegin(GL_POINTS);
244245 for (i = 0; i < slices2; i++) {
245246 sintemp = sinCache[i];
246247 costemp = cosCache[i];
250251 if (super.textureFlag) {
251252 texLow = radiusLow / outerRadius / 2;
252253
253 GL11.glTexCoord2f(
254 glTexCoord2f(
254255 texLow * sinCache[i] + 0.5f,
255256 texLow * cosCache[i] + 0.5f);
256257 }
257 GL11.glVertex3f(radiusLow * sintemp, radiusLow * costemp, 0.0f);
258 }
259 }
260 GL11.glEnd();
261 break;
262 case GLU.GLU_LINE :
258 glVertex3f(radiusLow * sintemp, radiusLow * costemp, 0.0f);
259 }
260 }
261 glEnd();
262 break;
263 case GLU_LINE :
263264 if (innerRadius == outerRadius) {
264 GL11.glBegin(GL11.GL_LINE_STRIP);
265 glBegin(GL_LINE_STRIP);
265266
266267 for (i = 0; i <= slices; i++) {
267268 if (super.textureFlag) {
268 GL11.glTexCoord2f(sinCache[i] / 2 + 0.5f, cosCache[i] / 2 + 0.5f);
269 }
270 GL11.glVertex3f(innerRadius * sinCache[i], innerRadius * cosCache[i], 0.0f);
271 }
272 GL11.glEnd();
269 glTexCoord2f(sinCache[i] / 2 + 0.5f, cosCache[i] / 2 + 0.5f);
270 }
271 glVertex3f(innerRadius * sinCache[i], innerRadius * cosCache[i], 0.0f);
272 }
273 glEnd();
273274 break;
274275 }
275276 for (j = 0; j <= loops; j++) {
278279 texLow = radiusLow / outerRadius / 2;
279280 }
280281
281 GL11.glBegin(GL11.GL_LINE_STRIP);
282 glBegin(GL_LINE_STRIP);
282283 for (i = 0; i <= slices; i++) {
283284 if (super.textureFlag) {
284 GL11.glTexCoord2f(
285 glTexCoord2f(
285286 texLow * sinCache[i] + 0.5f,
286287 texLow * cosCache[i] + 0.5f);
287288 }
288 GL11.glVertex3f(radiusLow * sinCache[i], radiusLow * cosCache[i], 0.0f);
289 }
290 GL11.glEnd();
289 glVertex3f(radiusLow * sinCache[i], radiusLow * cosCache[i], 0.0f);
290 }
291 glEnd();
291292 }
292293 for (i = 0; i < slices2; i++) {
293294 sintemp = sinCache[i];
294295 costemp = cosCache[i];
295 GL11.glBegin(GL11.GL_LINE_STRIP);
296 glBegin(GL_LINE_STRIP);
296297 for (j = 0; j <= loops; j++) {
297298 radiusLow = outerRadius - deltaRadius * ((float) j / loops);
298299 if (super.textureFlag) {
300301 }
301302
302303 if (super.textureFlag) {
303 GL11.glTexCoord2f(
304 glTexCoord2f(
304305 texLow * sinCache[i] + 0.5f,
305306 texLow * cosCache[i] + 0.5f);
306307 }
307 GL11.glVertex3f(radiusLow * sintemp, radiusLow * costemp, 0.0f);
308 }
309 GL11.glEnd();
310 }
311 break;
312 case GLU.GLU_SILHOUETTE :
308 glVertex3f(radiusLow * sintemp, radiusLow * costemp, 0.0f);
309 }
310 glEnd();
311 }
312 break;
313 case GLU_SILHOUETTE :
313314 if (sweepAngle < 360.0f) {
314315 for (i = 0; i <= slices; i += slices) {
315316 sintemp = sinCache[i];
316317 costemp = cosCache[i];
317 GL11.glBegin(GL11.GL_LINE_STRIP);
318 glBegin(GL_LINE_STRIP);
318319 for (j = 0; j <= loops; j++) {
319320 radiusLow = outerRadius - deltaRadius * ((float) j / loops);
320321
321322 if (super.textureFlag) {
322323 texLow = radiusLow / outerRadius / 2;
323 GL11.glTexCoord2f(
324 texLow * sinCache[i] + 0.5f,
325 texLow * cosCache[i] + 0.5f);
326 }
327 GL11.glVertex3f(radiusLow * sintemp, radiusLow * costemp, 0.0f);
328 }
329 GL11.glEnd();
324 glTexCoord2f(
325 texLow * sinCache[i] + 0.5f,
326 texLow * cosCache[i] + 0.5f);
327 }
328 glVertex3f(radiusLow * sintemp, radiusLow * costemp, 0.0f);
329 }
330 glEnd();
330331 }
331332 }
332333 for (j = 0; j <= loops; j += loops) {
335336 texLow = radiusLow / outerRadius / 2;
336337 }
337338
338 GL11.glBegin(GL11.GL_LINE_STRIP);
339 glBegin(GL_LINE_STRIP);
339340 for (i = 0; i <= slices; i++) {
340341 if (super.textureFlag) {
341 GL11.glTexCoord2f(
342 glTexCoord2f(
342343 texLow * sinCache[i] + 0.5f,
343344 texLow * cosCache[i] + 0.5f);
344345 }
345 GL11.glVertex3f(radiusLow * sinCache[i], radiusLow * cosCache[i], 0.0f);
346 }
347 GL11.glEnd();
346 glVertex3f(radiusLow * sinCache[i], radiusLow * cosCache[i], 0.0f);
347 }
348 glEnd();
348349 if (innerRadius == outerRadius)
349350 break;
350351 }
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 package org.lwjgl.util.glu;
3232
33 import org.lwjgl.opengl.GL11;
33 import static org.lwjgl.opengl.GL11.*;
3434
3535 /**
3636 * PixelStoreState.java
5959 }
6060
6161 public void load() {
62 unpackRowLength = glGetIntegerv(GL11.GL_UNPACK_ROW_LENGTH);
63 unpackAlignment = glGetIntegerv(GL11.GL_UNPACK_ALIGNMENT);
64 unpackSkipRows = glGetIntegerv(GL11.GL_UNPACK_SKIP_ROWS);
65 unpackSkipPixels = glGetIntegerv(GL11.GL_UNPACK_SKIP_PIXELS);
66 packRowLength = glGetIntegerv(GL11.GL_PACK_ROW_LENGTH);
67 packAlignment = glGetIntegerv(GL11.GL_PACK_ALIGNMENT);
68 packSkipRows = glGetIntegerv(GL11.GL_PACK_SKIP_ROWS);
69 packSkipPixels = glGetIntegerv(GL11.GL_PACK_SKIP_PIXELS);
62 unpackRowLength = glGetIntegerv(GL_UNPACK_ROW_LENGTH);
63 unpackAlignment = glGetIntegerv(GL_UNPACK_ALIGNMENT);
64 unpackSkipRows = glGetIntegerv(GL_UNPACK_SKIP_ROWS);
65 unpackSkipPixels = glGetIntegerv(GL_UNPACK_SKIP_PIXELS);
66 packRowLength = glGetIntegerv(GL_PACK_ROW_LENGTH);
67 packAlignment = glGetIntegerv(GL_PACK_ALIGNMENT);
68 packSkipRows = glGetIntegerv(GL_PACK_SKIP_ROWS);
69 packSkipPixels = glGetIntegerv(GL_PACK_SKIP_PIXELS);
7070 }
7171
7272 public void save() {
73 GL11.glPixelStorei(GL11.GL_UNPACK_ROW_LENGTH, unpackRowLength);
74 GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, unpackAlignment);
75 GL11.glPixelStorei(GL11.GL_UNPACK_SKIP_ROWS, unpackSkipRows);
76 GL11.glPixelStorei(GL11.GL_UNPACK_SKIP_PIXELS, unpackSkipPixels);
77 GL11.glPixelStorei(GL11.GL_PACK_ROW_LENGTH, packRowLength);
78 GL11.glPixelStorei(GL11.GL_PACK_ALIGNMENT, packAlignment);
79 GL11.glPixelStorei(GL11.GL_PACK_SKIP_ROWS, packSkipRows);
80 GL11.glPixelStorei(GL11.GL_PACK_SKIP_PIXELS, packSkipPixels);
73 glPixelStorei(GL_UNPACK_ROW_LENGTH, unpackRowLength);
74 glPixelStorei(GL_UNPACK_ALIGNMENT, unpackAlignment);
75 glPixelStorei(GL_UNPACK_SKIP_ROWS, unpackSkipRows);
76 glPixelStorei(GL_UNPACK_SKIP_PIXELS, unpackSkipPixels);
77 glPixelStorei(GL_PACK_ROW_LENGTH, packRowLength);
78 glPixelStorei(GL_PACK_ALIGNMENT, packAlignment);
79 glPixelStorei(GL_PACK_SKIP_ROWS, packSkipRows);
80 glPixelStorei(GL_PACK_SKIP_PIXELS, packSkipPixels);
8181 }
8282
8383 }
00 /*
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 */
3535
3636 import org.lwjgl.BufferUtils;
3737 import org.lwjgl.opengl.GL11;
38
39 import static org.lwjgl.opengl.GL11.*;
3840
3941 /**
4042 * Project.java
4143 * <p/>
4244 * <p/>
4345 * Created 11-jan-2004
44 *
46 *
4547 * @author Erik Duijs
4648 */
4749 public class Project extends Util {
7577
7678 /**
7779 * Method __gluMultMatrixVecf
78 *
80 *
7981 * @param finalMatrix
8082 * @param in
8183 * @param out
9496 /**
9597 * @param src
9698 * @param inverse
97 *
99 *
98100 * @return
99101 */
100102 private static boolean __gluInvertMatrixf(FloatBuffer src, FloatBuffer inverse) {
184186
185187 /**
186188 * Method gluPerspective.
187 *
189 *
188190 * @param fovy
189191 * @param aspect
190192 * @param zNear
212214 matrix.put(3 * 4 + 2, -2 * zNear * zFar / deltaZ);
213215 matrix.put(3 * 4 + 3, 0);
214216
215 GL11.glMultMatrix(matrix);
217 glMultMatrix(matrix);
216218 }
217219
218220 /**
219221 * Method gluLookAt
220 *
222 *
221223 * @param eyex
222224 * @param eyey
223225 * @param eyez
272274 matrix.put(1 * 4 + 2, -forward[1]);
273275 matrix.put(2 * 4 + 2, -forward[2]);
274276
275 GL11.glMultMatrix(matrix);
276 GL11.glTranslatef(-eyex, -eyey, -eyez);
277 glMultMatrix(matrix);
278 glTranslatef(-eyex, -eyey, -eyez);
277279 }
278280
279281 /**
280282 * Method gluProject
281 *
283 *
282284 * @param objx
283285 * @param objy
284286 * @param objz
327329
328330 /**
329331 * Method gluUnproject
330 *
332 *
331333 * @param winx
332334 * @param winy
333335 * @param winz
382384
383385 /**
384386 * Method gluPickMatrix
385 *
387 *
386388 * @param x
387389 * @param y
388390 * @param deltaX
400402 }
401403
402404 /* Translate and scale the picked region to the entire window */
403 GL11.glTranslatef(
405 glTranslatef(
404406 (viewport.get(viewport.position() + 2) - 2 * (x - viewport.get(viewport.position() + 0))) / deltaX,
405407 (viewport.get(viewport.position() + 3) - 2 * (y - viewport.get(viewport.position() + 1))) / deltaY,
406408 0);
407 GL11.glScalef(viewport.get(viewport.position() + 2) / deltaX, viewport.get(viewport.position() + 3) / deltaY, 1.0f);
409 glScalef(viewport.get(viewport.position() + 2) / deltaX, viewport.get(viewport.position() + 3) / deltaY, 1.0f);
408410 }
409411 }
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 package org.lwjgl.util.glu;
3232
33 import org.lwjgl.opengl.GL11;
33 import static org.lwjgl.opengl.GL11.*;
34 import static org.lwjgl.util.glu.GLU.*;
3435
3536 /**
3637 * Quadric.java
37 *
38 *
38 *
39 *
3940 * Created 22-dec-2003
4041 * @author Erik Duijs
4142 */
4243 public class Quadric {
43
44
4445 protected int drawStyle;
4546 protected int orientation;
4647 protected boolean textureFlag;
4748 protected int normals;
48
49
4950 /**
5051 * Constructor for Quadric.
5152 */
5253 public Quadric() {
5354 super();
54
55 drawStyle = GLU.GLU_FILL;
56 orientation = GLU.GLU_OUTSIDE;
55
56 drawStyle = GLU_FILL;
57 orientation = GLU_OUTSIDE;
5758 textureFlag = false;
58 normals = GLU.GLU_SMOOTH;
59 normals = GLU_SMOOTH;
5960 }
6061
6162 /**
6768 */
6869 protected void normal3f(float x, float y, float z) {
6970 float mag;
70
71
7172 mag = (float)Math.sqrt(x * x + y * y + z * z);
7273 if (mag > 0.00001F) {
7374 x /= mag;
7475 y /= mag;
7576 z /= mag;
7677 }
77 GL11.glNormal3f(x, y, z);
78 glNormal3f(x, y, z);
7879 }
7980
8081 /**
81 * specifies the draw style for quadrics.
82 * specifies the draw style for quadrics.
8283 *
8384 * The legal values are as follows:
8485 *
9293 * separating coplanar faces will not be drawn.
9394 *
9495 * GLU.POINT: Quadrics are rendered as a set of points.
95 *
96 *
9697 * @param drawStyle The drawStyle to set
9798 */
9899 public void setDrawStyle(int drawStyle) {
109110 *
110111 * GLU.SMOOTH: One normal is generated for every vertex of a quadric. This
111112 * is the default.
112 *
113 *
113114 * @param normals The normals to set
114115 */
115116 public void setNormals(int normals) {
126127 *
127128 * Note that the interpretation of outward and inward depends on the quadric
128129 * being drawn.
129 *
130 *
130131 * @param orientation The orientation to set
131132 */
132133 public void setOrientation(int orientation) {
141142 *
142143 * The manner in which texture coordinates are generated depends upon the
143144 * specific quadric rendered.
144 *
145 *
145146 * @param textureFlag The textureFlag to set
146147 */
147148 public void setTextureFlag(boolean textureFlag) {
148149 this.textureFlag = textureFlag;
149150 }
150
151
151152
152153 /**
153154 * Returns the drawStyle.
182183 }
183184
184185 protected void TXTR_COORD(float x, float y) {
185 if (textureFlag) GL11.glTexCoord2f(x,y);
186 if (textureFlag) glTexCoord2f(x,y);
186187 }
187188
188189
00 /*
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 package org.lwjgl.util.glu;
32
33 import static org.lwjgl.util.glu.GLU.*;
3234
3335 /**
3436 * Registry.java
5052 */
5153 public static String gluGetString(int name) {
5254
53 if (name == GLU.GLU_VERSION) {
55 if (name == GLU_VERSION) {
5456 return versionString;
55 } else if (name == GLU.GLU_EXTENSIONS) {
57 } else if (name == GLU_EXTENSIONS) {
5658 return extensionString;
5759 }
5860 return null;
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 package org.lwjgl.util.glu;
3232
33
34 import org.lwjgl.opengl.GL11;
33 import static org.lwjgl.opengl.GL11.*;
34 import static org.lwjgl.util.glu.GLU.*;
3535
3636 /**
3737 * Sphere.java
7474 boolean normals;
7575 float nsign;
7676
77 normals = super.normals != GLU.GLU_NONE;
78
79 if (super.orientation == GLU.GLU_INSIDE) {
77 normals = super.normals != GLU_NONE;
78
79 if (super.orientation == GLU_INSIDE) {
8080 nsign = -1.0f;
8181 } else {
8282 nsign = 1.0f;
8383 }
8484
85 drho = GLU.PI / stacks;
86 dtheta = 2.0f * GLU.PI / slices;
87
88 if (super.drawStyle == GLU.GLU_FILL) {
85 drho = PI / stacks;
86 dtheta = 2.0f * PI / slices;
87
88 if (super.drawStyle == GLU_FILL) {
8989 if (!super.textureFlag) {
9090 // draw +Z end as a triangle fan
91 GL11.glBegin(GL11.GL_TRIANGLE_FAN);
92 GL11.glNormal3f(0.0f, 0.0f, 1.0f);
93 GL11.glVertex3f(0.0f, 0.0f, nsign * radius);
91 glBegin(GL_TRIANGLE_FAN);
92 glNormal3f(0.0f, 0.0f, 1.0f);
93 glVertex3f(0.0f, 0.0f, nsign * radius);
9494 for (j = 0; j <= slices; j++) {
9595 theta = (j == slices) ? 0.0f : j * dtheta;
9696 x = -sin(theta) * sin(drho);
9797 y = cos(theta) * sin(drho);
9898 z = nsign * cos(drho);
9999 if (normals) {
100 GL11.glNormal3f(x * nsign, y * nsign, z * nsign);
100 glNormal3f(x * nsign, y * nsign, z * nsign);
101101 }
102 GL11.glVertex3f(x * radius, y * radius, z * radius);
103 }
104 GL11.glEnd();
102 glVertex3f(x * radius, y * radius, z * radius);
103 }
104 glEnd();
105105 }
106106
107107 ds = 1.0f / slices;
118118 // draw intermediate stacks as quad strips
119119 for (i = imin; i < imax; i++) {
120120 rho = i * drho;
121 GL11.glBegin(GL11.GL_QUAD_STRIP);
121 glBegin(GL_QUAD_STRIP);
122122 s = 0.0f;
123123 for (j = 0; j <= slices; j++) {
124124 theta = (j == slices) ? 0.0f : j * dtheta;
126126 y = cos(theta) * sin(rho);
127127 z = nsign * cos(rho);
128128 if (normals) {
129 GL11.glNormal3f(x * nsign, y * nsign, z * nsign);
129 glNormal3f(x * nsign, y * nsign, z * nsign);
130130 }
131131 TXTR_COORD(s, t);
132 GL11.glVertex3f(x * radius, y * radius, z * radius);
132 glVertex3f(x * radius, y * radius, z * radius);
133133 x = -sin(theta) * sin(rho + drho);
134134 y = cos(theta) * sin(rho + drho);
135135 z = nsign * cos(rho + drho);
136136 if (normals) {
137 GL11.glNormal3f(x * nsign, y * nsign, z * nsign);
137 glNormal3f(x * nsign, y * nsign, z * nsign);
138138 }
139139 TXTR_COORD(s, t - dt);
140140 s += ds;
141 GL11.glVertex3f(x * radius, y * radius, z * radius);
142 }
143 GL11.glEnd();
141 glVertex3f(x * radius, y * radius, z * radius);
142 }
143 glEnd();
144144 t -= dt;
145145 }
146146
147147 if (!super.textureFlag) {
148148 // draw -Z end as a triangle fan
149 GL11.glBegin(GL11.GL_TRIANGLE_FAN);
150 GL11.glNormal3f(0.0f, 0.0f, -1.0f);
151 GL11.glVertex3f(0.0f, 0.0f, -radius * nsign);
152 rho = GLU.PI - drho;
149 glBegin(GL_TRIANGLE_FAN);
150 glNormal3f(0.0f, 0.0f, -1.0f);
151 glVertex3f(0.0f, 0.0f, -radius * nsign);
152 rho = PI - drho;
153153 s = 1.0f;
154154 for (j = slices; j >= 0; j--) {
155155 theta = (j == slices) ? 0.0f : j * dtheta;
157157 y = cos(theta) * sin(rho);
158158 z = nsign * cos(rho);
159159 if (normals)
160 GL11.glNormal3f(x * nsign, y * nsign, z * nsign);
160 glNormal3f(x * nsign, y * nsign, z * nsign);
161161 s -= ds;
162 GL11.glVertex3f(x * radius, y * radius, z * radius);
163 }
164 GL11.glEnd();
162 glVertex3f(x * radius, y * radius, z * radius);
163 }
164 glEnd();
165165 }
166166 } else if (
167 super.drawStyle == GLU.GLU_LINE
168 || super.drawStyle == GLU.GLU_SILHOUETTE) {
167 super.drawStyle == GLU_LINE
168 || super.drawStyle == GLU_SILHOUETTE) {
169169 // draw stack lines
170170 for (i = 1;
171171 i < stacks;
172172 i++) { // stack line at i==stacks-1 was missing here
173173 rho = i * drho;
174 GL11.glBegin(GL11.GL_LINE_LOOP);
174 glBegin(GL_LINE_LOOP);
175175 for (j = 0; j < slices; j++) {
176176 theta = j * dtheta;
177177 x = cos(theta) * sin(rho);
178178 y = sin(theta) * sin(rho);
179179 z = cos(rho);
180180 if (normals)
181 GL11.glNormal3f(x * nsign, y * nsign, z * nsign);
182 GL11.glVertex3f(x * radius, y * radius, z * radius);
183 }
184 GL11.glEnd();
181 glNormal3f(x * nsign, y * nsign, z * nsign);
182 glVertex3f(x * radius, y * radius, z * radius);
183 }
184 glEnd();
185185 }
186186 // draw slice lines
187187 for (j = 0; j < slices; j++) {
188188 theta = j * dtheta;
189 GL11.glBegin(GL11.GL_LINE_STRIP);
189 glBegin(GL_LINE_STRIP);
190190 for (i = 0; i <= stacks; i++) {
191191 rho = i * drho;
192192 x = cos(theta) * sin(rho);
193193 y = sin(theta) * sin(rho);
194194 z = cos(rho);
195195 if (normals)
196 GL11.glNormal3f(x * nsign, y * nsign, z * nsign);
197 GL11.glVertex3f(x * radius, y * radius, z * radius);
198 }
199 GL11.glEnd();
200 }
201 } else if (super.drawStyle == GLU.GLU_POINT) {
196 glNormal3f(x * nsign, y * nsign, z * nsign);
197 glVertex3f(x * radius, y * radius, z * radius);
198 }
199 glEnd();
200 }
201 } else if (super.drawStyle == GLU_POINT) {
202202 // top and bottom-most points
203 GL11.glBegin(GL11.GL_POINTS);
203 glBegin(GL_POINTS);
204204 if (normals)
205 GL11.glNormal3f(0.0f, 0.0f, nsign);
206 GL11.glVertex3f(0.0f, 0.0f, radius);
205 glNormal3f(0.0f, 0.0f, nsign);
206 glVertex3f(0.0f, 0.0f, radius);
207207 if (normals)
208 GL11.glNormal3f(0.0f, 0.0f, -nsign);
209 GL11.glVertex3f(0.0f, 0.0f, -radius);
208 glNormal3f(0.0f, 0.0f, -nsign);
209 glVertex3f(0.0f, 0.0f, -radius);
210210
211211 // loop over stacks
212212 for (i = 1; i < stacks - 1; i++) {
217217 y = sin(theta) * sin(rho);
218218 z = cos(rho);
219219 if (normals)
220 GL11.glNormal3f(x * nsign, y * nsign, z * nsign);
221 GL11.glVertex3f(x * radius, y * radius, z * radius);
222 }
223 }
224 GL11.glEnd();
220 glNormal3f(x * nsign, y * nsign, z * nsign);
221 glVertex3f(x * radius, y * radius, z * radius);
222 }
223 }
224 glEnd();
225225 }
226226 }
227227
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 */
3333 import java.nio.IntBuffer;
3434
3535 import org.lwjgl.BufferUtils;
36 import org.lwjgl.opengl.GL11;
37 import org.lwjgl.opengl.GL12;
36
37 import static org.lwjgl.opengl.GL11.*;
38 import static org.lwjgl.opengl.GL12.*;
3839
3940 /**
4041 * Util.java
109110 protected static int compPerPix(int format) {
110111 /* Determine number of components per pixel */
111112 switch ( format ) {
112 case GL11.GL_COLOR_INDEX:
113 case GL11.GL_STENCIL_INDEX:
114 case GL11.GL_DEPTH_COMPONENT:
115 case GL11.GL_RED:
116 case GL11.GL_GREEN:
117 case GL11.GL_BLUE:
118 case GL11.GL_ALPHA:
119 case GL11.GL_LUMINANCE:
113 case GL_COLOR_INDEX:
114 case GL_STENCIL_INDEX:
115 case GL_DEPTH_COMPONENT:
116 case GL_RED:
117 case GL_GREEN:
118 case GL_BLUE:
119 case GL_ALPHA:
120 case GL_LUMINANCE:
120121 return 1;
121 case GL11.GL_LUMINANCE_ALPHA:
122 case GL_LUMINANCE_ALPHA:
122123 return 2;
123 case GL11.GL_RGB:
124 case GL12.GL_BGR:
124 case GL_RGB:
125 case GL_BGR:
125126 return 3;
126 case GL11.GL_RGBA:
127 case GL12.GL_BGRA:
127 case GL_RGBA:
128 case GL_BGRA:
128129 return 4;
129130 default :
130131 return -1;
172173 int n, m;
173174
174175 switch ( format ) {
175 case GL11.GL_COLOR_INDEX:
176 case GL11.GL_STENCIL_INDEX:
177 case GL11.GL_DEPTH_COMPONENT:
178 case GL11.GL_RED:
179 case GL11.GL_GREEN:
180 case GL11.GL_BLUE:
181 case GL11.GL_ALPHA:
182 case GL11.GL_LUMINANCE:
176 case GL_COLOR_INDEX:
177 case GL_STENCIL_INDEX:
178 case GL_DEPTH_COMPONENT:
179 case GL_RED:
180 case GL_GREEN:
181 case GL_BLUE:
182 case GL_ALPHA:
183 case GL_LUMINANCE:
183184 n = 1;
184185 break;
185 case GL11.GL_LUMINANCE_ALPHA:
186 case GL_LUMINANCE_ALPHA:
186187 n = 2;
187188 break;
188 case GL11.GL_RGB:
189 case GL12.GL_BGR:
189 case GL_RGB:
190 case GL_BGR:
190191 n = 3;
191192 break;
192 case GL11.GL_RGBA:
193 case GL12.GL_BGRA:
193 case GL_RGBA:
194 case GL_BGRA:
194195 n = 4;
195196 break;
196197 default :
198199 }
199200
200201 switch ( type ) {
201 case GL11.GL_UNSIGNED_BYTE:
202 case GL_UNSIGNED_BYTE:
202203 m = 1;
203204 break;
204 case GL11.GL_BYTE:
205 case GL_BYTE:
205206 m = 1;
206207 break;
207 case GL11.GL_BITMAP:
208 case GL_BITMAP:
208209 m = 1;
209210 break;
210 case GL11.GL_UNSIGNED_SHORT:
211 case GL_UNSIGNED_SHORT:
211212 m = 2;
212213 break;
213 case GL11.GL_SHORT:
214 case GL_SHORT:
214215 m = 2;
215216 break;
216 case GL11.GL_UNSIGNED_INT:
217 case GL_UNSIGNED_INT:
217218 m = 4;
218219 break;
219 case GL11.GL_INT:
220 case GL_INT:
220221 m = 4;
221222 break;
222 case GL11.GL_FLOAT:
223 case GL_FLOAT:
223224 m = 4;
224225 break;
225226 default :
238239 */
239240 protected static int glGetIntegerv(int what) {
240241 scratch.rewind();
241 GL11.glGetInteger(what, scratch);
242 glGetInteger(what, scratch);
242243 return scratch.get();
243244 }
244245
9898 public int winding; /* change in winding number when crossing */
9999 public boolean first;
100100
101 public GLUhalfEdge(boolean first) {
101 GLUhalfEdge(boolean first) {
102102 this.first = first;
103103 }
104104 }
8383 */
8484 package org.lwjgl.util.glu.tessellation;
8585
86 import org.lwjgl.util.glu.GLU;
8786 import org.lwjgl.util.glu.GLUtessellator;
8887 import org.lwjgl.util.glu.GLUtessellatorCallback;
8988 import org.lwjgl.util.glu.GLUtessellatorCallbackAdapter;
89
90 import static org.lwjgl.util.glu.GLU.*;
9091
9192 public class GLUtessellatorImpl implements GLUtessellator {
9293 public static final int TESS_MAX_CACHE = 100;
162163 normal[2] = 0;
163164
164165 relTolerance = GLU_TESS_DEFAULT_TOLERANCE;
165 windingRule = GLU.GLU_TESS_WINDING_ODD;
166 windingRule = GLU_TESS_WINDING_ODD;
166167 flagBoundary = false;
167168 boundaryOnly = false;
168169
188189 }
189190 }
190191
191 static public GLUtessellator gluNewTess()
192 public static GLUtessellator gluNewTess()
192193 {
193194 return new GLUtessellatorImpl();
194195 }
216217 */
217218 if (state < newState) {
218219 if (state == TessState.T_DORMANT) {
219 callErrorOrErrorData(GLU.GLU_TESS_MISSING_BEGIN_POLYGON);
220 callErrorOrErrorData(GLU_TESS_MISSING_BEGIN_POLYGON);
220221 gluTessBeginPolygon(null);
221222 } else if (state == TessState.T_IN_POLYGON) {
222 callErrorOrErrorData(GLU.GLU_TESS_MISSING_BEGIN_CONTOUR);
223 callErrorOrErrorData(GLU_TESS_MISSING_BEGIN_CONTOUR);
223224 gluTessBeginContour();
224225 }
225226 } else {
226227 if (state == TessState.T_IN_CONTOUR) {
227 callErrorOrErrorData(GLU.GLU_TESS_MISSING_END_CONTOUR);
228 callErrorOrErrorData(GLU_TESS_MISSING_END_CONTOUR);
228229 gluTessEndContour();
229230 } else if (state == TessState.T_IN_POLYGON) {
230 callErrorOrErrorData(GLU.GLU_TESS_MISSING_END_POLYGON);
231 callErrorOrErrorData(GLU_TESS_MISSING_END_POLYGON);
231232 /* gluTessEndPolygon( tess ) is too much work! */
232233 makeDormant();
233234 }
241242
242243 public void gluTessProperty(int which, double value) {
243244 switch (which) {
244 case GLU.GLU_TESS_TOLERANCE:
245 case GLU_TESS_TOLERANCE:
245246 if (value < 0.0 || value > 1.0) break;
246247 relTolerance = value;
247248 return;
248249
249 case GLU.GLU_TESS_WINDING_RULE:
250 case GLU_TESS_WINDING_RULE:
250251 int windingRule = (int) value;
251252 if (windingRule != value) break; /* not an integer */
252253
253254 switch (windingRule) {
254 case GLU.GLU_TESS_WINDING_ODD:
255 case GLU.GLU_TESS_WINDING_NONZERO:
256 case GLU.GLU_TESS_WINDING_POSITIVE:
257 case GLU.GLU_TESS_WINDING_NEGATIVE:
258 case GLU.GLU_TESS_WINDING_ABS_GEQ_TWO:
255 case GLU_TESS_WINDING_ODD:
256 case GLU_TESS_WINDING_NONZERO:
257 case GLU_TESS_WINDING_POSITIVE:
258 case GLU_TESS_WINDING_NEGATIVE:
259 case GLU_TESS_WINDING_ABS_GEQ_TWO:
259260 this.windingRule = windingRule;
260261 return;
261262 default:
262263 break;
263264 }
264265
265 case GLU.GLU_TESS_BOUNDARY_ONLY:
266 case GLU_TESS_BOUNDARY_ONLY:
266267 boundaryOnly = (value != 0);
267268 return;
268269
269270 default:
270 callErrorOrErrorData(GLU.GLU_INVALID_ENUM);
271 return;
272 }
273 callErrorOrErrorData(GLU.GLU_INVALID_VALUE);
271 callErrorOrErrorData(GLU_INVALID_ENUM);
272 return;
273 }
274 callErrorOrErrorData(GLU_INVALID_VALUE);
274275 }
275276
276277 /* Returns tessellator property */
277278 public void gluGetTessProperty(int which, double[] value, int value_offset) {
278279 switch (which) {
279 case GLU.GLU_TESS_TOLERANCE:
280 case GLU_TESS_TOLERANCE:
280281 /* tolerance should be in range [0..1] */
281282 assert (0.0 <= relTolerance && relTolerance <= 1.0);
282283 value[value_offset] = relTolerance;
283284 break;
284 case GLU.GLU_TESS_WINDING_RULE:
285 assert (windingRule == GLU.GLU_TESS_WINDING_ODD ||
286 windingRule == GLU.GLU_TESS_WINDING_NONZERO ||
287 windingRule == GLU.GLU_TESS_WINDING_POSITIVE ||
288 windingRule == GLU.GLU_TESS_WINDING_NEGATIVE ||
289 windingRule == GLU.GLU_TESS_WINDING_ABS_GEQ_TWO);
285 case GLU_TESS_WINDING_RULE:
286 assert (windingRule == GLU_TESS_WINDING_ODD ||
287 windingRule == GLU_TESS_WINDING_NONZERO ||
288 windingRule == GLU_TESS_WINDING_POSITIVE ||
289 windingRule == GLU_TESS_WINDING_NEGATIVE ||
290 windingRule == GLU_TESS_WINDING_ABS_GEQ_TWO);
290291 value[value_offset] = windingRule;
291292 break;
292 case GLU.GLU_TESS_BOUNDARY_ONLY:
293 case GLU_TESS_BOUNDARY_ONLY:
293294 assert (boundaryOnly == true || boundaryOnly == false);
294295 value[value_offset] = boundaryOnly ? 1 : 0;
295296 break;
296297 default:
297298 value[value_offset] = 0.0;
298 callErrorOrErrorData(GLU.GLU_INVALID_ENUM);
299 callErrorOrErrorData(GLU_INVALID_ENUM);
299300 break;
300301 }
301302 } /* gluGetTessProperty() */
308309
309310 public void gluTessCallback(int which, GLUtessellatorCallback aCallback) {
310311 switch (which) {
311 case GLU.GLU_TESS_BEGIN:
312 case GLU_TESS_BEGIN:
312313 callBegin = aCallback == null ? NULL_CB : aCallback;
313314 return;
314 case GLU.GLU_TESS_BEGIN_DATA:
315 case GLU_TESS_BEGIN_DATA:
315316 callBeginData = aCallback == null ? NULL_CB : aCallback;
316317 return;
317 case GLU.GLU_TESS_EDGE_FLAG:
318 case GLU_TESS_EDGE_FLAG:
318319 callEdgeFlag = aCallback == null ? NULL_CB : aCallback;
319320 /* If the client wants boundary edges to be flagged,
320321 * we render everything as separate triangles (no strips or fans).
321322 */
322323 flagBoundary = aCallback != null;
323324 return;
324 case GLU.GLU_TESS_EDGE_FLAG_DATA:
325 case GLU_TESS_EDGE_FLAG_DATA:
325326 callEdgeFlagData = callBegin = aCallback == null ? NULL_CB : aCallback;
326327 /* If the client wants boundary edges to be flagged,
327328 * we render everything as separate triangles (no strips or fans).
328329 */
329330 flagBoundary = (aCallback != null);
330331 return;
331 case GLU.GLU_TESS_VERTEX:
332 case GLU_TESS_VERTEX:
332333 callVertex = aCallback == null ? NULL_CB : aCallback;
333334 return;
334 case GLU.GLU_TESS_VERTEX_DATA:
335 case GLU_TESS_VERTEX_DATA:
335336 callVertexData = aCallback == null ? NULL_CB : aCallback;
336337 return;
337 case GLU.GLU_TESS_END:
338 case GLU_TESS_END:
338339 callEnd = aCallback == null ? NULL_CB : aCallback;
339340 return;
340 case GLU.GLU_TESS_END_DATA:
341 case GLU_TESS_END_DATA:
341342 callEndData = aCallback == null ? NULL_CB : aCallback;
342343 return;
343 case GLU.GLU_TESS_ERROR:
344 case GLU_TESS_ERROR:
344345 callError = aCallback == null ? NULL_CB : aCallback;
345346 return;
346 case GLU.GLU_TESS_ERROR_DATA:
347 case GLU_TESS_ERROR_DATA:
347348 callErrorData = aCallback == null ? NULL_CB : aCallback;
348349 return;
349 case GLU.GLU_TESS_COMBINE:
350 case GLU_TESS_COMBINE:
350351 callCombine = aCallback == null ? NULL_CB : aCallback;
351352 return;
352 case GLU.GLU_TESS_COMBINE_DATA:
353 case GLU_TESS_COMBINE_DATA:
353354 callCombineData = aCallback == null ? NULL_CB : aCallback;
354355 return;
355356 // case GLU_TESS_MESH:
356357 // callMesh = aCallback == null ? NULL_CB : aCallback;
357358 // return;
358359 default:
359 callErrorOrErrorData(GLU.GLU_INVALID_ENUM);
360 callErrorOrErrorData(GLU_INVALID_ENUM);
360361 return;
361362 }
362363 }
439440
440441 if (flushCacheOnNextVertex) {
441442 if (!flushCache()) {
442 callErrorOrErrorData(GLU.GLU_OUT_OF_MEMORY);
443 callErrorOrErrorData(GLU_OUT_OF_MEMORY);
443444 return;
444445 }
445446 lastEdge = null;
446447 }
447448 for (i = 0; i < 3; ++i) {
448449 x = coords[i+coords_offset];
449 if (x < -GLU.GLU_TESS_MAX_COORD) {
450 x = -GLU.GLU_TESS_MAX_COORD;
450 if (x < -GLU_TESS_MAX_COORD) {
451 x = -GLU_TESS_MAX_COORD;
451452 tooLarge = true;
452453 }
453 if (x > GLU.GLU_TESS_MAX_COORD) {
454 x = GLU.GLU_TESS_MAX_COORD;
454 if (x > GLU_TESS_MAX_COORD) {
455 x = GLU_TESS_MAX_COORD;
455456 tooLarge = true;
456457 }
457458 clamped[i] = x;
458459 }
459460 if (tooLarge) {
460 callErrorOrErrorData(GLU.GLU_TESS_COORD_TOO_LARGE);
461 callErrorOrErrorData(GLU_TESS_COORD_TOO_LARGE);
461462 }
462463
463464 if (mesh == null) {
466467 return;
467468 }
468469 if (!flushCache()) {
469 callErrorOrErrorData(GLU.GLU_OUT_OF_MEMORY);
470 callErrorOrErrorData(GLU_OUT_OF_MEMORY);
470471 return;
471472 }
472473 }
473474
474475 if (!addVertex(clamped, vertexData)) {
475 callErrorOrErrorData(GLU.GLU_OUT_OF_MEMORY);
476 callErrorOrErrorData(GLU_OUT_OF_MEMORY);
476477 }
477478 }
478479
596597 mesh = null;
597598 } catch (Exception e) {
598599 e.printStackTrace();
599 callErrorOrErrorData(GLU.GLU_OUT_OF_MEMORY);
600 callErrorOrErrorData(GLU_OUT_OF_MEMORY);
600601 }
601602 }
602603
8989 private Normal() {
9090 }
9191
92 static boolean SLANTED_SWEEP = false;
92 static boolean SLANTED_SWEEP;
9393 static double S_UNIT_X; /* Pre-normalized */
9494 static double S_UNIT_Y;
9595 private static final boolean TRUE_PROJECT = false;
9595 int node;
9696 }
9797
98 public static interface Leq {
98 public interface Leq {
9999 boolean leq(Object key1, Object key2);
100100 }
101101
9494 PriorityQ.Leq leq;
9595
9696 /* really __gl_pqHeapNewPriorityQ */
97 public PriorityQHeap(PriorityQ.Leq leq) {
97 PriorityQHeap(PriorityQ.Leq leq) {
9898 size = 0;
9999 max = PriorityQ.INIT_SIZE;
100100 nodes = new PriorityQ.PQnode[PriorityQ.INIT_SIZE + 1];
9292 boolean initialized;
9393 PriorityQ.Leq leq;
9494
95 public PriorityQSort(PriorityQ.Leq leq) {
95 PriorityQSort(PriorityQ.Leq leq) {
9696 heap = new PriorityQHeap(leq);
9797
9898 keys = new Object[PriorityQ.INIT_SIZE];
8383 */
8484 package org.lwjgl.util.glu.tessellation;
8585
86 import org.lwjgl.opengl.GL11;
87 import org.lwjgl.util.glu.GLU;
86 import static org.lwjgl.opengl.GL11.*;
87 import static org.lwjgl.util.glu.GLU.*;
8888
8989 class Render {
9090 private static final boolean USE_OPTIMIZED_CODE_PATH = false;
101101 * primitive is able to use the most triangles.
102102 */
103103 private static class FaceCount {
104 public FaceCount() {
105 }
106
107 public FaceCount(long size, GLUhalfEdge eStart, renderCallBack render) {
104 private FaceCount() {
105 }
106
107 private FaceCount(long size, GLUhalfEdge eStart, renderCallBack render) {
108108 this.size = size;
109109 this.eStart = eStart;
110110 this.render = render;
115115 renderCallBack render;
116116 };
117117
118 private static interface renderCallBack {
118 private interface renderCallBack {
119119 void render(GLUtessellatorImpl tess, GLUhalfEdge e, long size);
120120 }
121121
165165 */
166166 GLUhalfEdge e = fOrig.anEdge;
167167 FaceCount max = new FaceCount();
168 FaceCount newFace = new FaceCount();
168 FaceCount newFace;
169169
170170 max.size = 1;
171171 max.eStart = e;
328328 int newState;
329329 int edgeState = -1; /* force edge state output for first vertex */
330330
331 tess.callBeginOrBeginData(GL11.GL_TRIANGLES);
331 tess.callBeginOrBeginData(GL_TRIANGLES);
332332
333333 for (; f != null; f = f.trail) {
334334 /* Loop once for each edge (there will always be 3 edges) */
359359 * edge "e". The fan *should* contain exactly "size" triangles
360360 * (otherwise we've goofed up somewhere).
361361 */
362 tess.callBeginOrBeginData(GL11.GL_TRIANGLE_FAN);
362 tess.callBeginOrBeginData(GL_TRIANGLE_FAN);
363363 tess.callVertexOrVertexData( e.Org.data);
364364 tess.callVertexOrVertexData( e.Sym.Org.data);
365365
381381 * edge "e". The strip *should* contain exactly "size" triangles
382382 * (otherwise we've goofed up somewhere).
383383 */
384 tess.callBeginOrBeginData(GL11.GL_TRIANGLE_STRIP);
384 tess.callBeginOrBeginData(GL_TRIANGLE_STRIP);
385385 tess.callVertexOrVertexData( e.Org.data);
386386 tess.callVertexOrVertexData( e.Sym.Org.data);
387387
415415
416416 for (f = mesh.fHead.next; f != mesh.fHead; f = f.next) {
417417 if (f.inside) {
418 tess.callBeginOrBeginData(GL11.GL_LINE_LOOP);
418 tess.callBeginOrBeginData(GL_LINE_LOOP);
419419 e = f.anEdge;
420420 do {
421421 tess.callVertexOrVertexData( e.Org.data);
554554 } else {
555555 /* Make sure we do the right thing for each winding rule */
556556 switch (tess.windingRule) {
557 case GLU.GLU_TESS_WINDING_ODD:
558 case GLU.GLU_TESS_WINDING_NONZERO:
557 case GLU_TESS_WINDING_ODD:
558 case GLU_TESS_WINDING_NONZERO:
559559 break;
560 case GLU.GLU_TESS_WINDING_POSITIVE:
560 case GLU_TESS_WINDING_POSITIVE:
561561 if (sign < 0) return true;
562562 break;
563 case GLU.GLU_TESS_WINDING_NEGATIVE:
563 case GLU_TESS_WINDING_NEGATIVE:
564564 if (sign > 0) return true;
565565 break;
566 case GLU.GLU_TESS_WINDING_ABS_GEQ_TWO:
566 case GLU_TESS_WINDING_ABS_GEQ_TWO:
567567 return true;
568568 }
569569
570 tess.callBeginOrBeginData( tess.boundaryOnly ? GL11.GL_LINE_LOOP
571 : (tess.cacheCount > 3) ? GL11.GL_TRIANGLE_FAN
572 : GL11.GL_TRIANGLES);
570 tess.callBeginOrBeginData( tess.boundaryOnly ? GL_LINE_LOOP
571 : (tess.cacheCount > 3) ? GL_TRIANGLE_FAN
572 : GL_TRIANGLES);
573573
574574 tess.callVertexOrVertexData( v[0].data);
575575 if (sign > 0) {
8383 */
8484 package org.lwjgl.util.glu.tessellation;
8585
86 import org.lwjgl.util.glu.GLU;
86 import static org.lwjgl.util.glu.GLU.*;
8787
8888 class Sweep {
8989 private Sweep() {
269269
270270 static boolean IsWindingInside(GLUtessellatorImpl tess, int n) {
271271 switch (tess.windingRule) {
272 case GLU.GLU_TESS_WINDING_ODD:
272 case GLU_TESS_WINDING_ODD:
273273 return (n & 1) != 0;
274 case GLU.GLU_TESS_WINDING_NONZERO:
274 case GLU_TESS_WINDING_NONZERO:
275275 return (n != 0);
276 case GLU.GLU_TESS_WINDING_POSITIVE:
276 case GLU_TESS_WINDING_POSITIVE:
277277 return (n > 0);
278 case GLU.GLU_TESS_WINDING_NEGATIVE:
278 case GLU_TESS_WINDING_NEGATIVE:
279279 return (n < 0);
280 case GLU.GLU_TESS_WINDING_ABS_GEQ_TWO:
280 case GLU_TESS_WINDING_ABS_GEQ_TWO:
281281 return (n >= 2) || (n <= -2);
282282 }
283283 /*LINTED*/
456456 * but the user has not provided the callback necessary to handle
457457 * generated intersection points.
458458 */
459 tess.callErrorOrErrorData(GLU.GLU_TESS_NEED_COMBINE_CALLBACK);
459 tess.callErrorOrErrorData(GLU_TESS_NEED_COMBINE_CALLBACK);
460460 tess.fatalError = true;
461461 }
462462 }
11421142 * input contour and the maximum tolerance of 1.0, no merging will be
11431143 * done with coordinates larger than 3 * GLU_TESS_MAX_COORD).
11441144 */
1145 private static final double SENTINEL_COORD = (4.0 * GLU.GLU_TESS_MAX_COORD);
1145 private static final double SENTINEL_COORD = (4.0 * GLU_TESS_MAX_COORD);
11461146
11471147 static void AddSentinel(GLUtessellatorImpl tess, double t)
11481148 /*
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 */
3737 * @author elias
3838 */
3939 final class KeyMap {
40 public final static Component.Identifier.Key map(int lwjgl_key_code) {
40 public static Component.Identifier.Key map(int lwjgl_key_code) {
4141 switch (lwjgl_key_code) {
4242 case Keyboard.KEY_ESCAPE:
4343 return Component.Identifier.Key.ESCAPE;
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 */
4848 * @author elias
4949 */
5050 final class LWJGLKeyboard extends Keyboard {
51 protected LWJGLKeyboard() {
51 LWJGLKeyboard() {
5252 super("LWJGLKeyboard", createComponents(), new Controller[]{}, new Rumbler[]{});
5353 }
5454
55 private final static Component[] createComponents() {
56 List components = new ArrayList();
55 private static Component[] createComponents() {
56 List<Key> components = new ArrayList<Key>();
5757 Field[] vkey_fields = org.lwjgl.input.Keyboard.class.getFields();
58 for (int i = 0; i < vkey_fields.length; i++) {
59 Field vkey_field = vkey_fields[i];
58 for ( Field vkey_field : vkey_fields ) {
6059 try {
6160 if (Modifier.isStatic(vkey_field.getModifiers()) && vkey_field.getType() == int.class &&
6261 vkey_field.getName().startsWith("KEY_")) {
6968 throw new RuntimeException(e);
7069 }
7170 }
72 return (Component[])components.toArray(new Component[]{});
71 return components.toArray(new Component[components.size()]);
7372 }
7473
75 public final synchronized void pollDevice() throws IOException {
74 public synchronized void pollDevice() throws IOException {
7675 if (!org.lwjgl.input.Keyboard.isCreated())
7776 return;
7877 org.lwjgl.input.Keyboard.poll();
79 Component[] components = getComponents();
80 for (int i = 0; i < components.length; i++) {
81 Key key = (Key)components[i];
78 for ( Component component : getComponents() ) {
79 Key key = (Key)component;
8280 key.update();
8381 }
8482 }
8583
86 protected final synchronized boolean getNextDeviceEvent(Event event) throws IOException {
84 protected synchronized boolean getNextDeviceEvent(Event event) throws IOException {
8785 if (!org.lwjgl.input.Keyboard.isCreated())
8886 return false;
8987 if (!org.lwjgl.input.Keyboard.next())
103101 }
104102
105103
106 private final static class Key extends AbstractComponent {
104 private static final class Key extends AbstractComponent {
107105 private final int lwjgl_key;
108106 private float value;
109
110 public Key(Component.Identifier.Key key_id, int lwjgl_key) {
107
108 Key(Component.Identifier.Key key_id, int lwjgl_key) {
111109 super(key_id.getName(), key_id);
112110 this.lwjgl_key = lwjgl_key;
113111 }
114112
115 public final void update() {
113 public void update() {
116114 this.value = org.lwjgl.input.Keyboard.isKeyDown(lwjgl_key) ? 1 : 0;
117115 }
118
119 protected final float poll() {
116
117 protected float poll() {
120118 return value;
121119 }
122120
123 public final boolean isRelative() {
121 public boolean isRelative() {
124122 return false;
125123 }
126124
127 public final boolean isAnalog() {
125 public boolean isAnalog() {
128126 return false;
129127 }
130128 }
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 */
4343 * @author elias
4444 */
4545 final class LWJGLMouse extends Mouse {
46 private final static int EVENT_X = 1;
47 private final static int EVENT_Y = 2;
48 private final static int EVENT_WHEEL = 3;
49 private final static int EVENT_BUTTON = 4;
50 private final static int EVENT_DONE = 5;
46 private static final int EVENT_X = 1;
47 private static final int EVENT_Y = 2;
48 private static final int EVENT_WHEEL = 3;
49 private static final int EVENT_BUTTON = 4;
50 private static final int EVENT_DONE = 5;
5151
5252 private int event_state = EVENT_DONE;
53
54 protected LWJGLMouse() {
53
54 LWJGLMouse() {
5555 super("LWJGLMouse", createComponents(), new Controller[]{}, new Rumbler[]{});
5656 }
5757
58 private final static Component[] createComponents() {
58 private static Component[] createComponents() {
5959 return new Component[]{new Axis(Component.Identifier.Axis.X),
6060 new Axis(Component.Identifier.Axis.Y),
6161 new Axis(Component.Identifier.Axis.Z),
6464 new Button(Component.Identifier.Button.RIGHT)};
6565 }
6666
67 public final synchronized void pollDevice() throws IOException {
67 public synchronized void pollDevice() throws IOException {
6868 if (!org.lwjgl.input.Mouse.isCreated())
6969 return;
7070 org.lwjgl.input.Mouse.poll();
7272 setButtonState(i);
7373 }
7474
75 private final Button map(int lwjgl_button) {
75 private Button map(int lwjgl_button) {
7676 switch (lwjgl_button) {
7777 case 0:
7878 return (Button)getLeft();
8585 }
8686 }
8787
88 private final void setButtonState(int lwjgl_button) {
88 private void setButtonState(int lwjgl_button) {
8989 Button button = map(lwjgl_button);
9090 if (button != null)
9191 button.setValue(org.lwjgl.input.Mouse.isButtonDown(lwjgl_button) ? 1 : 0);
9292 }
9393
94 protected final synchronized boolean getNextDeviceEvent(Event event) throws IOException {
94 protected synchronized boolean getNextDeviceEvent(Event event) throws IOException {
9595 if (!org.lwjgl.input.Mouse.isCreated())
9696 return false;
9797 while (true) {
146146 }
147147 }
148148
149 final static class Axis extends AbstractComponent {
150 public Axis(Component.Identifier.Axis axis_id) {
149 static final class Axis extends AbstractComponent {
150 Axis(Component.Identifier.Axis axis_id) {
151151 super(axis_id.getName(), axis_id);
152152 }
153153
154 public final boolean isRelative() {
154 public boolean isRelative() {
155155 return true;
156156 }
157157
158 protected final float poll() throws IOException {
158 protected float poll() throws IOException {
159159 return 0;
160160 }
161161
162 public final boolean isAnalog() {
162 public boolean isAnalog() {
163163 return true;
164164 }
165165 }
166166
167 final static class Button extends AbstractComponent {
167 static final class Button extends AbstractComponent {
168168 private float value;
169
170 public Button(Component.Identifier.Button button_id) {
169
170 Button(Component.Identifier.Button button_id) {
171171 super(button_id.getName(), button_id);
172172 }
173173
174 protected final void setValue(float value) {
174 void setValue(float value) {
175175 this.value = value;
176176 }
177177
178 protected final float poll() throws IOException {
178 protected float poll() throws IOException {
179179 return value;
180180 }
181181
182 public final boolean isRelative() {
182 public boolean isRelative() {
183183 return false;
184184 }
185185
186 public final boolean isAnalog() {
186 public boolean isAnalog() {
187187 return false;
188188 }
189189 }
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 */
3939 * matrix unless otherwise stated.
4040 *
4141 * @author cix_foo <cix_foo@users.sourceforge.net>
42 * @version $Revision: 2983 $
43 * $Id: Matrix.java 2983 2008-04-07 18:36:09Z matzon $
42 * @version $Revision: 3418 $
43 * $Id: Matrix.java 3418 2010-09-28 21:11:35Z spasi $
4444 */
4545 public abstract class Matrix implements Serializable {
4646
4747 /**
4848 * Constructor for Matrix.
4949 */
50 public Matrix() {
50 protected Matrix() {
5151 super();
5252 }
5353
5656 * @return this
5757 */
5858 public abstract Matrix setIdentity();
59
59
6060
6161 /**
6262 * Invert this matrix
6363 * @return this
6464 */
6565 public abstract Matrix invert();
66
66
6767
6868 /**
6969 * Load from a float buffer. The buffer stores the matrix in column major
7070 * (OpenGL) order.
71 *
71 *
7272 * @param buf A float buffer to read from
7373 * @return this
7474 */
7575 public abstract Matrix load(FloatBuffer buf);
76
76
7777
7878 /**
7979 * Load from a float buffer. The buffer stores the matrix in row major
8080 * (mathematical) order.
81 *
81 *
8282 * @param buf A float buffer to read from
8383 * @return this
8484 */
8585 public abstract Matrix loadTranspose(FloatBuffer buf);
86
86
8787
8888 /**
8989 * Negate this matrix
9090 * @return this
9191 */
9292 public abstract Matrix negate();
93
93
9494
9595 /**
9696 * Store this matrix in a float buffer. The matrix is stored in column
9999 * @return this
100100 */
101101 public abstract Matrix store(FloatBuffer buf);
102
102
103103
104104 /**
105105 * Store this matrix in a float buffer. The matrix is stored in row
108108 * @return this
109109 */
110110 public abstract Matrix storeTranspose(FloatBuffer buf);
111
111
112112
113113 /**
114114 * Transpose this matrix
115115 * @return this
116116 */
117117 public abstract Matrix transpose();
118
118
119119
120120 /**
121121 * Set this matrix to 0.
122122 * @return this
123123 */
124124 public abstract Matrix setZero();
125
125
126126
127127 /**
128128 * @return the determinant of the matrix
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 */
3838 * Holds a 2x2 matrix
3939 *
4040 * @author cix_foo <cix_foo@users.sourceforge.net>
41 * @version $Revision: 2983 $
42 * $Id: Matrix2f.java 2983 2008-04-07 18:36:09Z matzon $
41 * @version $Revision: 3418 $
42 * $Id: Matrix2f.java 3418 2010-09-28 21:11:35Z spasi $
4343 */
4444
4545 public class Matrix2f extends Matrix implements Serializable {
46
46
4747 private static final long serialVersionUID = 1L;
4848
4949 public float m00, m01, m10, m11;
50
50
5151 /**
5252 * Constructor for Matrix2f. The matrix is initialised to the identity.
5353 */
5454 public Matrix2f() {
5555 setIdentity();
5656 }
57
57
5858 /**
5959 * Constructor
6060 */
6161 public Matrix2f(Matrix2f src) {
6262 load(src);
6363 }
64
64
6565 /**
6666 * Load from another matrix
6767 * @param src The source matrix
7070 public Matrix2f load(Matrix2f src) {
7171 return load(src, this);
7272 }
73
73
7474 /**
7575 * Copy the source matrix to the destination matrix.
7676 * @param src The source matrix
8080 public static Matrix2f load(Matrix2f src, Matrix2f dest) {
8181 if (dest == null)
8282 dest = new Matrix2f();
83
83
8484 dest.m00 = src.m00;
8585 dest.m01 = src.m01;
8686 dest.m10 = src.m10;
8787 dest.m11 = src.m11;
88
89 return dest;
90 }
91
88
89 return dest;
90 }
91
9292 /**
9393 * Load from a float buffer. The buffer stores the matrix in column major
9494 * (OpenGL) order.
95 *
95 *
9696 * @param buf A float buffer to read from
9797 * @return this
9898 */
9999 public Matrix load(FloatBuffer buf) {
100
100
101101 m00 = buf.get();
102102 m01 = buf.get();
103103 m10 = buf.get();
104104 m11 = buf.get();
105
105
106106 return this;
107107 }
108
108
109109 /**
110110 * Load from a float buffer. The buffer stores the matrix in row major
111111 * (mathematical) order.
112 *
112 *
113113 * @param buf A float buffer to read from
114114 * @return this
115115 */
116116 public Matrix loadTranspose(FloatBuffer buf) {
117
117
118118 m00 = buf.get();
119119 m10 = buf.get();
120120 m01 = buf.get();
121121 m11 = buf.get();
122
122
123123 return this;
124 }
125
124 }
125
126126 /**
127127 * Store this matrix in a float buffer. The matrix is stored in column
128128 * major (openGL) order.
135135 buf.put(m11);
136136 return this;
137137 }
138
138
139139 /**
140140 * Store this matrix in a float buffer. The matrix is stored in row
141141 * major (maths) order.
147147 buf.put(m01);
148148 buf.put(m11);
149149 return this;
150 }
151
152
153
150 }
151
152
153
154154 /**
155155 * Add two matrices together and place the result in a third matrix.
156156 * @param left The left source matrix
161161 public static Matrix2f add(Matrix2f left, Matrix2f right, Matrix2f dest) {
162162 if (dest == null)
163163 dest = new Matrix2f();
164
164
165165 dest.m00 = left.m00 + right.m00;
166166 dest.m01 = left.m01 + right.m01;
167167 dest.m10 = left.m10 + right.m10;
168168 dest.m11 = left.m11 + right.m11;
169
170 return dest;
171 }
169
170 return dest;
171 }
172172
173173 /**
174174 * Subtract the right matrix from the left and place the result in a third matrix.
180180 public static Matrix2f sub(Matrix2f left, Matrix2f right, Matrix2f dest) {
181181 if (dest == null)
182182 dest = new Matrix2f();
183
183
184184 dest.m00 = left.m00 - right.m00;
185185 dest.m01 = left.m01 - right.m01;
186186 dest.m10 = left.m10 - right.m10;
187187 dest.m11 = left.m11 - right.m11;
188
189 return dest;
190 }
188
189 return dest;
190 }
191191
192192 /**
193193 * Multiply the right matrix by the left and place the result in a third matrix.
199199 public static Matrix2f mul(Matrix2f left, Matrix2f right, Matrix2f dest) {
200200 if (dest == null)
201201 dest = new Matrix2f();
202
202
203203 float m00 = left.m00 * right.m00 + left.m10 * right.m01;
204204 float m01 = left.m01 * right.m00 + left.m11 * right.m01;
205205 float m10 = left.m00 * right.m10 + left.m10 * right.m11;
206206 float m11 = left.m01 * right.m10 + left.m11 * right.m11;
207
207
208208 dest.m00 = m00;
209209 dest.m01 = m01;
210210 dest.m10 = m10;
211211 dest.m11 = m11;
212
213 return dest;
214 }
215
212
213 return dest;
214 }
215
216216 /**
217217 * Transform a Vector by a matrix and return the result in a destination
218 * vector.
218 * vector.
219219 * @param left The left matrix
220220 * @param right The right vector
221221 * @param dest The destination vector, or null if a new one is to be created
224224 public static Vector2f transform(Matrix2f left, Vector2f right, Vector2f dest) {
225225 if (dest == null)
226226 dest = new Vector2f();
227
227
228228 float x = left.m00 * right.x + left.m10 * right.y;
229229 float y = left.m01 * right.x + left.m11 * right.y;
230
230
231231 dest.x = x;
232232 dest.y = y;
233233
234 return dest;
235 }
236
234 return dest;
235 }
236
237237 /**
238238 * Transpose this matrix
239239 * @return this
241241 public Matrix transpose() {
242242 return transpose(this);
243243 }
244
244
245245 /**
246246 * Transpose this matrix and place the result in another matrix.
247247 * @param dest The destination matrix or null if a new matrix is to be created
249249 */
250250 public Matrix2f transpose(Matrix2f dest) {
251251 return transpose(this, dest);
252 }
252 }
253253
254254 /**
255255 * Transpose the source matrix and place the result in the destination matrix.
266266
267267 dest.m01 = m01;
268268 dest.m10 = m10;
269
269
270270 return dest;
271271 }
272272
277277 public Matrix invert() {
278278 return invert(this, this);
279279 }
280
280
281281 /**
282282 * Invert the source matrix and place the result in the destination matrix.
283283 * @param src The source matrix to be inverted
288288 /*
289289 *inv(A) = 1/det(A) * adj(A);
290290 */
291
291
292292 float determinant = src.determinant();
293293 if (determinant != 0) {
294294 if (dest == null)
298298 float t01 = -src.m01*determinant_inv;
299299 float t11 = src.m00*determinant_inv;
300300 float t10 = -src.m10*determinant_inv;
301
301
302302 dest.m00 = t00;
303303 dest.m01 = t01;
304304 dest.m10 = t10;
312312 * Returns a string representation of this matrix
313313 */
314314 public String toString() {
315 StringBuffer buf = new StringBuffer();
315 StringBuilder buf = new StringBuilder();
316316 buf.append(m00).append(' ').append(m10).append(' ').append('\n');
317317 buf.append(m01).append(' ').append(m11).append(' ').append('\n');
318318 return buf.toString();
319319 }
320
320
321321 /**
322322 * Negate this matrix
323323 * @return this
325325 public Matrix negate() {
326326 return negate(this);
327327 }
328
328
329329 /**
330330 * Negate this matrix and stash the result in another matrix.
331331 * @param dest The destination matrix, or null if a new matrix is to be created
334334 public Matrix2f negate(Matrix2f dest) {
335335 return negate(this, this);
336336 }
337
337
338338 /**
339339 * Negate the source matrix and stash the result in the destination matrix.
340340 * @param src The source matrix to be negated
344344 public static Matrix2f negate(Matrix2f src, Matrix2f dest) {
345345 if (dest == null)
346346 dest = new Matrix2f();
347
347
348348 dest.m00 = -src.m00;
349349 dest.m01 = -src.m01;
350350 dest.m10 = -src.m10;
351351 dest.m11 = -src.m11;
352
352
353353 return dest;
354354 }
355355
373373 src.m11 = 1.0f;
374374 return src;
375375 }
376
376
377377 /**
378378 * Set this matrix to 0.
379379 * @return this
389389 src.m11 = 0.0f;
390390 return src;
391391 }
392
392
393393 /* (non-Javadoc)
394394 * @see org.lwjgl.vector.Matrix#determinant()
395395 */
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 */
3636 /**
3737 *
3838 * Holds a 3x3 matrix.
39 *
39 *
4040 * @author cix_foo <cix_foo@users.sourceforge.net>
41 * @version $Revision: 2983 $
42 * $Id: Matrix3f.java 2983 2008-04-07 18:36:09Z matzon $
41 * @version $Revision: 3418 $
42 * $Id: Matrix3f.java 3418 2010-09-28 21:11:35Z spasi $
4343 */
4444
4545 public class Matrix3f extends Matrix implements Serializable {
6363 super();
6464 setIdentity();
6565 }
66
66
6767 /**
6868 * Load from another matrix
6969 * @param src The source matrix
7272 public Matrix3f load(Matrix3f src) {
7373 return load(src, this);
7474 }
75
75
7676 /**
7777 * Copy source matrix to destination matrix
7878 * @param src The source matrix
9595
9696 return dest;
9797 }
98
98
9999 /**
100100 * Load from a float buffer. The buffer stores the matrix in column major
101101 * (OpenGL) order.
102 *
102 *
103103 * @param buf A float buffer to read from
104104 * @return this
105105 */
106106 public Matrix load(FloatBuffer buf) {
107
107
108108 m00 = buf.get();
109109 m01 = buf.get();
110110 m02 = buf.get();
114114 m20 = buf.get();
115115 m21 = buf.get();
116116 m22 = buf.get();
117
117
118118 return this;
119119 }
120
120
121121 /**
122122 * Load from a float buffer. The buffer stores the matrix in row major
123123 * (maths) order.
124 *
124 *
125125 * @param buf A float buffer to read from
126126 * @return this
127127 */
128128 public Matrix loadTranspose(FloatBuffer buf) {
129
129
130130 m00 = buf.get();
131131 m10 = buf.get();
132132 m20 = buf.get();
136136 m02 = buf.get();
137137 m12 = buf.get();
138138 m22 = buf.get();
139
139
140140 return this;
141 }
142
141 }
142
143143 /**
144144 * Store this matrix in a float buffer. The matrix is stored in column
145145 * major (openGL) order.
157157 buf.put(m22);
158158 return this;
159159 }
160
160
161161 /**
162162 * Store this matrix in a float buffer. The matrix is stored in row
163163 * major (maths) order.
174174 buf.put(m12);
175175 buf.put(m22);
176176 return this;
177 }
177 }
178178
179179 /**
180180 * Add two matrices together and place the result in a third matrix.
269269
270270 /**
271271 * Transform a Vector by a matrix and return the result in a destination
272 * vector.
272 * vector.
273273 * @param left The left matrix
274274 * @param right The right vector
275275 * @param dest The destination vector, or null if a new one is to be created
315315 */
316316 public static Matrix3f transpose(Matrix3f src, Matrix3f dest) {
317317 if (dest == null)
318 dest = new Matrix3f();
319 float m00 = src.m00;
320 float m01 = src.m10;
321 float m02 = src.m20;
322 float m10 = src.m01;
323 float m11 = src.m11;
324 float m12 = src.m21;
325 float m20 = src.m02;
326 float m21 = src.m12;
327 float m22 = src.m22;
318 dest = new Matrix3f();
319 float m00 = src.m00;
320 float m01 = src.m10;
321 float m02 = src.m20;
322 float m10 = src.m01;
323 float m11 = src.m11;
324 float m12 = src.m21;
325 float m20 = src.m02;
326 float m21 = src.m12;
327 float m22 = src.m22;
328328
329329 dest.m00 = m00;
330330 dest.m01 = m01;
335335 dest.m20 = m20;
336336 dest.m21 = m21;
337337 dest.m22 = m22;
338 return dest;
338 return dest;
339339 }
340340
341341 /**
353353 * Returns a string representation of this matrix
354354 */
355355 public String toString() {
356 StringBuffer buf = new StringBuffer();
356 StringBuilder buf = new StringBuilder();
357357 buf.append(m00).append(' ').append(m10).append(' ').append(m20).append(' ').append('\n');
358358 buf.append(m01).append(' ').append(m11).append(' ').append(m21).append(' ').append('\n');
359359 buf.append(m02).append(' ').append(m12).append(' ').append(m22).append(' ').append('\n');
376376 */
377377 public static Matrix3f invert(Matrix3f src, Matrix3f dest) {
378378 float determinant = src.determinant();
379
379
380380 if (determinant != 0) {
381381 if (dest == null)
382382 dest = new Matrix3f();
384384 *
385385 * inv(A) = 1/det(A) * adj(T), where adj(T) = transpose(Conjugate Matrix)
386386 *
387 * m00 m01 m02
387 * m00 m01 m02
388388 * m10 m11 m12
389 * m20 m21 m22
389 * m20 m21 m22
390390 */
391391 float determinant_inv = 1f/determinant;
392
392
393393 // get the conjugate matrix
394394 float t00 = src.m11 * src.m22 - src.m12* src.m21;
395395 float t01 = - src.m10 * src.m22 + src.m12 * src.m20;
462462 public Matrix setIdentity() {
463463 return setIdentity(this);
464464 }
465
465
466466 /**
467467 * Set the matrix to be the identity matrix.
468468 * @param m The matrix to be set to the identity
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 */
4242 private static final long serialVersionUID = 1L;
4343
4444 public float m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33;
45
45
4646 /**
4747 * Construct a new matrix, initialized to the identity.
4848 */
5555 * Returns a string representation of this matrix
5656 */
5757 public String toString() {
58 StringBuffer buf = new StringBuffer();
58 StringBuilder buf = new StringBuilder();
5959 buf.append(m00).append(' ').append(m10).append(' ').append(m20).append(' ').append(m30).append('\n');
6060 buf.append(m01).append(' ').append(m11).append(' ').append(m21).append(' ').append(m31).append('\n');
6161 buf.append(m02).append(' ').append(m12).append(' ').append(m22).append(' ').append(m32).append('\n');
7070 public Matrix setIdentity() {
7171 return setIdentity(this);
7272 }
73
73
7474 /**
7575 * Set the given matrix to be the identity matrix.
7676 * @param m The matrix to set to the identity
9393 m.m31 = 0.0f;
9494 m.m32 = 0.0f;
9595 m.m33 = 1.0f;
96
96
9797 return m;
9898 }
9999
127127 m.m31 = 0.0f;
128128 m.m32 = 0.0f;
129129 m.m33 = 0.0f;
130
130
131131 return m;
132132 }
133133
139139 public Matrix4f load(Matrix4f src) {
140140 return load(src, this);
141141 }
142
142
143143 /**
144144 * Copy the source matrix to the destination matrix
145145 * @param src The source matrix
165165 dest.m31 = src.m31;
166166 dest.m32 = src.m32;
167167 dest.m33 = src.m33;
168
169 return dest;
170 }
171
168
169 return dest;
170 }
171
172172 /**
173173 * Load from a float buffer. The buffer stores the matrix in column major
174174 * (OpenGL) order.
175 *
175 *
176176 * @param buf A float buffer to read from
177177 * @return this
178178 */
179179 public Matrix load(FloatBuffer buf) {
180
180
181181 m00 = buf.get();
182182 m01 = buf.get();
183183 m02 = buf.get();
194194 m31 = buf.get();
195195 m32 = buf.get();
196196 m33 = buf.get();
197
197
198198 return this;
199199 }
200
200
201201 /**
202202 * Load from a float buffer. The buffer stores the matrix in row major
203203 * (maths) order.
204 *
204 *
205205 * @param buf A float buffer to read from
206206 * @return this
207207 */
208208 public Matrix loadTranspose(FloatBuffer buf) {
209
209
210210 m00 = buf.get();
211211 m10 = buf.get();
212212 m20 = buf.get();
223223 m13 = buf.get();
224224 m23 = buf.get();
225225 m33 = buf.get();
226
226
227227 return this;
228 }
229
228 }
229
230230 /**
231231 * Store this matrix in a float buffer. The matrix is stored in column
232232 * major (openGL) order.
251251 buf.put(m33);
252252 return this;
253253 }
254
254
255255 /**
256256 * Store this matrix in a float buffer. The matrix is stored in row
257257 * major (maths) order.
275275 buf.put(m23);
276276 buf.put(m33);
277277 return this;
278 }
279
280
278 }
279
280
281281 /**
282282 * Add two matrices together and place the result in a third matrix.
283283 * @param left The left source matrix
288288 public static Matrix4f add(Matrix4f left, Matrix4f right, Matrix4f dest) {
289289 if (dest == null)
290290 dest = new Matrix4f();
291
291
292292 dest.m00 = left.m00 + right.m00;
293293 dest.m01 = left.m01 + right.m01;
294294 dest.m02 = left.m02 + right.m02;
306306 dest.m32 = left.m32 + right.m32;
307307 dest.m33 = left.m33 + right.m33;
308308
309 return dest;
310 }
309 return dest;
310 }
311311
312312 /**
313313 * Subtract the right matrix from the left and place the result in a third matrix.
319319 public static Matrix4f sub(Matrix4f left, Matrix4f right, Matrix4f dest) {
320320 if (dest == null)
321321 dest = new Matrix4f();
322
322
323323 dest.m00 = left.m00 - right.m00;
324324 dest.m01 = left.m01 - right.m01;
325325 dest.m02 = left.m02 - right.m02;
336336 dest.m31 = left.m31 - right.m31;
337337 dest.m32 = left.m32 - right.m32;
338338 dest.m33 = left.m33 - right.m33;
339
340 return dest;
341 }
339
340 return dest;
341 }
342342
343343 /**
344344 * Multiply the right matrix by the left and place the result in a third matrix.
387387
388388 return dest;
389389 }
390
390
391391 /**
392392 * Transform a Vector by a matrix and return the result in a destination
393 * vector.
393 * vector.
394394 * @param left The left matrix
395395 * @param right The right vector
396396 * @param dest The destination vector, or null if a new one is to be created
410410 dest.z = z;
411411 dest.w = w;
412412
413 return dest;
414 }
415
413 return dest;
414 }
415
416416 /**
417417 * Transpose this matrix
418418 * @return this
420420 public Matrix transpose() {
421421 return transpose(this);
422422 }
423
423
424424 /**
425425 * Translate this matrix
426426 * @param vec The vector to translate by
429429 public Matrix4f translate(Vector2f vec) {
430430 return translate(vec, this);
431431 }
432
432
433433 /**
434434 * Translate this matrix
435435 * @param vec The vector to translate by
472472 dest.m23 = src.m23 * vec.z;
473473 return dest;
474474 }
475
475
476476 /**
477477 * Rotates the matrix around the given axis the specified angle
478478 * @param angle the angle, in radians.
493493 public Matrix4f rotate(float angle, Vector3f axis, Matrix4f dest) {
494494 return rotate(angle, axis, this, dest);
495495 }
496
496
497497 /**
498498 * Rotates the source matrix around the given axis the specified angle and
499499 * put the result in the destination matrix.
571571 public static Matrix4f translate(Vector3f vec, Matrix4f src, Matrix4f dest) {
572572 if (dest == null)
573573 dest = new Matrix4f();
574
574
575575 dest.m30 += src.m00 * vec.x + src.m10 * vec.y + src.m20 * vec.z;
576576 dest.m31 += src.m01 * vec.x + src.m11 * vec.y + src.m21 * vec.z;
577577 dest.m32 += src.m02 * vec.x + src.m12 * vec.y + src.m22 * vec.z;
578578 dest.m33 += src.m03 * vec.x + src.m13 * vec.y + src.m23 * vec.z;
579
580 return dest;
581 }
582
579
580 return dest;
581 }
582
583583 /**
584584 * Translate this matrix and stash the result in another matrix
585585 * @param vec The vector to translate by
589589 public Matrix4f translate(Vector2f vec, Matrix4f dest) {
590590 return translate(vec, this, dest);
591591 }
592
592
593593 /**
594594 * Translate the source matrix and stash the result in the destination matrix
595595 * @param vec The vector to translate by
600600 public static Matrix4f translate(Vector2f vec, Matrix4f src, Matrix4f dest) {
601601 if (dest == null)
602602 dest = new Matrix4f();
603
603
604604 dest.m30 += src.m00 * vec.x + src.m10 * vec.y;
605605 dest.m31 += src.m01 * vec.x + src.m11 * vec.y;
606606 dest.m32 += src.m02 * vec.x + src.m12 * vec.y;
607607 dest.m33 += src.m03 * vec.x + src.m13 * vec.y;
608
609 return dest;
610 }
608
609 return dest;
610 }
611611
612612 /**
613613 * Transpose this matrix and place the result in another matrix
617617 public Matrix4f transpose(Matrix4f dest) {
618618 return transpose(this, dest);
619619 }
620
620
621621 /**
622622 * Transpose the source matrix and place the result in the destination matrix
623623 * @param src The source matrix
625625 * @return the transposed matrix
626626 */
627627 public static Matrix4f transpose(Matrix4f src, Matrix4f dest) {
628 if (dest == null)
629 dest = new Matrix4f();
630 float m00 = src.m00;
631 float m01 = src.m10;
632 float m02 = src.m20;
633 float m03 = src.m30;
634 float m10 = src.m01;
635 float m11 = src.m11;
636 float m12 = src.m21;
637 float m13 = src.m31;
638 float m20 = src.m02;
639 float m21 = src.m12;
640 float m22 = src.m22;
641 float m23 = src.m32;
642 float m30 = src.m03;
643 float m31 = src.m13;
644 float m32 = src.m23;
645 float m33 = src.m33;
628 if (dest == null)
629 dest = new Matrix4f();
630 float m00 = src.m00;
631 float m01 = src.m10;
632 float m02 = src.m20;
633 float m03 = src.m30;
634 float m10 = src.m01;
635 float m11 = src.m11;
636 float m12 = src.m21;
637 float m13 = src.m31;
638 float m20 = src.m02;
639 float m21 = src.m12;
640 float m22 = src.m22;
641 float m23 = src.m32;
642 float m30 = src.m03;
643 float m31 = src.m13;
644 float m32 = src.m23;
645 float m33 = src.m33;
646646
647647 dest.m00 = m00;
648648 dest.m01 = m01;
691691 - m11 * m20 * m32);
692692 return f;
693693 }
694
694
695695 /**
696696 * Calculate the determinant of a 3x3 matrix
697697 * @return result
701701 float t10, float t11, float t12,
702702 float t20, float t21, float t22)
703703 {
704 return t00 * (t11 * t22 - t12 * t21)
704 return t00 * (t11 * t22 - t12 * t21)
705705 + t01 * (t12 * t20 - t10 * t22)
706706 + t02 * (t10 * t21 - t11 * t20);
707707 }
722722 */
723723 public static Matrix4f invert(Matrix4f src, Matrix4f dest) {
724724 float determinant = src.determinant();
725
725
726726 if (determinant != 0) {
727727 /*
728728 * m00 m01 m02 m03
733733 if (dest == null)
734734 dest = new Matrix4f();
735735 float determinant_inv = 1f/determinant;
736
736
737737 // first row
738738 float t00 = determinant3x3(src.m11, src.m12, src.m13, src.m21, src.m22, src.m23, src.m31, src.m32, src.m33);
739739 float t01 = -determinant3x3(src.m10, src.m12, src.m13, src.m20, src.m22, src.m23, src.m30, src.m32, src.m33);
754754 float t31 = determinant3x3(src.m00, src.m02, src.m03, src.m10, src.m12, src.m13, src.m20, src.m22, src.m23);
755755 float t32 = -determinant3x3(src.m00, src.m01, src.m03, src.m10, src.m11, src.m13, src.m20, src.m21, src.m23);
756756 float t33 = determinant3x3(src.m00, src.m01, src.m02, src.m10, src.m11, src.m12, src.m20, src.m21, src.m22);
757
757
758758 // transpose and divide by the determinant
759759 dest.m00 = t00*determinant_inv;
760760 dest.m11 = t11*determinant_inv;
776776 } else
777777 return null;
778778 }
779
779
780780 /**
781781 * Negate this matrix
782782 * @return this
784784 public Matrix negate() {
785785 return negate(this);
786786 }
787
787
788788 /**
789789 * Negate this matrix and place the result in a destination matrix.
790790 * @param dest The destination matrix, or null if a new matrix is to be created
793793 public Matrix4f negate(Matrix4f dest) {
794794 return negate(this, this);
795795 }
796
796
797797 /**
798798 * Negate this matrix and place the result in a destination matrix.
799799 * @param src The source matrix
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 package org.lwjgl.util.vector;
3232
3333 /**
34 *
34 *
3535 * Quaternions for LWJGL!
36 *
36 *
3737 * @author fbi
38 * @version $Revision: 2983 $
39 * $Id: Quaternion.java 2983 2008-04-07 18:36:09Z matzon $
38 * @version $Revision: 3418 $
39 * $Id: Quaternion.java 3418 2010-09-28 21:11:35Z spasi $
4040 */
4141
4242 import java.nio.FloatBuffer;
5656
5757 /**
5858 * C'tor
59 *
59 *
6060 * @param src
6161 */
6262 public Quaternion(ReadableVector4f src) {
6565
6666 /**
6767 * C'tor
68 *
68 *
6969 */
7070 public Quaternion(float x, float y, float z, float w) {
7171 set(x, y, z, w);
7373
7474 /*
7575 * (non-Javadoc)
76 *
76 *
7777 * @see org.lwjgl.util.vector.WritableVector2f#set(float, float)
7878 */
7979 public void set(float x, float y) {
8383
8484 /*
8585 * (non-Javadoc)
86 *
86 *
8787 * @see org.lwjgl.util.vector.WritableVector3f#set(float, float, float)
8888 */
8989 public void set(float x, float y, float z) {
9494
9595 /*
9696 * (non-Javadoc)
97 *
97 *
9898 * @see org.lwjgl.util.vector.WritableVector4f#set(float, float, float,
9999 * float)
100100 */
107107
108108 /**
109109 * Load from another Vector4f
110 *
110 *
111111 * @param src
112112 * The source vector
113113 * @return this
127127 public Quaternion setIdentity() {
128128 return setIdentity(this);
129129 }
130
130
131131 /**
132132 * Set the given quaternion to the multiplication identity.
133133 * @param q The quaternion
150150
151151 /**
152152 * Normalise the source quaternion and place the result in another quaternion.
153 *
153 *
154154 * @param src
155155 * The source quaternion
156156 * @param dest
171171
172172 /**
173173 * Normalise this quaternion and place the result in another quaternion.
174 *
174 *
175175 * @param dest
176176 * The destination quaternion, or null if a new quaternion is to be
177177 * created
183183
184184 /**
185185 * The dot product of two quaternions
186 *
186 *
187187 * @param left
188188 * The LHS quat
189189 * @param right
197197
198198 /**
199199 * Calculate the conjugate of this quaternion and put it into the given one
200 *
200 *
201201 * @param dest
202202 * The quaternion which should be set to the conjugate of this
203203 * quaternion
208208
209209 /**
210210 * Calculate the conjugate of this quaternion and put it into the given one
211 *
211 *
212212 * @param src
213213 * The source quaternion
214214 * @param dest
247247
248248 /*
249249 * (non-Javadoc)
250 *
250 *
251251 * @see org.lwjgl.vector.Vector#scale(float)
252252 */
253253 public Vector scale(float scale) {
254254 return scale(scale, this, this);
255255 }
256
256
257257 /**
258258 * Scale the source quaternion by scale and put the result in the destination
259259 * @param scale The amount to scale by
299299
300300 /**
301301 * Set X
302 *
302 *
303303 * @param x
304304 */
305305 public final void setX(float x) {
308308
309309 /**
310310 * Set Y
311 *
311 *
312312 * @param y
313313 */
314314 public final void setY(float y) {
317317
318318 /**
319319 * Set Z
320 *
320 *
321321 * @param z
322322 */
323323 public void setZ(float z) {
326326
327327 /*
328328 * (Overrides)
329 *
329 *
330330 * @see org.lwjgl.vector.ReadableVector3f#getZ()
331331 */
332332 public float getZ() {
335335
336336 /**
337337 * Set W
338 *
338 *
339339 * @param w
340340 */
341341 public void setW(float w) {
344344
345345 /*
346346 * (Overrides)
347 *
347 *
348348 * @see org.lwjgl.vector.ReadableVector3f#getW()
349349 */
350350 public float getW() {
359359 * Sets the value of this quaternion to the quaternion product of
360360 * quaternions left and right (this = left * right). Note that this is safe
361361 * for aliasing (e.g. this can be left or right).
362 *
362 *
363363 * @param left
364364 * the first quaternion
365365 * @param right
379379 }
380380
381381 /**
382 *
382 *
383383 * Multiplies quaternion left by the inverse of quaternion right and places
384384 * the value into this quaternion. The value of both argument quaternions is
385385 * preservered (this = left * right^-1).
386 *
386 *
387387 * @param left
388388 * the left quaternion
389389 * @param right
414414 /**
415415 * Sets the value of this quaternion to the equivalent rotation of the
416416 * Axis-Angle argument.
417 *
417 *
418418 * @param a1
419419 * the axis-angle: (x,y,z) is the axis and w is the angle
420420 */
434434 /**
435435 * Sets the value of this quaternion using the rotational component of the
436436 * passed matrix.
437 *
437 *
438438 * @param m
439439 * The matrix
440440 * @return this
446446 /**
447447 * Sets the value of the source quaternion using the rotational component of the
448448 * passed matrix.
449 *
449 *
450450 * @param m
451451 * The source matrix
452452 * @param q
453453 * The destination quaternion, or null if a new quaternion is to be created
454454 * @return q
455455 */
456 public final static Quaternion setFromMatrix(Matrix4f m, Quaternion q) {
456 public static Quaternion setFromMatrix(Matrix4f m, Quaternion q) {
457457 return q.setFromMat(m.m00, m.m01, m.m02, m.m10, m.m11, m.m12, m.m20,
458458 m.m21, m.m22);
459459 }
461461 /**
462462 * Sets the value of this quaternion using the rotational component of the
463463 * passed matrix.
464 *
464 *
465465 * @param m
466466 * The source matrix
467467 */
472472 /**
473473 * Sets the value of the source quaternion using the rotational component of the
474474 * passed matrix.
475 *
475 *
476476 * @param m
477477 * The source matrix
478478 * @param q
479479 * The destination quaternion, or null if a new quaternion is to be created
480480 * @return q
481481 */
482 public static final Quaternion setFromMatrix(Matrix3f m, Quaternion q) {
482 public static Quaternion setFromMatrix(Matrix3f m, Quaternion q) {
483483 return q.setFromMat(m.m00, m.m01, m.m02, m.m10, m.m11, m.m12, m.m20,
484484 m.m21, m.m22);
485485 }
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 */
3939 /**
4040 * @return the length of the vector
4141 */
42 public float length();
42 float length();
4343 /**
4444 * @return the length squared of the vector
4545 */
46 public float lengthSquared();
46 float lengthSquared();
4747 /**
4848 * Store this vector in a FloatBuffer
4949 * @param buf The buffer to store it in, at the current position
5050 * @return this
5151 */
52 public Vector store(FloatBuffer buf);
52 Vector store(FloatBuffer buf);
5353 }
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 */
3737 /**
3838 * @return x
3939 */
40 public float getX();
40 float getX();
4141 /**
4242 * @return y
4343 */
44 public float getY();
44 float getY();
4545 }
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 */
3737 /**
3838 * @return z
3939 */
40 public float getZ();
40 float getZ();
4141 }
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 */
3434 * @author foo
3535 */
3636 public interface ReadableVector4f extends ReadableVector3f {
37
37
3838 /**
3939 * @return w
4040 */
41 public float getW();
41 float getW();
4242
4343 }
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 */
3838 * Base class for vectors.
3939 *
4040 * @author cix_foo <cix_foo@users.sourceforge.net>
41 * @version $Revision: 2983 $
42 * $Id: Vector.java 2983 2008-04-07 18:36:09Z matzon $
41 * @version $Revision: 3418 $
42 * $Id: Vector.java 3418 2010-09-28 21:11:35Z spasi $
4343 */
4444 public abstract class Vector implements Serializable, ReadableVector {
4545
4646 /**
4747 * Constructor for Vector.
4848 */
49 public Vector() {
49 protected Vector() {
5050 super();
5151 }
5252
5656 public final float length() {
5757 return (float) Math.sqrt(lengthSquared());
5858 }
59
59
6060
6161 /**
6262 * @return the length squared of the vector
6363 */
6464 public abstract float lengthSquared();
65
65
6666 /**
6767 * Load this vector from a FloatBuffer
6868 * @param buf The buffer to load it from, at the current position
6969 * @return this
7070 */
71 public abstract Vector load(FloatBuffer buf);
71 public abstract Vector load(FloatBuffer buf);
7272
7373 /**
7474 * Negate a vector
7575 * @return this
7676 */
7777 public abstract Vector negate();
78
78
7979
8080 /**
8181 * Normalise this vector
8989 } else
9090 throw new IllegalStateException("Zero length vector");
9191 }
92
92
9393
9494 /**
9595 * Store this vector in a FloatBuffer
9696 * @param buf The buffer to store it in, at the current position
9797 * @return this
9898 */
99 public abstract Vector store(FloatBuffer buf);
99 public abstract Vector store(FloatBuffer buf);
100100
101101
102102 /**
104104 * @param scale The scale factor
105105 * @return this
106106 */
107 public abstract Vector scale(float scale);
107 public abstract Vector scale(float scale);
108108
109109
110110
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 */
3636 /**
3737 *
3838 * Holds a 2-tuple vector.
39 *
39 *
4040 * @author cix_foo <cix_foo@users.sourceforge.net>
41 * @version $Revision: 2983 $
42 * $Id: Vector2f.java 2983 2008-04-07 18:36:09Z matzon $
41 * @version $Revision: 3418 $
42 * $Id: Vector2f.java 3418 2010-09-28 21:11:35Z spasi $
4343 */
4444
4545 public class Vector2f extends Vector implements Serializable, ReadableVector2f, WritableVector2f {
246246 * @see java.lang.Object#toString()
247247 */
248248 public String toString() {
249 StringBuffer sb = new StringBuffer(64);
249 StringBuilder sb = new StringBuilder(64);
250250
251251 sb.append("Vector2f[");
252252 sb.append(x);
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 */
3636 /**
3737 *
3838 * Holds a 3-tuple vector.
39 *
39 *
4040 * @author cix_foo <cix_foo@users.sourceforge.net>
41 * @version $Revision: 2983 $
42 * $Id: Vector3f.java 2983 2008-04-07 18:36:09Z matzon $
41 * @version $Revision: 3418 $
42 * $Id: Vector3f.java 3418 2010-09-28 21:11:35Z spasi $
4343 */
4444
4545 public class Vector3f extends Vector implements Serializable, ReadableVector3f, WritableVector3f {
154154
155155 /**
156156 * The cross product of two vectors.
157 *
157 *
158158 * @param left The LHS vector
159159 * @param right The RHS vector
160160 * @param dest The destination result, or null if a new vector is to be created
176176 );
177177
178178 return dest;
179 }
179 }
180180
181181
182182
287287 * @see java.lang.Object#toString()
288288 */
289289 public String toString() {
290 StringBuffer sb = new StringBuffer(64);
290 StringBuilder sb = new StringBuilder(64);
291291
292292 sb.append("Vector3f[");
293293 sb.append(x);
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 */
3434 * Writable interface to Vector2fs
3535 * @author $author$
3636 * @version $revision$
37 * $Id: WritableVector2f.java 2983 2008-04-07 18:36:09Z matzon $
37 * $Id: WritableVector2f.java 3418 2010-09-28 21:11:35Z spasi $
3838 */
3939 public interface WritableVector2f {
4040
4242 * Set the X value
4343 * @param x
4444 */
45 public void setX(float x);
46
45 void setX(float x);
46
4747 /**
4848 * Set the Y value
4949 * @param y
5050 */
51 public void setY(float y);
52
51 void setY(float y);
52
5353 /**
5454 * Set the X,Y values
5555 * @param x
5656 * @param y
5757 */
58 public void set(float x, float y);
59
58 void set(float x, float y);
59
6060 }
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 */
3434 * Writable interface to Vector3fs
3535 * @author $author$
3636 * @version $revision$
37 * $Id: WritableVector3f.java 2983 2008-04-07 18:36:09Z matzon $
37 * $Id: WritableVector3f.java 3418 2010-09-28 21:11:35Z spasi $
3838 */
3939 public interface WritableVector3f extends WritableVector2f {
4040
4242 * Set the Z value
4343 * @param z
4444 */
45 public void setZ(float z);
46
45 void setZ(float z);
46
4747 /**
4848 * Set the X,Y,Z values
4949 * @param x
5050 * @param y
5151 * @param z
5252 */
53 public void set(float x, float y, float z);
54
53 void set(float x, float y, float z);
54
5555 }
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 */
3434 * Writable interface to Vector4fs
3535 * @author $author$
3636 * @version $revision$
37 * $Id: WritableVector4f.java 2983 2008-04-07 18:36:09Z matzon $
37 * $Id: WritableVector4f.java 3418 2010-09-28 21:11:35Z spasi $
3838 */
3939 public interface WritableVector4f extends WritableVector3f {
4040
4242 * Set the W value
4343 * @param w
4444 */
45 public void setW(float w);
46
45 void setW(float w);
46
4747 /**
4848 * Set the X,Y,Z,W values
4949 * @param x
5151 * @param z
5252 * @param w
5353 */
54 public void set(float x, float y, float z, float w);
55
54 void set(float x, float y, float z, float w);
55
5656 }
0 /*******************************************************************************
1 * Copyright (c) 2008-2010 The Khronos Group Inc.
2 *
3 * Permission is hereby granted, free of charge, to any person obtaining a
4 * copy of this software and/or associated documentation files (the
5 * "Materials"), to deal in the Materials without restriction, including
6 * without limitation the rights to use, copy, modify, merge, publish,
7 * distribute, sublicense, and/or sell copies of the Materials, and to
8 * permit persons to whom the Materials are furnished to do so, subject to
9 * the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Materials.
13 *
14 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20 * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
21 ******************************************************************************/
22
23 /* $Revision: 11985 $ on $Date: 2010-07-15 11:16:06 -0700 (Thu, 15 Jul 2010) $ */
24
25 #ifndef __OPENCL_CL_H
26 #define __OPENCL_CL_H
27
28 #ifdef __APPLE__
29 #include <OpenCL/cl_platform.h>
30 #else
31 #include <CL/cl_platform.h>
32 #endif
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37
38 /******************************************************************************/
39
40 typedef struct _cl_platform_id * cl_platform_id;
41 typedef struct _cl_device_id * cl_device_id;
42 typedef struct _cl_context * cl_context;
43 typedef struct _cl_command_queue * cl_command_queue;
44 typedef struct _cl_mem * cl_mem;
45 typedef struct _cl_program * cl_program;
46 typedef struct _cl_kernel * cl_kernel;
47 typedef struct _cl_event * cl_event;
48 typedef struct _cl_sampler * cl_sampler;
49
50 typedef cl_uint cl_bool; /* WARNING! Unlike cl_ types in cl_platform.h, cl_bool is not guaranteed to be the same size as the bool in kernels. */
51 typedef cl_ulong cl_bitfield;
52 typedef cl_bitfield cl_device_type;
53 typedef cl_uint cl_platform_info;
54 typedef cl_uint cl_device_info;
55 typedef cl_bitfield cl_device_fp_config;
56 typedef cl_uint cl_device_mem_cache_type;
57 typedef cl_uint cl_device_local_mem_type;
58 typedef cl_bitfield cl_device_exec_capabilities;
59 typedef cl_bitfield cl_command_queue_properties;
60
61 typedef intptr_t cl_context_properties;
62 typedef cl_uint cl_context_info;
63 typedef cl_uint cl_command_queue_info;
64 typedef cl_uint cl_channel_order;
65 typedef cl_uint cl_channel_type;
66 typedef cl_bitfield cl_mem_flags;
67 typedef cl_uint cl_mem_object_type;
68 typedef cl_uint cl_mem_info;
69 typedef cl_uint cl_image_info;
70 typedef cl_uint cl_buffer_create_type;
71 typedef cl_uint cl_addressing_mode;
72 typedef cl_uint cl_filter_mode;
73 typedef cl_uint cl_sampler_info;
74 typedef cl_bitfield cl_map_flags;
75 typedef cl_uint cl_program_info;
76 typedef cl_uint cl_program_build_info;
77 typedef cl_int cl_build_status;
78 typedef cl_uint cl_kernel_info;
79 typedef cl_uint cl_kernel_work_group_info;
80 typedef cl_uint cl_event_info;
81 typedef cl_uint cl_command_type;
82 typedef cl_uint cl_profiling_info;
83
84 typedef struct _cl_image_format {
85 cl_channel_order image_channel_order;
86 cl_channel_type image_channel_data_type;
87 } cl_image_format;
88
89
90 typedef struct _cl_buffer_region {
91 size_t origin;
92 size_t size;
93 } cl_buffer_region;
94
95 /******************************************************************************/
96
97 /* Error Codes */
98 #define CL_SUCCESS 0
99 #define CL_DEVICE_NOT_FOUND -1
100 #define CL_DEVICE_NOT_AVAILABLE -2
101 #define CL_COMPILER_NOT_AVAILABLE -3
102 #define CL_MEM_OBJECT_ALLOCATION_FAILURE -4
103 #define CL_OUT_OF_RESOURCES -5
104 #define CL_OUT_OF_HOST_MEMORY -6
105 #define CL_PROFILING_INFO_NOT_AVAILABLE -7
106 #define CL_MEM_COPY_OVERLAP -8
107 #define CL_IMAGE_FORMAT_MISMATCH -9
108 #define CL_IMAGE_FORMAT_NOT_SUPPORTED -10
109 #define CL_BUILD_PROGRAM_FAILURE -11
110 #define CL_MAP_FAILURE -12
111 #define CL_MISALIGNED_SUB_BUFFER_OFFSET -13
112 #define CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST -14
113
114 #define CL_INVALID_VALUE -30
115 #define CL_INVALID_DEVICE_TYPE -31
116 #define CL_INVALID_PLATFORM -32
117 #define CL_INVALID_DEVICE -33
118 #define CL_INVALID_CONTEXT -34
119 #define CL_INVALID_QUEUE_PROPERTIES -35
120 #define CL_INVALID_COMMAND_QUEUE -36
121 #define CL_INVALID_HOST_PTR -37
122 #define CL_INVALID_MEM_OBJECT -38
123 #define CL_INVALID_IMAGE_FORMAT_DESCRIPTOR -39
124 #define CL_INVALID_IMAGE_SIZE -40
125 #define CL_INVALID_SAMPLER -41
126 #define CL_INVALID_BINARY -42
127 #define CL_INVALID_BUILD_OPTIONS -43
128 #define CL_INVALID_PROGRAM -44
129 #define CL_INVALID_PROGRAM_EXECUTABLE -45
130 #define CL_INVALID_KERNEL_NAME -46
131 #define CL_INVALID_KERNEL_DEFINITION -47
132 #define CL_INVALID_KERNEL -48
133 #define CL_INVALID_ARG_INDEX -49
134 #define CL_INVALID_ARG_VALUE -50
135 #define CL_INVALID_ARG_SIZE -51
136 #define CL_INVALID_KERNEL_ARGS -52
137 #define CL_INVALID_WORK_DIMENSION -53
138 #define CL_INVALID_WORK_GROUP_SIZE -54
139 #define CL_INVALID_WORK_ITEM_SIZE -55
140 #define CL_INVALID_GLOBAL_OFFSET -56
141 #define CL_INVALID_EVENT_WAIT_LIST -57
142 #define CL_INVALID_EVENT -58
143 #define CL_INVALID_OPERATION -59
144 #define CL_INVALID_GL_OBJECT -60
145 #define CL_INVALID_BUFFER_SIZE -61
146 #define CL_INVALID_MIP_LEVEL -62
147 #define CL_INVALID_GLOBAL_WORK_SIZE -63
148 #define CL_INVALID_PROPERTY -64
149
150 /* OpenCL Version */
151 #define CL_VERSION_1_0 1
152 #define CL_VERSION_1_1 1
153
154 /* cl_bool */
155 #define CL_FALSE 0
156 #define CL_TRUE 1
157
158 /* cl_platform_info */
159 #define CL_PLATFORM_PROFILE 0x0900
160 #define CL_PLATFORM_VERSION 0x0901
161 #define CL_PLATFORM_NAME 0x0902
162 #define CL_PLATFORM_VENDOR 0x0903
163 #define CL_PLATFORM_EXTENSIONS 0x0904
164
165 /* cl_device_type - bitfield */
166 #define CL_DEVICE_TYPE_DEFAULT (1 << 0)
167 #define CL_DEVICE_TYPE_CPU (1 << 1)
168 #define CL_DEVICE_TYPE_GPU (1 << 2)
169 #define CL_DEVICE_TYPE_ACCELERATOR (1 << 3)
170 #define CL_DEVICE_TYPE_ALL 0xFFFFFFFF
171
172 /* cl_device_info */
173 #define CL_DEVICE_TYPE 0x1000
174 #define CL_DEVICE_VENDOR_ID 0x1001
175 #define CL_DEVICE_MAX_COMPUTE_UNITS 0x1002
176 #define CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS 0x1003
177 #define CL_DEVICE_MAX_WORK_GROUP_SIZE 0x1004
178 #define CL_DEVICE_MAX_WORK_ITEM_SIZES 0x1005
179 #define CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR 0x1006
180 #define CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT 0x1007
181 #define CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT 0x1008
182 #define CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG 0x1009
183 #define CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT 0x100A
184 #define CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE 0x100B
185 #define CL_DEVICE_MAX_CLOCK_FREQUENCY 0x100C
186 #define CL_DEVICE_ADDRESS_BITS 0x100D
187 #define CL_DEVICE_MAX_READ_IMAGE_ARGS 0x100E
188 #define CL_DEVICE_MAX_WRITE_IMAGE_ARGS 0x100F
189 #define CL_DEVICE_MAX_MEM_ALLOC_SIZE 0x1010
190 #define CL_DEVICE_IMAGE2D_MAX_WIDTH 0x1011
191 #define CL_DEVICE_IMAGE2D_MAX_HEIGHT 0x1012
192 #define CL_DEVICE_IMAGE3D_MAX_WIDTH 0x1013
193 #define CL_DEVICE_IMAGE3D_MAX_HEIGHT 0x1014
194 #define CL_DEVICE_IMAGE3D_MAX_DEPTH 0x1015
195 #define CL_DEVICE_IMAGE_SUPPORT 0x1016
196 #define CL_DEVICE_MAX_PARAMETER_SIZE 0x1017
197 #define CL_DEVICE_MAX_SAMPLERS 0x1018
198 #define CL_DEVICE_MEM_BASE_ADDR_ALIGN 0x1019
199 #define CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE 0x101A
200 #define CL_DEVICE_SINGLE_FP_CONFIG 0x101B
201 #define CL_DEVICE_GLOBAL_MEM_CACHE_TYPE 0x101C
202 #define CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE 0x101D
203 #define CL_DEVICE_GLOBAL_MEM_CACHE_SIZE 0x101E
204 #define CL_DEVICE_GLOBAL_MEM_SIZE 0x101F
205 #define CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE 0x1020
206 #define CL_DEVICE_MAX_CONSTANT_ARGS 0x1021
207 #define CL_DEVICE_LOCAL_MEM_TYPE 0x1022
208 #define CL_DEVICE_LOCAL_MEM_SIZE 0x1023
209 #define CL_DEVICE_ERROR_CORRECTION_SUPPORT 0x1024
210 #define CL_DEVICE_PROFILING_TIMER_RESOLUTION 0x1025
211 #define CL_DEVICE_ENDIAN_LITTLE 0x1026
212 #define CL_DEVICE_AVAILABLE 0x1027
213 #define CL_DEVICE_COMPILER_AVAILABLE 0x1028
214 #define CL_DEVICE_EXECUTION_CAPABILITIES 0x1029
215 #define CL_DEVICE_QUEUE_PROPERTIES 0x102A
216 #define CL_DEVICE_NAME 0x102B
217 #define CL_DEVICE_VENDOR 0x102C
218 #define CL_DRIVER_VERSION 0x102D
219 #define CL_DEVICE_PROFILE 0x102E
220 #define CL_DEVICE_VERSION 0x102F
221 #define CL_DEVICE_EXTENSIONS 0x1030
222 #define CL_DEVICE_PLATFORM 0x1031
223 /* 0x1032 reserved for CL_DEVICE_DOUBLE_FP_CONFIG */
224 /* 0x1033 reserved for CL_DEVICE_HALF_FP_CONFIG */
225 #define CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF 0x1034
226 #define CL_DEVICE_HOST_UNIFIED_MEMORY 0x1035
227 #define CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR 0x1036
228 #define CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT 0x1037
229 #define CL_DEVICE_NATIVE_VECTOR_WIDTH_INT 0x1038
230 #define CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG 0x1039
231 #define CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT 0x103A
232 #define CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE 0x103B
233 #define CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF 0x103C
234 #define CL_DEVICE_OPENCL_C_VERSION 0x103D
235
236 /* cl_device_fp_config - bitfield */
237 #define CL_FP_DENORM (1 << 0)
238 #define CL_FP_INF_NAN (1 << 1)
239 #define CL_FP_ROUND_TO_NEAREST (1 << 2)
240 #define CL_FP_ROUND_TO_ZERO (1 << 3)
241 #define CL_FP_ROUND_TO_INF (1 << 4)
242 #define CL_FP_FMA (1 << 5)
243 #define CL_FP_SOFT_FLOAT (1 << 6)
244
245 /* cl_device_mem_cache_type */
246 #define CL_NONE 0x0
247 #define CL_READ_ONLY_CACHE 0x1
248 #define CL_READ_WRITE_CACHE 0x2
249
250 /* cl_device_local_mem_type */
251 #define CL_LOCAL 0x1
252 #define CL_GLOBAL 0x2
253
254 /* cl_device_exec_capabilities - bitfield */
255 #define CL_EXEC_KERNEL (1 << 0)
256 #define CL_EXEC_NATIVE_KERNEL (1 << 1)
257
258 /* cl_command_queue_properties - bitfield */
259 #define CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE (1 << 0)
260 #define CL_QUEUE_PROFILING_ENABLE (1 << 1)
261
262 /* cl_context_info */
263 #define CL_CONTEXT_REFERENCE_COUNT 0x1080
264 #define CL_CONTEXT_DEVICES 0x1081
265 #define CL_CONTEXT_PROPERTIES 0x1082
266 #define CL_CONTEXT_NUM_DEVICES 0x1083
267
268 /* cl_context_info + cl_context_properties */
269 #define CL_CONTEXT_PLATFORM 0x1084
270
271 /* cl_command_queue_info */
272 #define CL_QUEUE_CONTEXT 0x1090
273 #define CL_QUEUE_DEVICE 0x1091
274 #define CL_QUEUE_REFERENCE_COUNT 0x1092
275 #define CL_QUEUE_PROPERTIES 0x1093
276
277 /* cl_mem_flags - bitfield */
278 #define CL_MEM_READ_WRITE (1 << 0)
279 #define CL_MEM_WRITE_ONLY (1 << 1)
280 #define CL_MEM_READ_ONLY (1 << 2)
281 #define CL_MEM_USE_HOST_PTR (1 << 3)
282 #define CL_MEM_ALLOC_HOST_PTR (1 << 4)
283 #define CL_MEM_COPY_HOST_PTR (1 << 5)
284
285 /* cl_channel_order */
286 #define CL_R 0x10B0
287 #define CL_A 0x10B1
288 #define CL_RG 0x10B2
289 #define CL_RA 0x10B3
290 #define CL_RGB 0x10B4
291 #define CL_RGBA 0x10B5
292 #define CL_BGRA 0x10B6
293 #define CL_ARGB 0x10B7
294 #define CL_INTENSITY 0x10B8
295 #define CL_LUMINANCE 0x10B9
296 #define CL_Rx 0x10BA
297 #define CL_RGx 0x10BB
298 #define CL_RGBx 0x10BC
299
300 /* cl_channel_type */
301 #define CL_SNORM_INT8 0x10D0
302 #define CL_SNORM_INT16 0x10D1
303 #define CL_UNORM_INT8 0x10D2
304 #define CL_UNORM_INT16 0x10D3
305 #define CL_UNORM_SHORT_565 0x10D4
306 #define CL_UNORM_SHORT_555 0x10D5
307 #define CL_UNORM_INT_101010 0x10D6
308 #define CL_SIGNED_INT8 0x10D7
309 #define CL_SIGNED_INT16 0x10D8
310 #define CL_SIGNED_INT32 0x10D9
311 #define CL_UNSIGNED_INT8 0x10DA
312 #define CL_UNSIGNED_INT16 0x10DB
313 #define CL_UNSIGNED_INT32 0x10DC
314 #define CL_HALF_FLOAT 0x10DD
315 #define CL_FLOAT 0x10DE
316
317 /* cl_mem_object_type */
318 #define CL_MEM_OBJECT_BUFFER 0x10F0
319 #define CL_MEM_OBJECT_IMAGE2D 0x10F1
320 #define CL_MEM_OBJECT_IMAGE3D 0x10F2
321
322 /* cl_mem_info */
323 #define CL_MEM_TYPE 0x1100
324 #define CL_MEM_FLAGS 0x1101
325 #define CL_MEM_SIZE 0x1102
326 #define CL_MEM_HOST_PTR 0x1103
327 #define CL_MEM_MAP_COUNT 0x1104
328 #define CL_MEM_REFERENCE_COUNT 0x1105
329 #define CL_MEM_CONTEXT 0x1106
330 #define CL_MEM_ASSOCIATED_MEMOBJECT 0x1107
331 #define CL_MEM_OFFSET 0x1108
332
333 /* cl_image_info */
334 #define CL_IMAGE_FORMAT 0x1110
335 #define CL_IMAGE_ELEMENT_SIZE 0x1111
336 #define CL_IMAGE_ROW_PITCH 0x1112
337 #define CL_IMAGE_SLICE_PITCH 0x1113
338 #define CL_IMAGE_WIDTH 0x1114
339 #define CL_IMAGE_HEIGHT 0x1115
340 #define CL_IMAGE_DEPTH 0x1116
341
342 /* cl_addressing_mode */
343 #define CL_ADDRESS_NONE 0x1130
344 #define CL_ADDRESS_CLAMP_TO_EDGE 0x1131
345 #define CL_ADDRESS_CLAMP 0x1132
346 #define CL_ADDRESS_REPEAT 0x1133
347 #define CL_ADDRESS_MIRRORED_REPEAT 0x1134
348
349 /* cl_filter_mode */
350 #define CL_FILTER_NEAREST 0x1140
351 #define CL_FILTER_LINEAR 0x1141
352
353 /* cl_sampler_info */
354 #define CL_SAMPLER_REFERENCE_COUNT 0x1150
355 #define CL_SAMPLER_CONTEXT 0x1151
356 #define CL_SAMPLER_NORMALIZED_COORDS 0x1152
357 #define CL_SAMPLER_ADDRESSING_MODE 0x1153
358 #define CL_SAMPLER_FILTER_MODE 0x1154
359
360 /* cl_map_flags - bitfield */
361 #define CL_MAP_READ (1 << 0)
362 #define CL_MAP_WRITE (1 << 1)
363
364 /* cl_program_info */
365 #define CL_PROGRAM_REFERENCE_COUNT 0x1160
366 #define CL_PROGRAM_CONTEXT 0x1161
367 #define CL_PROGRAM_NUM_DEVICES 0x1162
368 #define CL_PROGRAM_DEVICES 0x1163
369 #define CL_PROGRAM_SOURCE 0x1164
370 #define CL_PROGRAM_BINARY_SIZES 0x1165
371 #define CL_PROGRAM_BINARIES 0x1166
372
373 /* cl_program_build_info */
374 #define CL_PROGRAM_BUILD_STATUS 0x1181
375 #define CL_PROGRAM_BUILD_OPTIONS 0x1182
376 #define CL_PROGRAM_BUILD_LOG 0x1183
377
378 /* cl_build_status */
379 #define CL_BUILD_SUCCESS 0
380 #define CL_BUILD_NONE -1
381 #define CL_BUILD_ERROR -2
382 #define CL_BUILD_IN_PROGRESS -3
383
384 /* cl_kernel_info */
385 #define CL_KERNEL_FUNCTION_NAME 0x1190
386 #define CL_KERNEL_NUM_ARGS 0x1191
387 #define CL_KERNEL_REFERENCE_COUNT 0x1192
388 #define CL_KERNEL_CONTEXT 0x1193
389 #define CL_KERNEL_PROGRAM 0x1194
390
391 /* cl_kernel_work_group_info */
392 #define CL_KERNEL_WORK_GROUP_SIZE 0x11B0
393 #define CL_KERNEL_COMPILE_WORK_GROUP_SIZE 0x11B1
394 #define CL_KERNEL_LOCAL_MEM_SIZE 0x11B2
395 #define CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE 0x11B3
396 #define CL_KERNEL_PRIVATE_MEM_SIZE 0x11B4
397
398 /* cl_event_info */
399 #define CL_EVENT_COMMAND_QUEUE 0x11D0
400 #define CL_EVENT_COMMAND_TYPE 0x11D1
401 #define CL_EVENT_REFERENCE_COUNT 0x11D2
402 #define CL_EVENT_COMMAND_EXECUTION_STATUS 0x11D3
403 #define CL_EVENT_CONTEXT 0x11D4
404
405 /* cl_command_type */
406 #define CL_COMMAND_NDRANGE_KERNEL 0x11F0
407 #define CL_COMMAND_TASK 0x11F1
408 #define CL_COMMAND_NATIVE_KERNEL 0x11F2
409 #define CL_COMMAND_READ_BUFFER 0x11F3
410 #define CL_COMMAND_WRITE_BUFFER 0x11F4
411 #define CL_COMMAND_COPY_BUFFER 0x11F5
412 #define CL_COMMAND_READ_IMAGE 0x11F6
413 #define CL_COMMAND_WRITE_IMAGE 0x11F7
414 #define CL_COMMAND_COPY_IMAGE 0x11F8
415 #define CL_COMMAND_COPY_IMAGE_TO_BUFFER 0x11F9
416 #define CL_COMMAND_COPY_BUFFER_TO_IMAGE 0x11FA
417 #define CL_COMMAND_MAP_BUFFER 0x11FB
418 #define CL_COMMAND_MAP_IMAGE 0x11FC
419 #define CL_COMMAND_UNMAP_MEM_OBJECT 0x11FD
420 #define CL_COMMAND_MARKER 0x11FE
421 #define CL_COMMAND_ACQUIRE_GL_OBJECTS 0x11FF
422 #define CL_COMMAND_RELEASE_GL_OBJECTS 0x1200
423 #define CL_COMMAND_READ_BUFFER_RECT 0x1201
424 #define CL_COMMAND_WRITE_BUFFER_RECT 0x1202
425 #define CL_COMMAND_COPY_BUFFER_RECT 0x1203
426 #define CL_COMMAND_USER 0x1204
427
428 /* command execution status */
429 #define CL_COMPLETE 0x0
430 #define CL_RUNNING 0x1
431 #define CL_SUBMITTED 0x2
432 #define CL_QUEUED 0x3
433
434 /* cl_buffer_create_type */
435 #define CL_BUFFER_CREATE_TYPE_REGION 0x1220
436
437 /* cl_profiling_info */
438 #define CL_PROFILING_COMMAND_QUEUED 0x1280
439 #define CL_PROFILING_COMMAND_SUBMIT 0x1281
440 #define CL_PROFILING_COMMAND_START 0x1282
441 #define CL_PROFILING_COMMAND_END 0x1283
442
443 /********************************************************************************************************/
444
445 /* Platform API */
446 extern CL_API_ENTRY cl_int CL_API_CALL
447 clGetPlatformIDs(cl_uint /* num_entries */,
448 cl_platform_id * /* platforms */,
449 cl_uint * /* num_platforms */) CL_API_SUFFIX__VERSION_1_0;
450
451 extern CL_API_ENTRY cl_int CL_API_CALL
452 clGetPlatformInfo(cl_platform_id /* platform */,
453 cl_platform_info /* param_name */,
454 size_t /* param_value_size */,
455 void * /* param_value */,
456 size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
457
458 /* Device APIs */
459 extern CL_API_ENTRY cl_int CL_API_CALL
460 clGetDeviceIDs(cl_platform_id /* platform */,
461 cl_device_type /* device_type */,
462 cl_uint /* num_entries */,
463 cl_device_id * /* devices */,
464 cl_uint * /* num_devices */) CL_API_SUFFIX__VERSION_1_0;
465
466 extern CL_API_ENTRY cl_int CL_API_CALL
467 clGetDeviceInfo(cl_device_id /* device */,
468 cl_device_info /* param_name */,
469 size_t /* param_value_size */,
470 void * /* param_value */,
471 size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
472
473 /* Context APIs */
474 extern CL_API_ENTRY cl_context CL_API_CALL
475 clCreateContext(const cl_context_properties * /* properties */,
476 cl_uint /* num_devices */,
477 const cl_device_id * /* devices */,
478 void (CL_CALLBACK * /* pfn_notify */)(const char *, const void *, size_t, void *),
479 void * /* user_data */,
480 cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
481
482 extern CL_API_ENTRY cl_context CL_API_CALL
483 clCreateContextFromType(const cl_context_properties * /* properties */,
484 cl_device_type /* device_type */,
485 void (CL_CALLBACK * /* pfn_notify*/ )(const char *, const void *, size_t, void *),
486 void * /* user_data */,
487 cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
488
489 extern CL_API_ENTRY cl_int CL_API_CALL
490 clRetainContext(cl_context /* context */) CL_API_SUFFIX__VERSION_1_0;
491
492 extern CL_API_ENTRY cl_int CL_API_CALL
493 clReleaseContext(cl_context /* context */) CL_API_SUFFIX__VERSION_1_0;
494
495 extern CL_API_ENTRY cl_int CL_API_CALL
496 clGetContextInfo(cl_context /* context */,
497 cl_context_info /* param_name */,
498 size_t /* param_value_size */,
499 void * /* param_value */,
500 size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
501
502 /* Command Queue APIs */
503 extern CL_API_ENTRY cl_command_queue CL_API_CALL
504 clCreateCommandQueue(cl_context /* context */,
505 cl_device_id /* device */,
506 cl_command_queue_properties /* properties */,
507 cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
508
509 extern CL_API_ENTRY cl_int CL_API_CALL
510 clRetainCommandQueue(cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_1_0;
511
512 extern CL_API_ENTRY cl_int CL_API_CALL
513 clReleaseCommandQueue(cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_1_0;
514
515 extern CL_API_ENTRY cl_int CL_API_CALL
516 clGetCommandQueueInfo(cl_command_queue /* command_queue */,
517 cl_command_queue_info /* param_name */,
518 size_t /* param_value_size */,
519 void * /* param_value */,
520 size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
521
522 #ifdef CL_USE_DEPRECATED_OPENCL_1_0_APIS
523 #warning CL_USE_DEPRECATED_OPENCL_1_0_APIS is defined. These APIs are unsupported and untested in OpenCL 1.1!
524 /*
525 * WARNING:
526 * This API introduces mutable state into the OpenCL implementation. It has been REMOVED
527 * to better facilitate thread safety. The 1.0 API is not thread safe. It is not tested by the
528 * OpenCL 1.1 conformance test, and consequently may not work or may not work dependably.
529 * It is likely to be non-performant. Use of this API is not advised. Use at your own risk.
530 *
531 * Software developers previously relying on this API are instructed to set the command queue
532 * properties when creating the queue, instead.
533 */
534 extern CL_API_ENTRY cl_int CL_API_CALL
535 clSetCommandQueueProperty(cl_command_queue /* command_queue */,
536 cl_command_queue_properties /* properties */,
537 cl_bool /* enable */,
538 cl_command_queue_properties * /* old_properties */) CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED;
539 #endif /* CL_USE_DEPRECATED_OPENCL_1_0_APIS */
540
541 /* Memory Object APIs */
542 extern CL_API_ENTRY cl_mem CL_API_CALL
543 clCreateBuffer(cl_context /* context */,
544 cl_mem_flags /* flags */,
545 size_t /* size */,
546 void * /* host_ptr */,
547 cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
548
549 extern CL_API_ENTRY cl_mem CL_API_CALL
550 clCreateSubBuffer(cl_mem /* buffer */,
551 cl_mem_flags /* flags */,
552 cl_buffer_create_type /* buffer_create_type */,
553 const void * /* buffer_create_info */,
554 cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_1;
555
556 extern CL_API_ENTRY cl_mem CL_API_CALL
557 clCreateImage2D(cl_context /* context */,
558 cl_mem_flags /* flags */,
559 const cl_image_format * /* image_format */,
560 size_t /* image_width */,
561 size_t /* image_height */,
562 size_t /* image_row_pitch */,
563 void * /* host_ptr */,
564 cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
565
566 extern CL_API_ENTRY cl_mem CL_API_CALL
567 clCreateImage3D(cl_context /* context */,
568 cl_mem_flags /* flags */,
569 const cl_image_format * /* image_format */,
570 size_t /* image_width */,
571 size_t /* image_height */,
572 size_t /* image_depth */,
573 size_t /* image_row_pitch */,
574 size_t /* image_slice_pitch */,
575 void * /* host_ptr */,
576 cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
577
578 extern CL_API_ENTRY cl_int CL_API_CALL
579 clRetainMemObject(cl_mem /* memobj */) CL_API_SUFFIX__VERSION_1_0;
580
581 extern CL_API_ENTRY cl_int CL_API_CALL
582 clReleaseMemObject(cl_mem /* memobj */) CL_API_SUFFIX__VERSION_1_0;
583
584 extern CL_API_ENTRY cl_int CL_API_CALL
585 clGetSupportedImageFormats(cl_context /* context */,
586 cl_mem_flags /* flags */,
587 cl_mem_object_type /* image_type */,
588 cl_uint /* num_entries */,
589 cl_image_format * /* image_formats */,
590 cl_uint * /* num_image_formats */) CL_API_SUFFIX__VERSION_1_0;
591
592 extern CL_API_ENTRY cl_int CL_API_CALL
593 clGetMemObjectInfo(cl_mem /* memobj */,
594 cl_mem_info /* param_name */,
595 size_t /* param_value_size */,
596 void * /* param_value */,
597 size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
598
599 extern CL_API_ENTRY cl_int CL_API_CALL
600 clGetImageInfo(cl_mem /* image */,
601 cl_image_info /* param_name */,
602 size_t /* param_value_size */,
603 void * /* param_value */,
604 size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
605
606 extern CL_API_ENTRY cl_int CL_API_CALL
607 clSetMemObjectDestructorCallback( cl_mem /* memobj */,
608 void (CL_CALLBACK * /*pfn_notify*/)( cl_mem /* memobj */, void* /*user_data*/),
609 void * /*user_data */ ) CL_API_SUFFIX__VERSION_1_1;
610
611 /* Sampler APIs */
612 extern CL_API_ENTRY cl_sampler CL_API_CALL
613 clCreateSampler(cl_context /* context */,
614 cl_bool /* normalized_coords */,
615 cl_addressing_mode /* addressing_mode */,
616 cl_filter_mode /* filter_mode */,
617 cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
618
619 extern CL_API_ENTRY cl_int CL_API_CALL
620 clRetainSampler(cl_sampler /* sampler */) CL_API_SUFFIX__VERSION_1_0;
621
622 extern CL_API_ENTRY cl_int CL_API_CALL
623 clReleaseSampler(cl_sampler /* sampler */) CL_API_SUFFIX__VERSION_1_0;
624
625 extern CL_API_ENTRY cl_int CL_API_CALL
626 clGetSamplerInfo(cl_sampler /* sampler */,
627 cl_sampler_info /* param_name */,
628 size_t /* param_value_size */,
629 void * /* param_value */,
630 size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
631
632 /* Program Object APIs */
633 extern CL_API_ENTRY cl_program CL_API_CALL
634 clCreateProgramWithSource(cl_context /* context */,
635 cl_uint /* count */,
636 const char ** /* strings */,
637 const size_t * /* lengths */,
638 cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
639
640 extern CL_API_ENTRY cl_program CL_API_CALL
641 clCreateProgramWithBinary(cl_context /* context */,
642 cl_uint /* num_devices */,
643 const cl_device_id * /* device_list */,
644 const size_t * /* lengths */,
645 const unsigned char ** /* binaries */,
646 cl_int * /* binary_status */,
647 cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
648
649 extern CL_API_ENTRY cl_int CL_API_CALL
650 clRetainProgram(cl_program /* program */) CL_API_SUFFIX__VERSION_1_0;
651
652 extern CL_API_ENTRY cl_int CL_API_CALL
653 clReleaseProgram(cl_program /* program */) CL_API_SUFFIX__VERSION_1_0;
654
655 extern CL_API_ENTRY cl_int CL_API_CALL
656 clBuildProgram(cl_program /* program */,
657 cl_uint /* num_devices */,
658 const cl_device_id * /* device_list */,
659 const char * /* options */,
660 void (CL_CALLBACK * /* pfn_notify */)(cl_program /* program */, void * /* user_data */),
661 void * /* user_data */) CL_API_SUFFIX__VERSION_1_0;
662
663 extern CL_API_ENTRY cl_int CL_API_CALL
664 clUnloadCompiler(void) CL_API_SUFFIX__VERSION_1_0;
665
666 extern CL_API_ENTRY cl_int CL_API_CALL
667 clGetProgramInfo(cl_program /* program */,
668 cl_program_info /* param_name */,
669 size_t /* param_value_size */,
670 void * /* param_value */,
671 size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
672
673 extern CL_API_ENTRY cl_int CL_API_CALL
674 clGetProgramBuildInfo(cl_program /* program */,
675 cl_device_id /* device */,
676 cl_program_build_info /* param_name */,
677 size_t /* param_value_size */,
678 void * /* param_value */,
679 size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
680
681 /* Kernel Object APIs */
682 extern CL_API_ENTRY cl_kernel CL_API_CALL
683 clCreateKernel(cl_program /* program */,
684 const char * /* kernel_name */,
685 cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
686
687 extern CL_API_ENTRY cl_int CL_API_CALL
688 clCreateKernelsInProgram(cl_program /* program */,
689 cl_uint /* num_kernels */,
690 cl_kernel * /* kernels */,
691 cl_uint * /* num_kernels_ret */) CL_API_SUFFIX__VERSION_1_0;
692
693 extern CL_API_ENTRY cl_int CL_API_CALL
694 clRetainKernel(cl_kernel /* kernel */) CL_API_SUFFIX__VERSION_1_0;
695
696 extern CL_API_ENTRY cl_int CL_API_CALL
697 clReleaseKernel(cl_kernel /* kernel */) CL_API_SUFFIX__VERSION_1_0;
698
699 extern CL_API_ENTRY cl_int CL_API_CALL
700 clSetKernelArg(cl_kernel /* kernel */,
701 cl_uint /* arg_index */,
702 size_t /* arg_size */,
703 const void * /* arg_value */) CL_API_SUFFIX__VERSION_1_0;
704
705 extern CL_API_ENTRY cl_int CL_API_CALL
706 clGetKernelInfo(cl_kernel /* kernel */,
707 cl_kernel_info /* param_name */,
708 size_t /* param_value_size */,
709 void * /* param_value */,
710 size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
711
712 extern CL_API_ENTRY cl_int CL_API_CALL
713 clGetKernelWorkGroupInfo(cl_kernel /* kernel */,
714 cl_device_id /* device */,
715 cl_kernel_work_group_info /* param_name */,
716 size_t /* param_value_size */,
717 void * /* param_value */,
718 size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
719
720 /* Event Object APIs */
721 extern CL_API_ENTRY cl_int CL_API_CALL
722 clWaitForEvents(cl_uint /* num_events */,
723 const cl_event * /* event_list */) CL_API_SUFFIX__VERSION_1_0;
724
725 extern CL_API_ENTRY cl_int CL_API_CALL
726 clGetEventInfo(cl_event /* event */,
727 cl_event_info /* param_name */,
728 size_t /* param_value_size */,
729 void * /* param_value */,
730 size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
731
732 extern CL_API_ENTRY cl_event CL_API_CALL
733 clCreateUserEvent(cl_context /* context */,
734 cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_1;
735
736 extern CL_API_ENTRY cl_int CL_API_CALL
737 clRetainEvent(cl_event /* event */) CL_API_SUFFIX__VERSION_1_0;
738
739 extern CL_API_ENTRY cl_int CL_API_CALL
740 clReleaseEvent(cl_event /* event */) CL_API_SUFFIX__VERSION_1_0;
741
742 extern CL_API_ENTRY cl_int CL_API_CALL
743 clSetUserEventStatus(cl_event /* event */,
744 cl_int /* execution_status */) CL_API_SUFFIX__VERSION_1_1;
745
746 extern CL_API_ENTRY cl_int CL_API_CALL
747 clSetEventCallback( cl_event /* event */,
748 cl_int /* command_exec_callback_type */,
749 void (CL_CALLBACK * /* pfn_notify */)(cl_event, cl_int, void *),
750 void * /* user_data */) CL_API_SUFFIX__VERSION_1_1;
751
752 /* Profiling APIs */
753 extern CL_API_ENTRY cl_int CL_API_CALL
754 clGetEventProfilingInfo(cl_event /* event */,
755 cl_profiling_info /* param_name */,
756 size_t /* param_value_size */,
757 void * /* param_value */,
758 size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
759
760 /* Flush and Finish APIs */
761 extern CL_API_ENTRY cl_int CL_API_CALL
762 clFlush(cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_1_0;
763
764 extern CL_API_ENTRY cl_int CL_API_CALL
765 clFinish(cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_1_0;
766
767 /* Enqueued Commands APIs */
768 extern CL_API_ENTRY cl_int CL_API_CALL
769 clEnqueueReadBuffer(cl_command_queue /* command_queue */,
770 cl_mem /* buffer */,
771 cl_bool /* blocking_read */,
772 size_t /* offset */,
773 size_t /* cb */,
774 void * /* ptr */,
775 cl_uint /* num_events_in_wait_list */,
776 const cl_event * /* event_wait_list */,
777 cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
778
779 extern CL_API_ENTRY cl_int CL_API_CALL
780 clEnqueueReadBufferRect(cl_command_queue /* command_queue */,
781 cl_mem /* buffer */,
782 cl_bool /* blocking_read */,
783 const size_t * /* buffer_origin */,
784 const size_t * /* host_origin */,
785 const size_t * /* region */,
786 size_t /* buffer_row_pitch */,
787 size_t /* buffer_slice_pitch */,
788 size_t /* host_row_pitch */,
789 size_t /* host_slice_pitch */,
790 void * /* ptr */,
791 cl_uint /* num_events_in_wait_list */,
792 const cl_event * /* event_wait_list */,
793 cl_event * /* event */) CL_API_SUFFIX__VERSION_1_1;
794
795 extern CL_API_ENTRY cl_int CL_API_CALL
796 clEnqueueWriteBuffer(cl_command_queue /* command_queue */,
797 cl_mem /* buffer */,
798 cl_bool /* blocking_write */,
799 size_t /* offset */,
800 size_t /* cb */,
801 const void * /* ptr */,
802 cl_uint /* num_events_in_wait_list */,
803 const cl_event * /* event_wait_list */,
804 cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
805
806 extern CL_API_ENTRY cl_int CL_API_CALL
807 clEnqueueWriteBufferRect(cl_command_queue /* command_queue */,
808 cl_mem /* buffer */,
809 cl_bool /* blocking_write */,
810 const size_t * /* buffer_origin */,
811 const size_t * /* host_origin */,
812 const size_t * /* region */,
813 size_t /* buffer_row_pitch */,
814 size_t /* buffer_slice_pitch */,
815 size_t /* host_row_pitch */,
816 size_t /* host_slice_pitch */,
817 const void * /* ptr */,
818 cl_uint /* num_events_in_wait_list */,
819 const cl_event * /* event_wait_list */,
820 cl_event * /* event */) CL_API_SUFFIX__VERSION_1_1;
821
822 extern CL_API_ENTRY cl_int CL_API_CALL
823 clEnqueueCopyBuffer(cl_command_queue /* command_queue */,
824 cl_mem /* src_buffer */,
825 cl_mem /* dst_buffer */,
826 size_t /* src_offset */,
827 size_t /* dst_offset */,
828 size_t /* cb */,
829 cl_uint /* num_events_in_wait_list */,
830 const cl_event * /* event_wait_list */,
831 cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
832
833 extern CL_API_ENTRY cl_int CL_API_CALL
834 clEnqueueCopyBufferRect(cl_command_queue /* command_queue */,
835 cl_mem /* src_buffer */,
836 cl_mem /* dst_buffer */,
837 const size_t * /* src_origin */,
838 const size_t * /* dst_origin */,
839 const size_t * /* region */,
840 size_t /* src_row_pitch */,
841 size_t /* src_slice_pitch */,
842 size_t /* dst_row_pitch */,
843 size_t /* dst_slice_pitch */,
844 cl_uint /* num_events_in_wait_list */,
845 const cl_event * /* event_wait_list */,
846 cl_event * /* event */) CL_API_SUFFIX__VERSION_1_1;
847
848 extern CL_API_ENTRY cl_int CL_API_CALL
849 clEnqueueReadImage(cl_command_queue /* command_queue */,
850 cl_mem /* image */,
851 cl_bool /* blocking_read */,
852 const size_t * /* origin[3] */,
853 const size_t * /* region[3] */,
854 size_t /* row_pitch */,
855 size_t /* slice_pitch */,
856 void * /* ptr */,
857 cl_uint /* num_events_in_wait_list */,
858 const cl_event * /* event_wait_list */,
859 cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
860
861 extern CL_API_ENTRY cl_int CL_API_CALL
862 clEnqueueWriteImage(cl_command_queue /* command_queue */,
863 cl_mem /* image */,
864 cl_bool /* blocking_write */,
865 const size_t * /* origin[3] */,
866 const size_t * /* region[3] */,
867 size_t /* input_row_pitch */,
868 size_t /* input_slice_pitch */,
869 const void * /* ptr */,
870 cl_uint /* num_events_in_wait_list */,
871 const cl_event * /* event_wait_list */,
872 cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
873
874 extern CL_API_ENTRY cl_int CL_API_CALL
875 clEnqueueCopyImage(cl_command_queue /* command_queue */,
876 cl_mem /* src_image */,
877 cl_mem /* dst_image */,
878 const size_t * /* src_origin[3] */,
879 const size_t * /* dst_origin[3] */,
880 const size_t * /* region[3] */,
881 cl_uint /* num_events_in_wait_list */,
882 const cl_event * /* event_wait_list */,
883 cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
884
885 extern CL_API_ENTRY cl_int CL_API_CALL
886 clEnqueueCopyImageToBuffer(cl_command_queue /* command_queue */,
887 cl_mem /* src_image */,
888 cl_mem /* dst_buffer */,
889 const size_t * /* src_origin[3] */,
890 const size_t * /* region[3] */,
891 size_t /* dst_offset */,
892 cl_uint /* num_events_in_wait_list */,
893 const cl_event * /* event_wait_list */,
894 cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
895
896 extern CL_API_ENTRY cl_int CL_API_CALL
897 clEnqueueCopyBufferToImage(cl_command_queue /* command_queue */,
898 cl_mem /* src_buffer */,
899 cl_mem /* dst_image */,
900 size_t /* src_offset */,
901 const size_t * /* dst_origin[3] */,
902 const size_t * /* region[3] */,
903 cl_uint /* num_events_in_wait_list */,
904 const cl_event * /* event_wait_list */,
905 cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
906
907 extern CL_API_ENTRY void * CL_API_CALL
908 clEnqueueMapBuffer(cl_command_queue /* command_queue */,
909 cl_mem /* buffer */,
910 cl_bool /* blocking_map */,
911 cl_map_flags /* map_flags */,
912 size_t /* offset */,
913 size_t /* cb */,
914 cl_uint /* num_events_in_wait_list */,
915 const cl_event * /* event_wait_list */,
916 cl_event * /* event */,
917 cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
918
919 extern CL_API_ENTRY void * CL_API_CALL
920 clEnqueueMapImage(cl_command_queue /* command_queue */,
921 cl_mem /* image */,
922 cl_bool /* blocking_map */,
923 cl_map_flags /* map_flags */,
924 const size_t * /* origin[3] */,
925 const size_t * /* region[3] */,
926 size_t * /* image_row_pitch */,
927 size_t * /* image_slice_pitch */,
928 cl_uint /* num_events_in_wait_list */,
929 const cl_event * /* event_wait_list */,
930 cl_event * /* event */,
931 cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
932
933 extern CL_API_ENTRY cl_int CL_API_CALL
934 clEnqueueUnmapMemObject(cl_command_queue /* command_queue */,
935 cl_mem /* memobj */,
936 void * /* mapped_ptr */,
937 cl_uint /* num_events_in_wait_list */,
938 const cl_event * /* event_wait_list */,
939 cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
940
941 extern CL_API_ENTRY cl_int CL_API_CALL
942 clEnqueueNDRangeKernel(cl_command_queue /* command_queue */,
943 cl_kernel /* kernel */,
944 cl_uint /* work_dim */,
945 const size_t * /* global_work_offset */,
946 const size_t * /* global_work_size */,
947 const size_t * /* local_work_size */,
948 cl_uint /* num_events_in_wait_list */,
949 const cl_event * /* event_wait_list */,
950 cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
951
952 extern CL_API_ENTRY cl_int CL_API_CALL
953 clEnqueueTask(cl_command_queue /* command_queue */,
954 cl_kernel /* kernel */,
955 cl_uint /* num_events_in_wait_list */,
956 const cl_event * /* event_wait_list */,
957 cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
958
959 extern CL_API_ENTRY cl_int CL_API_CALL
960 clEnqueueNativeKernel(cl_command_queue /* command_queue */,
961 void (*user_func)(void *),
962 void * /* args */,
963 size_t /* cb_args */,
964 cl_uint /* num_mem_objects */,
965 const cl_mem * /* mem_list */,
966 const void ** /* args_mem_loc */,
967 cl_uint /* num_events_in_wait_list */,
968 const cl_event * /* event_wait_list */,
969 cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
970
971 extern CL_API_ENTRY cl_int CL_API_CALL
972 clEnqueueMarker(cl_command_queue /* command_queue */,
973 cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
974
975 extern CL_API_ENTRY cl_int CL_API_CALL
976 clEnqueueWaitForEvents(cl_command_queue /* command_queue */,
977 cl_uint /* num_events */,
978 const cl_event * /* event_list */) CL_API_SUFFIX__VERSION_1_0;
979
980 extern CL_API_ENTRY cl_int CL_API_CALL
981 clEnqueueBarrier(cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_1_0;
982
983 /* Extension function access
984 *
985 * Returns the extension function address for the given function name,
986 * or NULL if a valid function can not be found. The client must
987 * check to make sure the address is not NULL, before using or
988 * calling the returned function address.
989 */
990 extern CL_API_ENTRY void * CL_API_CALL clGetExtensionFunctionAddress(const char * /* func_name */) CL_API_SUFFIX__VERSION_1_0;
991
992 #ifdef __cplusplus
993 }
994 #endif
995
996 #endif /* __OPENCL_CL_H */
997
0 /**********************************************************************************
1 * Copyright (c) 2008-2010 The Khronos Group Inc.
2 *
3 * Permission is hereby granted, free of charge, to any person obtaining a
4 * copy of this software and/or associated documentation files (the
5 * "Materials"), to deal in the Materials without restriction, including
6 * without limitation the rights to use, copy, modify, merge, publish,
7 * distribute, sublicense, and/or sell copies of the Materials, and to
8 * permit persons to whom the Materials are furnished to do so, subject to
9 * the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Materials.
13 *
14 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20 * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
21 **********************************************************************************/
22
23 /* $Revision: 11708 $ on $Date: 2010-06-13 23:36:24 -0700 (Sun, 13 Jun 2010) $ */
24
25 #ifndef __OPENCL_CL_D3D10_H
26 #define __OPENCL_CL_D3D10_H
27
28 #include <d3d10.h>
29 #include <CL/cl.h>
30 #include <CL/cl_platform.h>
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35
36 /******************************************************************************
37 * cl_khr_d3d10_sharing */
38 #define cl_khr_d3d10_sharing 1
39
40 typedef cl_uint cl_d3d10_device_source_khr;
41 typedef cl_uint cl_d3d10_device_set_khr;
42
43 /******************************************************************************/
44
45 // Error Codes
46 #define CL_INVALID_D3D10_DEVICE_KHR -1002
47 #define CL_INVALID_D3D10_RESOURCE_KHR -1003
48 #define CL_D3D10_RESOURCE_ALREADY_ACQUIRED_KHR -1004
49 #define CL_D3D10_RESOURCE_NOT_ACQUIRED_KHR -1005
50
51 // cl_d3d10_device_source_nv
52 #define CL_D3D10_DEVICE_KHR 0x4010
53 #define CL_D3D10_DXGI_ADAPTER_KHR 0x4011
54
55 // cl_d3d10_device_set_nv
56 #define CL_PREFERRED_DEVICES_FOR_D3D10_KHR 0x4012
57 #define CL_ALL_DEVICES_FOR_D3D10_KHR 0x4013
58
59 // cl_context_info
60 #define CL_CONTEXT_D3D10_DEVICE_KHR 0x4014
61 #define CL_CONTEXT_D3D10_PREFER_SHARED_RESOURCES_KHR 0x402C
62
63 // cl_mem_info
64 #define CL_MEM_D3D10_RESOURCE_KHR 0x4015
65
66 // cl_image_info
67 #define CL_IMAGE_D3D10_SUBRESOURCE_KHR 0x4016
68
69 // cl_command_type
70 #define CL_COMMAND_ACQUIRE_D3D10_OBJECTS_KHR 0x4017
71 #define CL_COMMAND_RELEASE_D3D10_OBJECTS_KHR 0x4018
72
73 /******************************************************************************/
74
75 typedef CL_API_ENTRY cl_int (CL_API_CALL *clGetDeviceIDsFromD3D10KHR_fn)(
76 cl_platform_id platform,
77 cl_d3d10_device_source_khr d3d_device_source,
78 void * d3d_object,
79 cl_d3d10_device_set_khr d3d_device_set,
80 cl_uint num_entries,
81 cl_device_id * devices,
82 cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_0;
83
84 typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D10BufferKHR_fn)(
85 cl_context context,
86 cl_mem_flags flags,
87 ID3D10Buffer * resource,
88 cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0;
89
90 typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D10Texture2DKHR_fn)(
91 cl_context context,
92 cl_mem_flags flags,
93 ID3D10Texture2D * resource,
94 UINT subresource,
95 cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0;
96
97 typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D10Texture3DKHR_fn)(
98 cl_context context,
99 cl_mem_flags flags,
100 ID3D10Texture3D * resource,
101 UINT subresource,
102 cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0;
103
104 typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueAcquireD3D10ObjectsKHR_fn)(
105 cl_command_queue command_queue,
106 cl_uint num_objects,
107 const cl_mem * mem_objects,
108 cl_uint num_events_in_wait_list,
109 const cl_event * event_wait_list,
110 cl_event * event) CL_API_SUFFIX__VERSION_1_0;
111
112 typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueReleaseD3D10ObjectsKHR_fn)(
113 cl_command_queue command_queue,
114 cl_uint num_objects,
115 cl_mem * mem_objects,
116 cl_uint num_events_in_wait_list,
117 const cl_event * event_wait_list,
118 cl_event * event) CL_API_SUFFIX__VERSION_1_0;
119
120 #ifdef __cplusplus
121 }
122 #endif
123
124 #endif // __OPENCL_CL_D3D10_H
125
0 /*******************************************************************************
1 * Copyright (c) 2008-2010 The Khronos Group Inc.
2 *
3 * Permission is hereby granted, free of charge, to any person obtaining a
4 * copy of this software and/or associated documentation files (the
5 * "Materials"), to deal in the Materials without restriction, including
6 * without limitation the rights to use, copy, modify, merge, publish,
7 * distribute, sublicense, and/or sell copies of the Materials, and to
8 * permit persons to whom the Materials are furnished to do so, subject to
9 * the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Materials.
13 *
14 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20 * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
21 ******************************************************************************/
22
23 /* $Revision: 11928 $ on $Date: 2010-07-13 09:04:56 -0700 (Tue, 13 Jul 2010) $ */
24
25 /* cl_ext.h contains OpenCL extensions which don't have external */
26 /* (OpenGL, D3D) dependencies. */
27
28 #ifndef __CL_EXT_H
29 #define __CL_EXT_H
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 #ifdef __APPLE__
36 #include <OpenCL/cl.h>
37 #include <AvailabilityMacros.h>
38 #else
39 #include <CL/cl.h>
40 #endif
41
42 /* cl_khr_fp64 extension - no extension #define since it has no functions */
43 #define CL_DEVICE_DOUBLE_FP_CONFIG 0x1032
44
45 /* cl_khr_fp16 extension - no extension #define since it has no functions */
46 #define CL_DEVICE_HALF_FP_CONFIG 0x1033
47
48 /* Memory object destruction
49 *
50 * Apple extension for use to manage externally allocated buffers used with cl_mem objects with CL_MEM_USE_HOST_PTR
51 *
52 * Registers a user callback function that will be called when the memory object is deleted and its resources
53 * freed. Each call to clSetMemObjectCallbackFn registers the specified user callback function on a callback
54 * stack associated with memobj. The registered user callback functions are called in the reverse order in
55 * which they were registered. The user callback functions are called and then the memory object is deleted
56 * and its resources freed. This provides a mechanism for the application (and libraries) using memobj to be
57 * notified when the memory referenced by host_ptr, specified when the memory object is created and used as
58 * the storage bits for the memory object, can be reused or freed.
59 *
60 * The application may not call CL api's with the cl_mem object passed to the pfn_notify.
61 *
62 * Please check for the "cl_APPLE_SetMemObjectDestructor" extension using clGetDeviceInfo(CL_DEVICE_EXTENSIONS)
63 * before using.
64 */
65 #define cl_APPLE_SetMemObjectDestructor 1
66 cl_int CL_API_ENTRY clSetMemObjectDestructorAPPLE( cl_mem /* memobj */,
67 void (* /*pfn_notify*/)( cl_mem /* memobj */, void* /*user_data*/),
68 void * /*user_data */ ) CL_EXT_SUFFIX__VERSION_1_0;
69
70
71 /* Context Logging Functions
72 *
73 * The next three convenience functions are intended to be used as the pfn_notify parameter to clCreateContext().
74 * Please check for the "cl_APPLE_ContextLoggingFunctions" extension using clGetDeviceInfo(CL_DEVICE_EXTENSIONS)
75 * before using.
76 *
77 * clLogMessagesToSystemLog fowards on all log messages to the Apple System Logger
78 */
79 #define cl_APPLE_ContextLoggingFunctions 1
80 extern void CL_API_ENTRY clLogMessagesToSystemLogAPPLE( const char * /* errstr */,
81 const void * /* private_info */,
82 size_t /* cb */,
83 void * /* user_data */ ) CL_EXT_SUFFIX__VERSION_1_0;
84
85 /* clLogMessagesToStdout sends all log messages to the file descriptor stdout */
86 extern void CL_API_ENTRY clLogMessagesToStdoutAPPLE( const char * /* errstr */,
87 const void * /* private_info */,
88 size_t /* cb */,
89 void * /* user_data */ ) CL_EXT_SUFFIX__VERSION_1_0;
90
91 /* clLogMessagesToStderr sends all log messages to the file descriptor stderr */
92 extern void CL_API_ENTRY clLogMessagesToStderrAPPLE( const char * /* errstr */,
93 const void * /* private_info */,
94 size_t /* cb */,
95 void * /* user_data */ ) CL_EXT_SUFFIX__VERSION_1_0;
96
97
98 /************************
99 * cl_khr_icd extension *
100 ************************/
101 #define cl_khr_icd 1
102
103 /* cl_platform_info */
104 #define CL_PLATFORM_ICD_SUFFIX_KHR 0x0920
105
106 /* Additional Error Codes */
107 #define CL_PLATFORM_NOT_FOUND_KHR -1001
108
109 extern CL_API_ENTRY cl_int CL_API_CALL
110 clIcdGetPlatformIDsKHR(cl_uint /* num_entries */,
111 cl_platform_id * /* platforms */,
112 cl_uint * /* num_platforms */);
113
114 typedef CL_API_ENTRY cl_int (CL_API_CALL *clIcdGetPlatformIDsKHR_fn)(
115 cl_uint /* num_entries */,
116 cl_platform_id * /* platforms */,
117 cl_uint * /* num_platforms */);
118
119
120 /******************************************
121 * cl_nv_device_attribute_query extension *
122 ******************************************/
123 /* cl_nv_device_attribute_query extension - no extension #define since it has no functions */
124 #define CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV 0x4000
125 #define CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV 0x4001
126 #define CL_DEVICE_REGISTERS_PER_BLOCK_NV 0x4002
127 #define CL_DEVICE_WARP_SIZE_NV 0x4003
128 #define CL_DEVICE_GPU_OVERLAP_NV 0x4004
129 #define CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV 0x4005
130 #define CL_DEVICE_INTEGRATED_MEMORY_NV 0x4006
131
132
133 /*********************************
134 * cl_amd_device_attribute_query *
135 *********************************/
136 #define CL_DEVICE_PROFILING_TIMER_OFFSET_AMD 0x4036
137
138
139 #ifdef CL_VERSION_1_1
140 /***********************************
141 * cl_ext_device_fission extension *
142 ***********************************/
143 #define cl_ext_device_fission 1
144
145 extern CL_API_ENTRY cl_int CL_API_CALL
146 clReleaseDeviceEXT( cl_device_id /*device*/ ) CL_EXT_SUFFIX__VERSION_1_1;
147
148 typedef CL_API_ENTRY cl_int
149 (CL_API_CALL *clReleaseDeviceEXT_fn)( cl_device_id /*device*/ ) CL_EXT_SUFFIX__VERSION_1_1;
150
151 extern CL_API_ENTRY cl_int CL_API_CALL
152 clRetainDeviceEXT( cl_device_id /*device*/ ) CL_EXT_SUFFIX__VERSION_1_1;
153
154 typedef CL_API_ENTRY cl_int
155 (CL_API_CALL *clRetainDeviceEXT_fn)( cl_device_id /*device*/ ) CL_EXT_SUFFIX__VERSION_1_1;
156
157 typedef cl_ulong cl_device_partition_property_ext;
158 extern CL_API_ENTRY cl_int CL_API_CALL
159 clCreateSubDevicesEXT( cl_device_id /*in_device*/,
160 const cl_device_partition_property_ext * /* properties */,
161 cl_uint /*num_entries*/,
162 cl_device_id * /*out_devices*/,
163 cl_uint * /*num_devices*/ ) CL_EXT_SUFFIX__VERSION_1_1;
164
165 typedef CL_API_ENTRY cl_int
166 ( CL_API_CALL * clCreateSubDevicesEXT_fn)( cl_device_id /*in_device*/,
167 const cl_device_partition_property_ext * /* properties */,
168 cl_uint /*num_entries*/,
169 cl_device_id * /*out_devices*/,
170 cl_uint * /*num_devices*/ ) CL_EXT_SUFFIX__VERSION_1_1;
171
172 /* cl_device_partition_property_ext */
173 #define CL_DEVICE_PARTITION_EQUALLY_EXT 0x4050
174 #define CL_DEVICE_PARTITION_BY_COUNTS_EXT 0x4051
175 #define CL_DEVICE_PARTITION_BY_NAMES_EXT 0x4052
176 #define CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN_EXT 0x4053
177
178 /* clDeviceGetInfo selectors */
179 #define CL_DEVICE_PARENT_DEVICE_EXT 0x4054
180 #define CL_DEVICE_PARTITION_TYPES_EXT 0x4055
181 #define CL_DEVICE_AFFINITY_DOMAINS_EXT 0x4056
182 #define CL_DEVICE_REFERENCE_COUNT_EXT 0x4057
183 #define CL_DEVICE_PARTITION_STYLE_EXT 0x4058
184
185 /* error codes */
186 #define CL_DEVICE_PARTITION_FAILED_EXT -1057
187 #define CL_INVALID_PARTITION_COUNT_EXT -1058
188 #define CL_INVALID_PARTITION_NAME_EXT -1059
189
190 /* CL_AFFINITY_DOMAINs */
191 #define CL_AFFINITY_DOMAIN_L1_CACHE_EXT 0x1
192 #define CL_AFFINITY_DOMAIN_L2_CACHE_EXT 0x2
193 #define CL_AFFINITY_DOMAIN_L3_CACHE_EXT 0x3
194 #define CL_AFFINITY_DOMAIN_L4_CACHE_EXT 0x4
195 #define CL_AFFINITY_DOMAIN_NUMA_EXT 0x10
196 #define CL_AFFINITY_DOMAIN_NEXT_FISSIONABLE_EXT 0x100
197
198 /* cl_device_partition_property_ext list terminators */
199 #define CL_PROPERTIES_LIST_END_EXT ((cl_device_partition_property_ext) 0)
200 #define CL_PARTITION_BY_COUNTS_LIST_END_EXT ((cl_device_partition_property_ext) 0)
201 #define CL_PARTITION_BY_NAMES_LIST_END_EXT ((cl_device_partition_property_ext) 0 - 1)
202
203
204
205 #endif /* CL_VERSION_1_1 */
206
207 #ifdef __cplusplus
208 }
209 #endif
210
211
212 #endif /* __CL_EXT_H */
0 /**********************************************************************************
1 * Copyright (c) 2008-2010 The Khronos Group Inc.
2 *
3 * Permission is hereby granted, free of charge, to any person obtaining a
4 * copy of this software and/or associated documentation files (the
5 * "Materials"), to deal in the Materials without restriction, including
6 * without limitation the rights to use, copy, modify, merge, publish,
7 * distribute, sublicense, and/or sell copies of the Materials, and to
8 * permit persons to whom the Materials are furnished to do so, subject to
9 * the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Materials.
13 *
14 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20 * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
21 **********************************************************************************/
22
23 /* $Revision: 11708 $ on $Date: 2010-06-13 23:36:24 -0700 (Sun, 13 Jun 2010) $ */
24
25 /*
26 * cl_gl.h contains Khronos-approved (KHR) OpenCL extensions which have
27 * OpenGL dependencies. The application is responsible for #including
28 * OpenGL or OpenGL ES headers before #including cl_gl.h.
29 */
30
31 #ifndef __OPENCL_CL_GL_H
32 #define __OPENCL_CL_GL_H
33
34 #ifdef __APPLE__
35 #include <OpenCL/cl.h>
36 #include <OpenGL/CGLDevice.h>
37 #else
38 #include <CL/cl.h>
39 #endif
40
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44
45 typedef cl_uint cl_gl_object_type;
46 typedef cl_uint cl_gl_texture_info;
47 typedef cl_uint cl_gl_platform_info;
48 typedef struct __GLsync *cl_GLsync;
49
50 /* cl_gl_object_type */
51 #define CL_GL_OBJECT_BUFFER 0x2000
52 #define CL_GL_OBJECT_TEXTURE2D 0x2001
53 #define CL_GL_OBJECT_TEXTURE3D 0x2002
54 #define CL_GL_OBJECT_RENDERBUFFER 0x2003
55
56 /* cl_gl_texture_info */
57 #define CL_GL_TEXTURE_TARGET 0x2004
58 #define CL_GL_MIPMAP_LEVEL 0x2005
59
60 extern CL_API_ENTRY cl_mem CL_API_CALL
61 clCreateFromGLBuffer(cl_context /* context */,
62 cl_mem_flags /* flags */,
63 cl_GLuint /* bufobj */,
64 int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
65
66 extern CL_API_ENTRY cl_mem CL_API_CALL
67 clCreateFromGLTexture2D(cl_context /* context */,
68 cl_mem_flags /* flags */,
69 cl_GLenum /* target */,
70 cl_GLint /* miplevel */,
71 cl_GLuint /* texture */,
72 cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
73
74 extern CL_API_ENTRY cl_mem CL_API_CALL
75 clCreateFromGLTexture3D(cl_context /* context */,
76 cl_mem_flags /* flags */,
77 cl_GLenum /* target */,
78 cl_GLint /* miplevel */,
79 cl_GLuint /* texture */,
80 cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
81
82 extern CL_API_ENTRY cl_mem CL_API_CALL
83 clCreateFromGLRenderbuffer(cl_context /* context */,
84 cl_mem_flags /* flags */,
85 cl_GLuint /* renderbuffer */,
86 cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
87
88 extern CL_API_ENTRY cl_int CL_API_CALL
89 clGetGLObjectInfo(cl_mem /* memobj */,
90 cl_gl_object_type * /* gl_object_type */,
91 cl_GLuint * /* gl_object_name */) CL_API_SUFFIX__VERSION_1_0;
92
93 extern CL_API_ENTRY cl_int CL_API_CALL
94 clGetGLTextureInfo(cl_mem /* memobj */,
95 cl_gl_texture_info /* param_name */,
96 size_t /* param_value_size */,
97 void * /* param_value */,
98 size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
99
100 extern CL_API_ENTRY cl_int CL_API_CALL
101 clEnqueueAcquireGLObjects(cl_command_queue /* command_queue */,
102 cl_uint /* num_objects */,
103 const cl_mem * /* mem_objects */,
104 cl_uint /* num_events_in_wait_list */,
105 const cl_event * /* event_wait_list */,
106 cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
107
108 extern CL_API_ENTRY cl_int CL_API_CALL
109 clEnqueueReleaseGLObjects(cl_command_queue /* command_queue */,
110 cl_uint /* num_objects */,
111 const cl_mem * /* mem_objects */,
112 cl_uint /* num_events_in_wait_list */,
113 const cl_event * /* event_wait_list */,
114 cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
115
116 /* cl_khr_gl_sharing extension */
117
118 #define cl_khr_gl_sharing 1
119
120 typedef cl_uint cl_gl_context_info;
121
122 /* Additional Error Codes */
123 #define CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR -1000
124
125 /* cl_gl_context_info */
126 #define CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR 0x2006
127 #define CL_DEVICES_FOR_GL_CONTEXT_KHR 0x2007
128
129 /* Additional cl_context_properties */
130 #define CL_GL_CONTEXT_KHR 0x2008
131 #define CL_EGL_DISPLAY_KHR 0x2009
132 #define CL_GLX_DISPLAY_KHR 0x200A
133 #define CL_WGL_HDC_KHR 0x200B
134 #define CL_CGL_SHAREGROUP_KHR 0x200C
135
136 extern CL_API_ENTRY cl_int CL_API_CALL
137 clGetGLContextInfoKHR(const cl_context_properties * /* properties */,
138 cl_gl_context_info /* param_name */,
139 size_t /* param_value_size */,
140 void * /* param_value */,
141 size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
142
143 typedef CL_API_ENTRY cl_int (CL_API_CALL *clGetGLContextInfoKHR_fn)(
144 const cl_context_properties * properties,
145 cl_gl_context_info param_name,
146 size_t param_value_size,
147 void * param_value,
148 size_t * param_value_size_ret);
149
150 #ifdef __cplusplus
151 }
152 #endif
153
154 #endif /* __OPENCL_CL_GL_H */
0 /**********************************************************************************
1 * Copyright (c) 2008-2010 The Khronos Group Inc.
2 *
3 * Permission is hereby granted, free of charge, to any person obtaining a
4 * copy of this software and/or associated documentation files (the
5 * "Materials"), to deal in the Materials without restriction, including
6 * without limitation the rights to use, copy, modify, merge, publish,
7 * distribute, sublicense, and/or sell copies of the Materials, and to
8 * permit persons to whom the Materials are furnished to do so, subject to
9 * the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Materials.
13 *
14 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20 * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
21 **********************************************************************************/
22
23 /* $Revision: 11708 $ on $Date: 2010-06-13 23:36:24 -0700 (Sun, 13 Jun 2010) $ */
24
25 /* cl_gl_ext.h contains vendor (non-KHR) OpenCL extensions which have */
26 /* OpenGL dependencies. */
27
28 #ifndef __OPENCL_CL_GL_EXT_H
29 #define __OPENCL_CL_GL_EXT_H
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 #ifdef __APPLE__
36 #include <OpenCL/cl_gl.h>
37 #else
38 #include <CL/cl_gl.h>
39 #endif
40
41 /*
42 * For each extension, follow this template
43 * /* cl_VEN_extname extension */
44 /* #define cl_VEN_extname 1
45 * ... define new types, if any
46 * ... define new tokens, if any
47 * ... define new APIs, if any
48 *
49 * If you need GLtypes here, mirror them with a cl_GLtype, rather than including a GL header
50 * This allows us to avoid having to decide whether to include GL headers or GLES here.
51 */
52
53 /*
54 * cl_khr_gl_event extension
55 * See section 9.9 in the OpenCL 1.1 spec for more information
56 */
57 #define CL_COMMAND_GL_FENCE_SYNC_OBJECT_KHR 0x200D
58
59 extern CL_API_ENTRY cl_event CL_API_CALL
60 clCreateEventFromGLsyncKHR(cl_context /* context */,
61 cl_GLsync /* cl_GLsync */,
62 cl_int * /* errcode_ret */) CL_EXT_SUFFIX__VERSION_1_1;
63
64 #ifdef __cplusplus
65 }
66 #endif
67
68 #endif /* __OPENCL_CL_GL_EXT_H */
0 /**********************************************************************************
1 * Copyright (c) 2008-2010 The Khronos Group Inc.
2 *
3 * Permission is hereby granted, free of charge, to any person obtaining a
4 * copy of this software and/or associated documentation files (the
5 * "Materials"), to deal in the Materials without restriction, including
6 * without limitation the rights to use, copy, modify, merge, publish,
7 * distribute, sublicense, and/or sell copies of the Materials, and to
8 * permit persons to whom the Materials are furnished to do so, subject to
9 * the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Materials.
13 *
14 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20 * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
21 **********************************************************************************/
22
23 /* $Revision: 11803 $ on $Date: 2010-06-25 10:02:12 -0700 (Fri, 25 Jun 2010) $ */
24
25 #ifndef __CL_PLATFORM_H
26 #define __CL_PLATFORM_H
27
28 #ifdef __APPLE__
29 /* Contains #defines for AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER below */
30 #include <AvailabilityMacros.h>
31 #endif
32
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36
37 #if defined(_WIN32)
38 #define CL_API_ENTRY
39 #define CL_API_CALL __stdcall
40 #define CL_CALLBACK __stdcall
41 #else
42 #define CL_API_ENTRY
43 #define CL_API_CALL
44 #define CL_CALLBACK
45 #endif
46
47 #ifdef __APPLE__
48 #define CL_EXTENSION_WEAK_LINK __attribute__((weak_import))
49 #define CL_API_SUFFIX__VERSION_1_0 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
50 #define CL_EXT_SUFFIX__VERSION_1_0 CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
51 #define CL_API_SUFFIX__VERSION_1_1 CL_EXTENSION_WEAK_LINK
52 #define CL_EXT_SUFFIX__VERSION_1_1 CL_EXTENSION_WEAK_LINK
53 #define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
54 #else
55 #define CL_EXTENSION_WEAK_LINK
56 #define CL_API_SUFFIX__VERSION_1_0
57 #define CL_EXT_SUFFIX__VERSION_1_0
58 #define CL_API_SUFFIX__VERSION_1_1
59 #define CL_EXT_SUFFIX__VERSION_1_1
60 #define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED
61 #endif
62
63 #if (defined (_WIN32) && defined(_MSC_VER))
64
65 /* scalar types */
66 typedef signed __int8 cl_char;
67 typedef unsigned __int8 cl_uchar;
68 typedef signed __int16 cl_short;
69 typedef unsigned __int16 cl_ushort;
70 typedef signed __int32 cl_int;
71 typedef unsigned __int32 cl_uint;
72 typedef signed __int64 cl_long;
73 typedef unsigned __int64 cl_ulong;
74
75 typedef unsigned __int16 cl_half;
76 typedef float cl_float;
77 typedef double cl_double;
78
79 /* Macro names and corresponding values defined by OpenCL */
80 #define CL_CHAR_BIT 8
81 #define CL_SCHAR_MAX 127
82 #define CL_SCHAR_MIN (-127-1)
83 #define CL_CHAR_MAX CL_SCHAR_MAX
84 #define CL_CHAR_MIN CL_SCHAR_MIN
85 #define CL_UCHAR_MAX 255
86 #define CL_SHRT_MAX 32767
87 #define CL_SHRT_MIN (-32767-1)
88 #define CL_USHRT_MAX 65535
89 #define CL_INT_MAX 2147483647
90 #define CL_INT_MIN (-2147483647-1)
91 #define CL_UINT_MAX 0xffffffffU
92 #define CL_LONG_MAX ((cl_long) 0x7FFFFFFFFFFFFFFFLL)
93 #define CL_LONG_MIN ((cl_long) -0x7FFFFFFFFFFFFFFFLL - 1LL)
94 #define CL_ULONG_MAX ((cl_ulong) 0xFFFFFFFFFFFFFFFFULL)
95
96 #define CL_FLT_DIG 6
97 #define CL_FLT_MANT_DIG 24
98 #define CL_FLT_MAX_10_EXP +38
99 #define CL_FLT_MAX_EXP +128
100 #define CL_FLT_MIN_10_EXP -37
101 #define CL_FLT_MIN_EXP -125
102 #define CL_FLT_RADIX 2
103 #define CL_FLT_MAX 340282346638528859811704183484516925440.0f
104 #define CL_FLT_MIN 1.175494350822287507969e-38f
105 #define CL_FLT_EPSILON 0x1.0p-23f
106
107 #define CL_DBL_DIG 15
108 #define CL_DBL_MANT_DIG 53
109 #define CL_DBL_MAX_10_EXP +308
110 #define CL_DBL_MAX_EXP +1024
111 #define CL_DBL_MIN_10_EXP -307
112 #define CL_DBL_MIN_EXP -1021
113 #define CL_DBL_RADIX 2
114 #define CL_DBL_MAX 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0
115 #define CL_DBL_MIN 2.225073858507201383090e-308
116 #define CL_DBL_EPSILON 2.220446049250313080847e-16
117
118 #define CL_M_E 2.718281828459045090796
119 #define CL_M_LOG2E 1.442695040888963387005
120 #define CL_M_LOG10E 0.434294481903251816668
121 #define CL_M_LN2 0.693147180559945286227
122 #define CL_M_LN10 2.302585092994045901094
123 #define CL_M_PI 3.141592653589793115998
124 #define CL_M_PI_2 1.570796326794896557999
125 #define CL_M_PI_4 0.785398163397448278999
126 #define CL_M_1_PI 0.318309886183790691216
127 #define CL_M_2_PI 0.636619772367581382433
128 #define CL_M_2_SQRTPI 1.128379167095512558561
129 #define CL_M_SQRT2 1.414213562373095145475
130 #define CL_M_SQRT1_2 0.707106781186547572737
131
132 #define CL_M_E_F 2.71828174591064f
133 #define CL_M_LOG2E_F 1.44269502162933f
134 #define CL_M_LOG10E_F 0.43429449200630f
135 #define CL_M_LN2_F 0.69314718246460f
136 #define CL_M_LN10_F 2.30258512496948f
137 #define CL_M_PI_F 3.14159274101257f
138 #define CL_M_PI_2_F 1.57079637050629f
139 #define CL_M_PI_4_F 0.78539818525314f
140 #define CL_M_1_PI_F 0.31830987334251f
141 #define CL_M_2_PI_F 0.63661974668503f
142 #define CL_M_2_SQRTPI_F 1.12837922573090f
143 #define CL_M_SQRT2_F 1.41421353816986f
144 #define CL_M_SQRT1_2_F 0.70710676908493f
145
146 #define CL_NAN (CL_INFINITY - CL_INFINITY)
147 #define CL_HUGE_VALF ((cl_float) 1e50)
148 #define CL_HUGE_VAL ((cl_double) 1e500)
149 #define CL_MAXFLOAT CL_FLT_MAX
150 #define CL_INFINITY CL_HUGE_VALF
151
152 #else
153
154 #include <stdint.h>
155
156 /* scalar types */
157 typedef int8_t cl_char;
158 typedef uint8_t cl_uchar;
159 typedef int16_t cl_short __attribute__((aligned(2)));
160 typedef uint16_t cl_ushort __attribute__((aligned(2)));
161 typedef int32_t cl_int __attribute__((aligned(4)));
162 typedef uint32_t cl_uint __attribute__((aligned(4)));
163 typedef int64_t cl_long __attribute__((aligned(8)));
164 typedef uint64_t cl_ulong __attribute__((aligned(8)));
165
166 typedef uint16_t cl_half __attribute__((aligned(2)));
167 typedef float cl_float __attribute__((aligned(4)));
168 typedef double cl_double __attribute__((aligned(8)));
169
170 /* Macro names and corresponding values defined by OpenCL */
171 #define CL_CHAR_BIT 8
172 #define CL_SCHAR_MAX 127
173 #define CL_SCHAR_MIN (-127-1)
174 #define CL_CHAR_MAX CL_SCHAR_MAX
175 #define CL_CHAR_MIN CL_SCHAR_MIN
176 #define CL_UCHAR_MAX 255
177 #define CL_SHRT_MAX 32767
178 #define CL_SHRT_MIN (-32767-1)
179 #define CL_USHRT_MAX 65535
180 #define CL_INT_MAX 2147483647
181 #define CL_INT_MIN (-2147483647-1)
182 #define CL_UINT_MAX 0xffffffffU
183 #define CL_LONG_MAX ((cl_long) 0x7FFFFFFFFFFFFFFFLL)
184 #define CL_LONG_MIN ((cl_long) -0x7FFFFFFFFFFFFFFFLL - 1LL)
185 #define CL_ULONG_MAX ((cl_ulong) 0xFFFFFFFFFFFFFFFFULL)
186
187 #define CL_FLT_DIG 6
188 #define CL_FLT_MANT_DIG 24
189 #define CL_FLT_MAX_10_EXP +38
190 #define CL_FLT_MAX_EXP +128
191 #define CL_FLT_MIN_10_EXP -37
192 #define CL_FLT_MIN_EXP -125
193 #define CL_FLT_RADIX 2
194 #define CL_FLT_MAX 0x1.fffffep127f
195 #define CL_FLT_MIN 0x1.0p-126f
196 #define CL_FLT_EPSILON 0x1.0p-23f
197
198 #define CL_DBL_DIG 15
199 #define CL_DBL_MANT_DIG 53
200 #define CL_DBL_MAX_10_EXP +308
201 #define CL_DBL_MAX_EXP +1024
202 #define CL_DBL_MIN_10_EXP -307
203 #define CL_DBL_MIN_EXP -1021
204 #define CL_DBL_RADIX 2
205 #define CL_DBL_MAX 0x1.fffffffffffffp1023
206 #define CL_DBL_MIN 0x1.0p-1022
207 #define CL_DBL_EPSILON 0x1.0p-52
208
209 #define CL_M_E 2.718281828459045090796
210 #define CL_M_LOG2E 1.442695040888963387005
211 #define CL_M_LOG10E 0.434294481903251816668
212 #define CL_M_LN2 0.693147180559945286227
213 #define CL_M_LN10 2.302585092994045901094
214 #define CL_M_PI 3.141592653589793115998
215 #define CL_M_PI_2 1.570796326794896557999
216 #define CL_M_PI_4 0.785398163397448278999
217 #define CL_M_1_PI 0.318309886183790691216
218 #define CL_M_2_PI 0.636619772367581382433
219 #define CL_M_2_SQRTPI 1.128379167095512558561
220 #define CL_M_SQRT2 1.414213562373095145475
221 #define CL_M_SQRT1_2 0.707106781186547572737
222
223 #define CL_M_E_F 2.71828174591064f
224 #define CL_M_LOG2E_F 1.44269502162933f
225 #define CL_M_LOG10E_F 0.43429449200630f
226 #define CL_M_LN2_F 0.69314718246460f
227 #define CL_M_LN10_F 2.30258512496948f
228 #define CL_M_PI_F 3.14159274101257f
229 #define CL_M_PI_2_F 1.57079637050629f
230 #define CL_M_PI_4_F 0.78539818525314f
231 #define CL_M_1_PI_F 0.31830987334251f
232 #define CL_M_2_PI_F 0.63661974668503f
233 #define CL_M_2_SQRTPI_F 1.12837922573090f
234 #define CL_M_SQRT2_F 1.41421353816986f
235 #define CL_M_SQRT1_2_F 0.70710676908493f
236
237 #if defined( __GNUC__ )
238 #define CL_HUGE_VALF __builtin_huge_valf()
239 #define CL_HUGE_VAL __builtin_huge_val()
240 #define CL_NAN __builtin_nanf( "" )
241 #else
242 #define CL_HUGE_VALF ((cl_float) 1e50)
243 #define CL_HUGE_VAL ((cl_double) 1e500)
244 float nanf( const char * );
245 #define CL_NAN nanf( "" )
246 #endif
247 #define CL_MAXFLOAT CL_FLT_MAX
248 #define CL_INFINITY CL_HUGE_VALF
249
250 #endif
251
252 #include <stddef.h>
253
254 /* Mirror types to GL types. Mirror types allow us to avoid deciding which headers to load based on whether we are using GL or GLES here. */
255 typedef unsigned int cl_GLuint;
256 typedef int cl_GLint;
257 typedef unsigned int cl_GLenum;
258
259 /*
260 * Vector types
261 *
262 * Note: OpenCL requires that all types be naturally aligned.
263 * This means that vector types must be naturally aligned.
264 * For example, a vector of four floats must be aligned to
265 * a 16 byte boundary (calculated as 4 * the natural 4-byte
266 * alignment of the float). The alignment qualifiers here
267 * will only function properly if your compiler supports them
268 * and if you don't actively work to defeat them. For example,
269 * in order for a cl_float4 to be 16 byte aligned in a struct,
270 * the start of the struct must itself be 16-byte aligned.
271 *
272 * Maintaining proper alignment is the user's responsibility.
273 */
274
275 /* Define basic vector types */
276 #if defined( __VEC__ )
277 #include <altivec.h> /* may be omitted depending on compiler. AltiVec spec provides no way to detect whether the header is required. */
278 typedef vector unsigned char __cl_uchar16;
279 typedef vector signed char __cl_char16;
280 typedef vector unsigned short __cl_ushort8;
281 typedef vector signed short __cl_short8;
282 typedef vector unsigned int __cl_uint4;
283 typedef vector signed int __cl_int4;
284 typedef vector float __cl_float4;
285 #define __CL_UCHAR16__ 1
286 #define __CL_CHAR16__ 1
287 #define __CL_USHORT8__ 1
288 #define __CL_SHORT8__ 1
289 #define __CL_UINT4__ 1
290 #define __CL_INT4__ 1
291 #define __CL_FLOAT4__ 1
292 #endif
293
294 #if defined( __SSE__ )
295 #if defined( __MINGW64__ )
296 #include <intrin.h>
297 #else
298 #include <xmmintrin.h>
299 #endif
300 #if defined( __GNUC__ )
301 typedef float __cl_float4 __attribute__((vector_size(16)));
302 #else
303 typedef __m128 __cl_float4;
304 #endif
305 #define __CL_FLOAT4__ 1
306 #endif
307
308 #if defined( __SSE2__ )
309 #if defined( __MINGW64__ )
310 #include <intrin.h>
311 #else
312 #include <emmintrin.h>
313 #endif
314 #if defined( __GNUC__ )
315 typedef cl_uchar __cl_uchar16 __attribute__((vector_size(16)));
316 typedef cl_char __cl_char16 __attribute__((vector_size(16)));
317 typedef cl_ushort __cl_ushort8 __attribute__((vector_size(16)));
318 typedef cl_short __cl_short8 __attribute__((vector_size(16)));
319 typedef cl_uint __cl_uint4 __attribute__((vector_size(16)));
320 typedef cl_int __cl_int4 __attribute__((vector_size(16)));
321 typedef cl_ulong __cl_ulong2 __attribute__((vector_size(16)));
322 typedef cl_long __cl_long2 __attribute__((vector_size(16)));
323 typedef cl_double __cl_double2 __attribute__((vector_size(16)));
324 #else
325 typedef __m128i __cl_uchar16;
326 typedef __m128i __cl_char16;
327 typedef __m128i __cl_ushort8;
328 typedef __m128i __cl_short8;
329 typedef __m128i __cl_uint4;
330 typedef __m128i __cl_int4;
331 typedef __m128i __cl_ulong2;
332 typedef __m128i __cl_long2;
333 typedef __m128d __cl_double2;
334 #endif
335 #define __CL_UCHAR16__ 1
336 #define __CL_CHAR16__ 1
337 #define __CL_USHORT8__ 1
338 #define __CL_SHORT8__ 1
339 #define __CL_INT4__ 1
340 #define __CL_UINT4__ 1
341 #define __CL_ULONG2__ 1
342 #define __CL_LONG2__ 1
343 #define __CL_DOUBLE2__ 1
344 #endif
345
346 #if defined( __MMX__ )
347 #include <mmintrin.h>
348 #if defined( __GNUC__ )
349 typedef cl_uchar __cl_uchar8 __attribute__((vector_size(8)));
350 typedef cl_char __cl_char8 __attribute__((vector_size(8)));
351 typedef cl_ushort __cl_ushort4 __attribute__((vector_size(8)));
352 typedef cl_short __cl_short4 __attribute__((vector_size(8)));
353 typedef cl_uint __cl_uint2 __attribute__((vector_size(8)));
354 typedef cl_int __cl_int2 __attribute__((vector_size(8)));
355 typedef cl_ulong __cl_ulong1 __attribute__((vector_size(8)));
356 typedef cl_long __cl_long1 __attribute__((vector_size(8)));
357 typedef cl_float __cl_float2 __attribute__((vector_size(8)));
358 #else
359 typedef __m64 __cl_uchar8;
360 typedef __m64 __cl_char8;
361 typedef __m64 __cl_ushort4;
362 typedef __m64 __cl_short4;
363 typedef __m64 __cl_uint2;
364 typedef __m64 __cl_int2;
365 typedef __m64 __cl_ulong1;
366 typedef __m64 __cl_long1;
367 typedef __m64 __cl_float2;
368 #endif
369 #define __CL_UCHAR8__ 1
370 #define __CL_CHAR8__ 1
371 #define __CL_USHORT4__ 1
372 #define __CL_SHORT4__ 1
373 #define __CL_INT2__ 1
374 #define __CL_UINT2__ 1
375 #define __CL_ULONG1__ 1
376 #define __CL_LONG1__ 1
377 #define __CL_FLOAT2__ 1
378 #endif
379
380 #if defined( __AVX__ )
381 #if defined( __MINGW64__ )
382 #include <intrin.h>
383 #else
384 #include <immintrin.h>
385 #endif
386 #if defined( __GNUC__ )
387 typedef cl_float __cl_float8 __attribute__((vector_size(32)));
388 typedef cl_double __cl_double4 __attribute__((vector_size(32)));
389 #else
390 typedef __m256 __cl_float8;
391 typedef __m256d __cl_double4;
392 #endif
393 #define __CL_FLOAT8__ 1
394 #define __CL_DOUBLE4__ 1
395 #endif
396
397 /* Define alignment keys */
398 #if defined( __GNUC__ )
399 #define CL_ALIGNED(_x) __attribute__ ((aligned(_x)))
400 #elif defined( _WIN32) && (_MSC_VER)
401 /* Alignment keys neutered on windows because MSVC can't swallow function arguments with alignment requirements */
402 /* http://msdn.microsoft.com/en-us/library/373ak2y1%28VS.71%29.aspx */
403 /* #include <crtdefs.h> */
404 /* #define CL_ALIGNED(_x) _CRT_ALIGN(_x) */
405 #define CL_ALIGNED(_x)
406 #else
407 #warning Need to implement some method to align data here
408 #define CL_ALIGNED(_x)
409 #endif
410
411 /* Indicate whether .xyzw, .s0123 and .hi.lo are supported */
412 #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
413 /* .xyzw and .s0123...{f|F} are supported */
414 #define CL_HAS_NAMED_VECTOR_FIELDS 1
415 /* .hi and .lo are supported */
416 #define CL_HAS_HI_LO_VECTOR_FIELDS 1
417 #endif
418
419 /* Define cl_vector types */
420
421 /* ---- cl_charn ---- */
422 typedef union
423 {
424 cl_char CL_ALIGNED(2) s[2];
425 #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
426 __extension__ struct{ cl_char x, y; };
427 __extension__ struct{ cl_char s0, s1; };
428 __extension__ struct{ cl_char lo, hi; };
429 #endif
430 #if defined( __CL_CHAR2__)
431 __cl_char2 v2;
432 #endif
433 }cl_char2;
434
435 typedef union
436 {
437 cl_char CL_ALIGNED(4) s[4];
438 #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
439 __extension__ struct{ cl_char x, y, z, w; };
440 __extension__ struct{ cl_char s0, s1, s2, s3; };
441 __extension__ struct{ cl_char2 lo, hi; };
442 #endif
443 #if defined( __CL_CHAR2__)
444 __cl_char2 v2[2];
445 #endif
446 #if defined( __CL_CHAR4__)
447 __cl_char4 v4;
448 #endif
449 }cl_char4;
450
451 /* cl_char3 is identical in size, alignment and behavior to cl_char4. See section 6.1.5. */
452 typedef cl_char4 cl_char3;
453
454 typedef union
455 {
456 cl_char CL_ALIGNED(8) s[8];
457 #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
458 __extension__ struct{ cl_char x, y, z, w; };
459 __extension__ struct{ cl_char s0, s1, s2, s3, s4, s5, s6, s7; };
460 __extension__ struct{ cl_char4 lo, hi; };
461 #endif
462 #if defined( __CL_CHAR2__)
463 __cl_char2 v2[4];
464 #endif
465 #if defined( __CL_CHAR4__)
466 __cl_char4 v4[2];
467 #endif
468 #if defined( __CL_CHAR8__ )
469 __cl_char8 v8;
470 #endif
471 }cl_char8;
472
473 typedef union
474 {
475 cl_char CL_ALIGNED(16) s[16];
476 #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
477 __extension__ struct{ cl_char x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
478 __extension__ struct{ cl_char s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
479 __extension__ struct{ cl_char8 lo, hi; };
480 #endif
481 #if defined( __CL_CHAR2__)
482 __cl_char2 v2[8];
483 #endif
484 #if defined( __CL_CHAR4__)
485 __cl_char4 v4[4];
486 #endif
487 #if defined( __CL_CHAR8__ )
488 __cl_char8 v8[2];
489 #endif
490 #if defined( __CL_CHAR16__ )
491 __cl_char16 v16;
492 #endif
493 }cl_char16;
494
495
496 /* ---- cl_ucharn ---- */
497 typedef union
498 {
499 cl_uchar CL_ALIGNED(2) s[2];
500 #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
501 __extension__ struct{ cl_uchar x, y; };
502 __extension__ struct{ cl_uchar s0, s1; };
503 __extension__ struct{ cl_uchar lo, hi; };
504 #endif
505 #if defined( __cl_uchar2__)
506 __cl_uchar2 v2;
507 #endif
508 }cl_uchar2;
509
510 typedef union
511 {
512 cl_uchar CL_ALIGNED(4) s[4];
513 #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
514 __extension__ struct{ cl_uchar x, y, z, w; };
515 __extension__ struct{ cl_uchar s0, s1, s2, s3; };
516 __extension__ struct{ cl_uchar2 lo, hi; };
517 #endif
518 #if defined( __CL_UCHAR2__)
519 __cl_uchar2 v2[2];
520 #endif
521 #if defined( __CL_UCHAR4__)
522 __cl_uchar4 v4;
523 #endif
524 }cl_uchar4;
525
526 /* cl_uchar3 is identical in size, alignment and behavior to cl_uchar4. See section 6.1.5. */
527 typedef cl_uchar4 cl_uchar3;
528
529 typedef union
530 {
531 cl_uchar CL_ALIGNED(8) s[8];
532 #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
533 __extension__ struct{ cl_uchar x, y, z, w; };
534 __extension__ struct{ cl_uchar s0, s1, s2, s3, s4, s5, s6, s7; };
535 __extension__ struct{ cl_uchar4 lo, hi; };
536 #endif
537 #if defined( __CL_UCHAR2__)
538 __cl_uchar2 v2[4];
539 #endif
540 #if defined( __CL_UCHAR4__)
541 __cl_uchar4 v4[2];
542 #endif
543 #if defined( __CL_UCHAR8__ )
544 __cl_uchar8 v8;
545 #endif
546 }cl_uchar8;
547
548 typedef union
549 {
550 cl_uchar CL_ALIGNED(16) s[16];
551 #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
552 __extension__ struct{ cl_uchar x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
553 __extension__ struct{ cl_uchar s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
554 __extension__ struct{ cl_uchar8 lo, hi; };
555 #endif
556 #if defined( __CL_UCHAR2__)
557 __cl_uchar2 v2[8];
558 #endif
559 #if defined( __CL_UCHAR4__)
560 __cl_uchar4 v4[4];
561 #endif
562 #if defined( __CL_UCHAR8__ )
563 __cl_uchar8 v8[2];
564 #endif
565 #if defined( __CL_UCHAR16__ )
566 __cl_uchar16 v16;
567 #endif
568 }cl_uchar16;
569
570
571 /* ---- cl_shortn ---- */
572 typedef union
573 {
574 cl_short CL_ALIGNED(4) s[2];
575 #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
576 __extension__ struct{ cl_short x, y; };
577 __extension__ struct{ cl_short s0, s1; };
578 __extension__ struct{ cl_short lo, hi; };
579 #endif
580 #if defined( __CL_SHORT2__)
581 __cl_short2 v2;
582 #endif
583 }cl_short2;
584
585 typedef union
586 {
587 cl_short CL_ALIGNED(8) s[4];
588 #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
589 __extension__ struct{ cl_short x, y, z, w; };
590 __extension__ struct{ cl_short s0, s1, s2, s3; };
591 __extension__ struct{ cl_short2 lo, hi; };
592 #endif
593 #if defined( __CL_SHORT2__)
594 __cl_short2 v2[2];
595 #endif
596 #if defined( __CL_SHORT4__)
597 __cl_short4 v4;
598 #endif
599 }cl_short4;
600
601 /* cl_short3 is identical in size, alignment and behavior to cl_short4. See section 6.1.5. */
602 typedef cl_short4 cl_short3;
603
604 typedef union
605 {
606 cl_short CL_ALIGNED(16) s[8];
607 #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
608 __extension__ struct{ cl_short x, y, z, w; };
609 __extension__ struct{ cl_short s0, s1, s2, s3, s4, s5, s6, s7; };
610 __extension__ struct{ cl_short4 lo, hi; };
611 #endif
612 #if defined( __CL_SHORT2__)
613 __cl_short2 v2[4];
614 #endif
615 #if defined( __CL_SHORT4__)
616 __cl_short4 v4[2];
617 #endif
618 #if defined( __CL_SHORT8__ )
619 __cl_short8 v8;
620 #endif
621 }cl_short8;
622
623 typedef union
624 {
625 cl_short CL_ALIGNED(32) s[16];
626 #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
627 __extension__ struct{ cl_short x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
628 __extension__ struct{ cl_short s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
629 __extension__ struct{ cl_short8 lo, hi; };
630 #endif
631 #if defined( __CL_SHORT2__)
632 __cl_short2 v2[8];
633 #endif
634 #if defined( __CL_SHORT4__)
635 __cl_short4 v4[4];
636 #endif
637 #if defined( __CL_SHORT8__ )
638 __cl_short8 v8[2];
639 #endif
640 #if defined( __CL_SHORT16__ )
641 __cl_short16 v16;
642 #endif
643 }cl_short16;
644
645
646 /* ---- cl_ushortn ---- */
647 typedef union
648 {
649 cl_ushort CL_ALIGNED(4) s[2];
650 #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
651 __extension__ struct{ cl_ushort x, y; };
652 __extension__ struct{ cl_ushort s0, s1; };
653 __extension__ struct{ cl_ushort lo, hi; };
654 #endif
655 #if defined( __CL_USHORT2__)
656 __cl_ushort2 v2;
657 #endif
658 }cl_ushort2;
659
660 typedef union
661 {
662 cl_ushort CL_ALIGNED(8) s[4];
663 #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
664 __extension__ struct{ cl_ushort x, y, z, w; };
665 __extension__ struct{ cl_ushort s0, s1, s2, s3; };
666 __extension__ struct{ cl_ushort2 lo, hi; };
667 #endif
668 #if defined( __CL_USHORT2__)
669 __cl_ushort2 v2[2];
670 #endif
671 #if defined( __CL_USHORT4__)
672 __cl_ushort4 v4;
673 #endif
674 }cl_ushort4;
675
676 /* cl_ushort3 is identical in size, alignment and behavior to cl_ushort4. See section 6.1.5. */
677 typedef cl_ushort4 cl_ushort3;
678
679 typedef union
680 {
681 cl_ushort CL_ALIGNED(16) s[8];
682 #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
683 __extension__ struct{ cl_ushort x, y, z, w; };
684 __extension__ struct{ cl_ushort s0, s1, s2, s3, s4, s5, s6, s7; };
685 __extension__ struct{ cl_ushort4 lo, hi; };
686 #endif
687 #if defined( __CL_USHORT2__)
688 __cl_ushort2 v2[4];
689 #endif
690 #if defined( __CL_USHORT4__)
691 __cl_ushort4 v4[2];
692 #endif
693 #if defined( __CL_USHORT8__ )
694 __cl_ushort8 v8;
695 #endif
696 }cl_ushort8;
697
698 typedef union
699 {
700 cl_ushort CL_ALIGNED(32) s[16];
701 #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
702 __extension__ struct{ cl_ushort x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
703 __extension__ struct{ cl_ushort s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
704 __extension__ struct{ cl_ushort8 lo, hi; };
705 #endif
706 #if defined( __CL_USHORT2__)
707 __cl_ushort2 v2[8];
708 #endif
709 #if defined( __CL_USHORT4__)
710 __cl_ushort4 v4[4];
711 #endif
712 #if defined( __CL_USHORT8__ )
713 __cl_ushort8 v8[2];
714 #endif
715 #if defined( __CL_USHORT16__ )
716 __cl_ushort16 v16;
717 #endif
718 }cl_ushort16;
719
720 /* ---- cl_intn ---- */
721 typedef union
722 {
723 cl_int CL_ALIGNED(8) s[2];
724 #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
725 __extension__ struct{ cl_int x, y; };
726 __extension__ struct{ cl_int s0, s1; };
727 __extension__ struct{ cl_int lo, hi; };
728 #endif
729 #if defined( __CL_INT2__)
730 __cl_int2 v2;
731 #endif
732 }cl_int2;
733
734 typedef union
735 {
736 cl_int CL_ALIGNED(16) s[4];
737 #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
738 __extension__ struct{ cl_int x, y, z, w; };
739 __extension__ struct{ cl_int s0, s1, s2, s3; };
740 __extension__ struct{ cl_int2 lo, hi; };
741 #endif
742 #if defined( __CL_INT2__)
743 __cl_int2 v2[2];
744 #endif
745 #if defined( __CL_INT4__)
746 __cl_int4 v4;
747 #endif
748 }cl_int4;
749
750 /* cl_int3 is identical in size, alignment and behavior to cl_int4. See section 6.1.5. */
751 typedef cl_int4 cl_int3;
752
753 typedef union
754 {
755 cl_int CL_ALIGNED(32) s[8];
756 #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
757 __extension__ struct{ cl_int x, y, z, w; };
758 __extension__ struct{ cl_int s0, s1, s2, s3, s4, s5, s6, s7; };
759 __extension__ struct{ cl_int4 lo, hi; };
760 #endif
761 #if defined( __CL_INT2__)
762 __cl_int2 v2[4];
763 #endif
764 #if defined( __CL_INT4__)
765 __cl_int4 v4[2];
766 #endif
767 #if defined( __CL_INT8__ )
768 __cl_int8 v8;
769 #endif
770 }cl_int8;
771
772 typedef union
773 {
774 cl_int CL_ALIGNED(64) s[16];
775 #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
776 __extension__ struct{ cl_int x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
777 __extension__ struct{ cl_int s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
778 __extension__ struct{ cl_int8 lo, hi; };
779 #endif
780 #if defined( __CL_INT2__)
781 __cl_int2 v2[8];
782 #endif
783 #if defined( __CL_INT4__)
784 __cl_int4 v4[4];
785 #endif
786 #if defined( __CL_INT8__ )
787 __cl_int8 v8[2];
788 #endif
789 #if defined( __CL_INT16__ )
790 __cl_int16 v16;
791 #endif
792 }cl_int16;
793
794
795 /* ---- cl_uintn ---- */
796 typedef union
797 {
798 cl_uint CL_ALIGNED(8) s[2];
799 #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
800 __extension__ struct{ cl_uint x, y; };
801 __extension__ struct{ cl_uint s0, s1; };
802 __extension__ struct{ cl_uint lo, hi; };
803 #endif
804 #if defined( __CL_UINT2__)
805 __cl_uint2 v2;
806 #endif
807 }cl_uint2;
808
809 typedef union
810 {
811 cl_uint CL_ALIGNED(16) s[4];
812 #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
813 __extension__ struct{ cl_uint x, y, z, w; };
814 __extension__ struct{ cl_uint s0, s1, s2, s3; };
815 __extension__ struct{ cl_uint2 lo, hi; };
816 #endif
817 #if defined( __CL_UINT2__)
818 __cl_uint2 v2[2];
819 #endif
820 #if defined( __CL_UINT4__)
821 __cl_uint4 v4;
822 #endif
823 }cl_uint4;
824
825 /* cl_uint3 is identical in size, alignment and behavior to cl_uint4. See section 6.1.5. */
826 typedef cl_uint4 cl_uint3;
827
828 typedef union
829 {
830 cl_uint CL_ALIGNED(32) s[8];
831 #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
832 __extension__ struct{ cl_uint x, y, z, w; };
833 __extension__ struct{ cl_uint s0, s1, s2, s3, s4, s5, s6, s7; };
834 __extension__ struct{ cl_uint4 lo, hi; };
835 #endif
836 #if defined( __CL_UINT2__)
837 __cl_uint2 v2[4];
838 #endif
839 #if defined( __CL_UINT4__)
840 __cl_uint4 v4[2];
841 #endif
842 #if defined( __CL_UINT8__ )
843 __cl_uint8 v8;
844 #endif
845 }cl_uint8;
846
847 typedef union
848 {
849 cl_uint CL_ALIGNED(64) s[16];
850 #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
851 __extension__ struct{ cl_uint x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
852 __extension__ struct{ cl_uint s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
853 __extension__ struct{ cl_uint8 lo, hi; };
854 #endif
855 #if defined( __CL_UINT2__)
856 __cl_uint2 v2[8];
857 #endif
858 #if defined( __CL_UINT4__)
859 __cl_uint4 v4[4];
860 #endif
861 #if defined( __CL_UINT8__ )
862 __cl_uint8 v8[2];
863 #endif
864 #if defined( __CL_UINT16__ )
865 __cl_uint16 v16;
866 #endif
867 }cl_uint16;
868
869 /* ---- cl_longn ---- */
870 typedef union
871 {
872 cl_long CL_ALIGNED(16) s[2];
873 #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
874 __extension__ struct{ cl_long x, y; };
875 __extension__ struct{ cl_long s0, s1; };
876 __extension__ struct{ cl_long lo, hi; };
877 #endif
878 #if defined( __CL_LONG2__)
879 __cl_long2 v2;
880 #endif
881 }cl_long2;
882
883 typedef union
884 {
885 cl_long CL_ALIGNED(32) s[4];
886 #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
887 __extension__ struct{ cl_long x, y, z, w; };
888 __extension__ struct{ cl_long s0, s1, s2, s3; };
889 __extension__ struct{ cl_long2 lo, hi; };
890 #endif
891 #if defined( __CL_LONG2__)
892 __cl_long2 v2[2];
893 #endif
894 #if defined( __CL_LONG4__)
895 __cl_long4 v4;
896 #endif
897 }cl_long4;
898
899 /* cl_long3 is identical in size, alignment and behavior to cl_long4. See section 6.1.5. */
900 typedef cl_long4 cl_long3;
901
902 typedef union
903 {
904 cl_long CL_ALIGNED(64) s[8];
905 #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
906 __extension__ struct{ cl_long x, y, z, w; };
907 __extension__ struct{ cl_long s0, s1, s2, s3, s4, s5, s6, s7; };
908 __extension__ struct{ cl_long4 lo, hi; };
909 #endif
910 #if defined( __CL_LONG2__)
911 __cl_long2 v2[4];
912 #endif
913 #if defined( __CL_LONG4__)
914 __cl_long4 v4[2];
915 #endif
916 #if defined( __CL_LONG8__ )
917 __cl_long8 v8;
918 #endif
919 }cl_long8;
920
921 typedef union
922 {
923 cl_long CL_ALIGNED(128) s[16];
924 #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
925 __extension__ struct{ cl_long x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
926 __extension__ struct{ cl_long s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
927 __extension__ struct{ cl_long8 lo, hi; };
928 #endif
929 #if defined( __CL_LONG2__)
930 __cl_long2 v2[8];
931 #endif
932 #if defined( __CL_LONG4__)
933 __cl_long4 v4[4];
934 #endif
935 #if defined( __CL_LONG8__ )
936 __cl_long8 v8[2];
937 #endif
938 #if defined( __CL_LONG16__ )
939 __cl_long16 v16;
940 #endif
941 }cl_long16;
942
943
944 /* ---- cl_ulongn ---- */
945 typedef union
946 {
947 cl_ulong CL_ALIGNED(16) s[2];
948 #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
949 __extension__ struct{ cl_ulong x, y; };
950 __extension__ struct{ cl_ulong s0, s1; };
951 __extension__ struct{ cl_ulong lo, hi; };
952 #endif
953 #if defined( __CL_ULONG2__)
954 __cl_ulong2 v2;
955 #endif
956 }cl_ulong2;
957
958 typedef union
959 {
960 cl_ulong CL_ALIGNED(32) s[4];
961 #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
962 __extension__ struct{ cl_ulong x, y, z, w; };
963 __extension__ struct{ cl_ulong s0, s1, s2, s3; };
964 __extension__ struct{ cl_ulong2 lo, hi; };
965 #endif
966 #if defined( __CL_ULONG2__)
967 __cl_ulong2 v2[2];
968 #endif
969 #if defined( __CL_ULONG4__)
970 __cl_ulong4 v4;
971 #endif
972 }cl_ulong4;
973
974 /* cl_ulong3 is identical in size, alignment and behavior to cl_ulong4. See section 6.1.5. */
975 typedef cl_ulong4 cl_ulong3;
976
977 typedef union
978 {
979 cl_ulong CL_ALIGNED(64) s[8];
980 #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
981 __extension__ struct{ cl_ulong x, y, z, w; };
982 __extension__ struct{ cl_ulong s0, s1, s2, s3, s4, s5, s6, s7; };
983 __extension__ struct{ cl_ulong4 lo, hi; };
984 #endif
985 #if defined( __CL_ULONG2__)
986 __cl_ulong2 v2[4];
987 #endif
988 #if defined( __CL_ULONG4__)
989 __cl_ulong4 v4[2];
990 #endif
991 #if defined( __CL_ULONG8__ )
992 __cl_ulong8 v8;
993 #endif
994 }cl_ulong8;
995
996 typedef union
997 {
998 cl_ulong CL_ALIGNED(128) s[16];
999 #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
1000 __extension__ struct{ cl_ulong x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
1001 __extension__ struct{ cl_ulong s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
1002 __extension__ struct{ cl_ulong8 lo, hi; };
1003 #endif
1004 #if defined( __CL_ULONG2__)
1005 __cl_ulong2 v2[8];
1006 #endif
1007 #if defined( __CL_ULONG4__)
1008 __cl_ulong4 v4[4];
1009 #endif
1010 #if defined( __CL_ULONG8__ )
1011 __cl_ulong8 v8[2];
1012 #endif
1013 #if defined( __CL_ULONG16__ )
1014 __cl_ulong16 v16;
1015 #endif
1016 }cl_ulong16;
1017
1018
1019 /* --- cl_floatn ---- */
1020
1021 typedef union
1022 {
1023 cl_float CL_ALIGNED(8) s[2];
1024 #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
1025 __extension__ struct{ cl_float x, y; };
1026 __extension__ struct{ cl_float s0, s1; };
1027 __extension__ struct{ cl_float lo, hi; };
1028 #endif
1029 #if defined( __CL_FLOAT2__)
1030 __cl_float2 v2;
1031 #endif
1032 }cl_float2;
1033
1034 typedef union
1035 {
1036 cl_float CL_ALIGNED(16) s[4];
1037 #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
1038 __extension__ struct{ cl_float x, y, z, w; };
1039 __extension__ struct{ cl_float s0, s1, s2, s3; };
1040 __extension__ struct{ cl_float2 lo, hi; };
1041 #endif
1042 #if defined( __CL_FLOAT2__)
1043 __cl_float2 v2[2];
1044 #endif
1045 #if defined( __CL_FLOAT4__)
1046 __cl_float4 v4;
1047 #endif
1048 }cl_float4;
1049
1050 /* cl_float3 is identical in size, alignment and behavior to cl_float4. See section 6.1.5. */
1051 typedef cl_float4 cl_float3;
1052
1053 typedef union
1054 {
1055 cl_float CL_ALIGNED(32) s[8];
1056 #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
1057 __extension__ struct{ cl_float x, y, z, w; };
1058 __extension__ struct{ cl_float s0, s1, s2, s3, s4, s5, s6, s7; };
1059 __extension__ struct{ cl_float4 lo, hi; };
1060 #endif
1061 #if defined( __CL_FLOAT2__)
1062 __cl_float2 v2[4];
1063 #endif
1064 #if defined( __CL_FLOAT4__)
1065 __cl_float4 v4[2];
1066 #endif
1067 #if defined( __CL_FLOAT8__ )
1068 __cl_float8 v8;
1069 #endif
1070 }cl_float8;
1071
1072 typedef union
1073 {
1074 cl_float CL_ALIGNED(64) s[16];
1075 #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
1076 __extension__ struct{ cl_float x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
1077 __extension__ struct{ cl_float s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
1078 __extension__ struct{ cl_float8 lo, hi; };
1079 #endif
1080 #if defined( __CL_FLOAT2__)
1081 __cl_float2 v2[8];
1082 #endif
1083 #if defined( __CL_FLOAT4__)
1084 __cl_float4 v4[4];
1085 #endif
1086 #if defined( __CL_FLOAT8__ )
1087 __cl_float8 v8[2];
1088 #endif
1089 #if defined( __CL_FLOAT16__ )
1090 __cl_float16 v16;
1091 #endif
1092 }cl_float16;
1093
1094 /* --- cl_doublen ---- */
1095
1096 typedef union
1097 {
1098 cl_double CL_ALIGNED(16) s[2];
1099 #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
1100 __extension__ struct{ cl_double x, y; };
1101 __extension__ struct{ cl_double s0, s1; };
1102 __extension__ struct{ cl_double lo, hi; };
1103 #endif
1104 #if defined( __CL_DOUBLE2__)
1105 __cl_double2 v2;
1106 #endif
1107 }cl_double2;
1108
1109 typedef union
1110 {
1111 cl_double CL_ALIGNED(32) s[4];
1112 #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
1113 __extension__ struct{ cl_double x, y, z, w; };
1114 __extension__ struct{ cl_double s0, s1, s2, s3; };
1115 __extension__ struct{ cl_double2 lo, hi; };
1116 #endif
1117 #if defined( __CL_DOUBLE2__)
1118 __cl_double2 v2[2];
1119 #endif
1120 #if defined( __CL_DOUBLE4__)
1121 __cl_double4 v4;
1122 #endif
1123 }cl_double4;
1124
1125 /* cl_double3 is identical in size, alignment and behavior to cl_double4. See section 6.1.5. */
1126 typedef cl_double4 cl_double3;
1127
1128 typedef union
1129 {
1130 cl_double CL_ALIGNED(64) s[8];
1131 #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
1132 __extension__ struct{ cl_double x, y, z, w; };
1133 __extension__ struct{ cl_double s0, s1, s2, s3, s4, s5, s6, s7; };
1134 __extension__ struct{ cl_double4 lo, hi; };
1135 #endif
1136 #if defined( __CL_DOUBLE2__)
1137 __cl_double2 v2[4];
1138 #endif
1139 #if defined( __CL_DOUBLE4__)
1140 __cl_double4 v4[2];
1141 #endif
1142 #if defined( __CL_DOUBLE8__ )
1143 __cl_double8 v8;
1144 #endif
1145 }cl_double8;
1146
1147 typedef union
1148 {
1149 cl_double CL_ALIGNED(128) s[16];
1150 #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
1151 __extension__ struct{ cl_double x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
1152 __extension__ struct{ cl_double s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
1153 __extension__ struct{ cl_double8 lo, hi; };
1154 #endif
1155 #if defined( __CL_DOUBLE2__)
1156 __cl_double2 v2[8];
1157 #endif
1158 #if defined( __CL_DOUBLE4__)
1159 __cl_double4 v4[4];
1160 #endif
1161 #if defined( __CL_DOUBLE8__ )
1162 __cl_double8 v8[2];
1163 #endif
1164 #if defined( __CL_DOUBLE16__ )
1165 __cl_double16 v16;
1166 #endif
1167 }cl_double16;
1168
1169 /* Macro to facilitate debugging
1170 * Usage:
1171 * Place CL_PROGRAM_STRING_DEBUG_INFO on the line before the first line of your source.
1172 * The first line ends with: CL_PROGRAM_STRING_BEGIN \"
1173 * Each line thereafter of OpenCL C source must end with: \n\
1174 * The last line ends in ";
1175 *
1176 * Example:
1177 *
1178 * const char *my_program = CL_PROGRAM_STRING_BEGIN "\
1179 * kernel void foo( int a, float * b ) \n\
1180 * { \n\
1181 * // my comment \n\
1182 * *b[ get_global_id(0)] = a; \n\
1183 * } \n\
1184 * ";
1185 *
1186 * This should correctly set up the line, (column) and file information for your source
1187 * string so you can do source level debugging.
1188 */
1189 #define __CL_STRINGIFY( _x ) # _x
1190 #define _CL_STRINGIFY( _x ) __CL_STRINGIFY( _x )
1191 #define CL_PROGRAM_STRING_DEBUG_INFO "#line " _CL_STRINGIFY(__LINE__) " \"" __FILE__ "\" \n\n"
1192
1193 #ifdef __cplusplus
1194 }
1195 #endif
1196
1197 #endif /* __CL_PLATFORM_H */
0 /**********************************************************************************
1 * Copyright (c) 2008-2009 The Khronos Group Inc.
2 *
3 * Permission is hereby granted, free of charge, to any person obtaining a
4 * copy of this software and/or associated documentation files (the
5 * "Materials"), to deal in the Materials without restriction, including
6 * without limitation the rights to use, copy, modify, merge, publish,
7 * distribute, sublicense, and/or sell copies of the Materials, and to
8 * permit persons to whom the Materials are furnished to do so, subject to
9 * the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Materials.
13 *
14 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20 * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
21 **********************************************************************************/
22
23 #ifndef __CL_PLATFORM_H
24 #define __CL_PLATFORM_H
25
26 #ifdef __APPLE__
27 /* Contains #defines for AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER below */
28 #include <AvailabilityMacros.h>
29 #endif
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 #define CL_API_ENTRY
36 #define CL_API_CALL
37 #ifdef __APPLE__
38 #define CL_API_SUFFIX__VERSION_1_0 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
39 #define CL_EXTENSION_WEAK_LINK __attribute__((weak_import))
40 #else
41 #define CL_API_SUFFIX__VERSION_1_0
42 #define CL_EXTENSION_WEAK_LINK
43 #endif
44
45 #if (defined (WIN32) && (_MSC_VER))
46
47 /* scalar types */
48 typedef signed __int8 cl_char;
49 typedef unsigned __int8 cl_uchar;
50 typedef signed __int16 cl_short;
51 typedef unsigned __int16 cl_ushort;
52 typedef signed __int32 cl_int;
53 typedef unsigned __int32 cl_uint;
54 typedef signed __int64 cl_long;
55 typedef unsigned __int64 cl_ulong;
56
57 typedef unsigned __int16 cl_half;
58 typedef float cl_float;
59 typedef double cl_double;
60
61
62 /*
63 * Vector types
64 *
65 * Note: OpenCL requires that all types be naturally aligned.
66 * This means that vector types must be naturally aligned.
67 * For example, a vector of four floats must be aligned to
68 * a 16 byte boundary (calculated as 4 * the natural 4-byte
69 * alignment of the float). The alignment qualifiers here
70 * will only function properly if your compiler supports them
71 * and if you don't actively work to defeat them. For example,
72 * in order for a cl_float4 to be 16 byte aligned in a struct,
73 * the start of the struct must itself be 16-byte aligned.
74 *
75 * Maintaining proper alignment is the user's responsibility.
76 */
77 typedef signed __int8 cl_char2[2];
78 typedef signed __int8 cl_char4[4];
79 typedef signed __int8 cl_char8[8];
80 typedef signed __int8 cl_char16[16];
81 typedef unsigned __int8 cl_uchar2[2];
82 typedef unsigned __int8 cl_uchar4[4];
83 typedef unsigned __int8 cl_uchar8[8];
84 typedef unsigned __int8 cl_uchar16[16];
85
86 typedef signed __int16 cl_short2[2];
87 typedef signed __int16 cl_short4[4];
88 typedef signed __int16 cl_short8[8];
89 typedef signed __int16 cl_short16[16];
90 typedef unsigned __int16 cl_ushort2[2];
91 typedef unsigned __int16 cl_ushort4[4];
92 typedef unsigned __int16 cl_ushort8[8];
93 typedef unsigned __int16 cl_ushort16[16];
94
95 typedef signed __int32 cl_int2[2];
96 typedef signed __int32 cl_int4[4];
97 typedef signed __int32 cl_int8[8];
98 typedef signed __int32 cl_int16[16];
99 typedef unsigned __int32 cl_uint2[2];
100 typedef unsigned __int32 cl_uint4[4];
101 typedef unsigned __int32 cl_uint8[8];
102 typedef unsigned __int32 cl_uint16[16];
103
104 typedef signed __int64 cl_long2[2];
105 typedef signed __int64 cl_long4[4];
106 typedef signed __int64 cl_long8[8];
107 typedef signed __int64 cl_long16[16];
108 typedef unsigned __int64 cl_ulong2[2];
109 typedef unsigned __int64 cl_ulong4[4];
110 typedef unsigned __int64 cl_ulong8[8];
111 typedef unsigned __int64 cl_ulong16[16];
112
113 typedef float cl_float2[2];
114 typedef float cl_float4[4];
115 typedef float cl_float8[8];
116 typedef float cl_float16[16];
117
118 typedef double cl_double2[2];
119 typedef double cl_double4[4];
120 typedef double cl_double8[8];
121 typedef double cl_double16[16];
122 /* There are no vector types for half */
123
124 #define CL_CHAR_BIT 8
125 #define CL_SCHAR_MAX 127
126 #define CL_SCHAR_MIN (-127-1)
127 #define CL_CHAR_MAX CL_SCHAR_MAX
128 #define CL_CHAR_MIN CL_SCHAR_MIN
129 #define CL_UCHAR_MAX 255
130 #define CL_SHRT_MAX 32767
131 #define CL_SHRT_MIN (-32767-1)
132 #define CL_USHRT_MAX 65535
133 #define CL_INT_MAX 2147483647
134 #define CL_INT_MIN (-2147483647-1)
135 #define CL_UINT_MAX 0xffffffffU
136 #define CL_LONG_MAX ((cl_long) 0x7FFFFFFFFFFFFFFFLL)
137 #define CL_LONG_MIN ((cl_long) -0x7FFFFFFFFFFFFFFFLL - 1LL)
138 #define CL_ULONG_MAX ((cl_ulong) 0xFFFFFFFFFFFFFFFFULL)
139
140 #define CL_FLT_DIG 6
141 #define CL_FLT_MANT_DIG 24
142 #define CL_FLT_MAX_10_EXP +38
143 #define CL_FLT_MAX_EXP +128
144 #define CL_FLT_MIN_10_EXP -37
145 #define CL_FLT_MIN_EXP -125
146 #define CL_FLT_RADIX 2
147 #define CL_FLT_MAX 340282346638528859811704183484516925440.0f
148 #define CL_FLT_MIN 1.175494350822287507969e-38f
149 #define CL_FLT_EPSILON 0x1.0p-23f
150
151 #define CL_DBL_DIG 15
152 #define CL_DBL_MANT_DIG 53
153 #define CL_DBL_MAX_10_EXP +308
154 #define CL_DBL_MAX_EXP +1024
155 #define CL_DBL_MIN_10_EXP -307
156 #define CL_DBL_MIN_EXP -1021
157 #define CL_DBL_RADIX 2
158 #define CL_DBL_MAX 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0
159 #define CL_DBL_MIN 2.225073858507201383090e-308
160 #define CL_DBL_EPSILON 2.220446049250313080847e-16
161
162
163 #else
164
165 #include <stdint.h>
166
167 /* scalar types */
168 typedef int8_t cl_char;
169 typedef uint8_t cl_uchar;
170 typedef int16_t cl_short __attribute__((aligned(2)));
171 typedef uint16_t cl_ushort __attribute__((aligned(2)));
172 typedef int32_t cl_int __attribute__((aligned(4)));
173 typedef uint32_t cl_uint __attribute__((aligned(4)));
174 typedef int64_t cl_long __attribute__((aligned(8)));
175 typedef uint64_t cl_ulong __attribute__((aligned(8)));
176
177 typedef uint16_t cl_half __attribute__((aligned(2)));
178 typedef float cl_float __attribute__((aligned(4)));
179 typedef double cl_double __attribute__((aligned(8)));
180
181 /*
182 * Vector types
183 *
184 * Note: OpenCL requires that all types be naturally aligned.
185 * This means that vector types must be naturally aligned.
186 * For example, a vector of four floats must be aligned to
187 * a 16 byte boundary (calculated as 4 * the natural 4-byte
188 * alignment of the float). The alignment qualifiers here
189 * will only function properly if your compiler supports them
190 * and if you don't actively work to defeat them. For example,
191 * in order for a cl_float4 to be 16 byte aligned in a struct,
192 * the start of the struct must itself be 16-byte aligned.
193 *
194 * Maintaining proper alignment is the user's responsibility.
195 */
196 typedef int8_t cl_char2[2] __attribute__((aligned(2)));
197 typedef int8_t cl_char4[4] __attribute__((aligned(4)));
198 typedef int8_t cl_char8[8] __attribute__((aligned(8)));
199 typedef int8_t cl_char16[16] __attribute__((aligned(16)));
200 typedef uint8_t cl_uchar2[2] __attribute__((aligned(2)));
201 typedef uint8_t cl_uchar4[4] __attribute__((aligned(4)));
202 typedef uint8_t cl_uchar8[8] __attribute__((aligned(8)));
203 typedef uint8_t cl_uchar16[16] __attribute__((aligned(16)));
204
205 typedef int16_t cl_short2[2] __attribute__((aligned(4)));
206 typedef int16_t cl_short4[4] __attribute__((aligned(8)));
207 typedef int16_t cl_short8[8] __attribute__((aligned(16)));
208 typedef int16_t cl_short16[16] __attribute__((aligned(32)));
209 typedef uint16_t cl_ushort2[2] __attribute__((aligned(4)));
210 typedef uint16_t cl_ushort4[4] __attribute__((aligned(8)));
211 typedef uint16_t cl_ushort8[8] __attribute__((aligned(16)));
212 typedef uint16_t cl_ushort16[16] __attribute__((aligned(32)));
213
214 typedef int32_t cl_int2[2] __attribute__((aligned(8)));
215 typedef int32_t cl_int4[4] __attribute__((aligned(16)));
216 typedef int32_t cl_int8[8] __attribute__((aligned(32)));
217 typedef int32_t cl_int16[16] __attribute__((aligned(64)));
218 typedef uint32_t cl_uint2[2] __attribute__((aligned(8)));
219 typedef uint32_t cl_uint4[4] __attribute__((aligned(16)));
220 typedef uint32_t cl_uint8[8] __attribute__((aligned(32)));
221 typedef uint32_t cl_uint16[16] __attribute__((aligned(64)));
222
223 typedef int64_t cl_long2[2] __attribute__((aligned(16)));
224 typedef int64_t cl_long4[4] __attribute__((aligned(32)));
225 typedef int64_t cl_long8[8] __attribute__((aligned(64)));
226 typedef int64_t cl_long16[16] __attribute__((aligned(128)));
227 typedef uint64_t cl_ulong2[2] __attribute__((aligned(16)));
228 typedef uint64_t cl_ulong4[4] __attribute__((aligned(32)));
229 typedef uint64_t cl_ulong8[8] __attribute__((aligned(64)));
230 typedef uint64_t cl_ulong16[16] __attribute__((aligned(128)));
231
232 typedef float cl_float2[2] __attribute__((aligned(8)));
233 typedef float cl_float4[4] __attribute__((aligned(16)));
234 typedef float cl_float8[8] __attribute__((aligned(32)));
235 typedef float cl_float16[16] __attribute__((aligned(64)));
236
237 typedef double cl_double2[2] __attribute__((aligned(16)));
238 typedef double cl_double4[4] __attribute__((aligned(32)));
239 typedef double cl_double8[8] __attribute__((aligned(64)));
240 typedef double cl_double16[16] __attribute__((aligned(128)));
241
242 /* There are no vector types for half */
243
244 /******************************************************************************/
245
246 // Macro names and corresponding values defined by OpenCL
247
248 #define CL_CHAR_BIT 8
249 #define CL_SCHAR_MAX 127
250 #define CL_SCHAR_MIN (-127-1)
251 #define CL_CHAR_MAX CL_SCHAR_MAX
252 #define CL_CHAR_MIN CL_SCHAR_MIN
253 #define CL_UCHAR_MAX 255
254 #define CL_SHRT_MAX 32767
255 #define CL_SHRT_MIN (-32767-1)
256 #define CL_USHRT_MAX 65535
257 #define CL_INT_MAX 2147483647
258 #define CL_INT_MIN (-2147483647-1)
259 #define CL_UINT_MAX 0xffffffffU
260 #define CL_LONG_MAX ((cl_long) 0x7FFFFFFFFFFFFFFFLL)
261 #define CL_LONG_MIN ((cl_long) -0x7FFFFFFFFFFFFFFFLL - 1LL)
262 #define CL_ULONG_MAX ((cl_ulong) 0xFFFFFFFFFFFFFFFFULL)
263
264 #define CL_FLT_DIG 6
265 #define CL_FLT_MANT_DIG 24
266 #define CL_FLT_MAX_10_EXP +38
267 #define CL_FLT_MAX_EXP +128
268 #define CL_FLT_MIN_10_EXP -37
269 #define CL_FLT_MIN_EXP -125
270 #define CL_FLT_RADIX 2
271 #define CL_FLT_MAX 0x1.fffffep127f
272 #define CL_FLT_MIN 0x1.0p-126f
273 #define CL_FLT_EPSILON 0x1.0p-23f
274
275 #define CL_DBL_DIG 15
276 #define CL_DBL_MANT_DIG 53
277 #define CL_DBL_MAX_10_EXP +308
278 #define CL_DBL_MAX_EXP +1024
279 #define CL_DBL_MIN_10_EXP -307
280 #define CL_DBL_MIN_EXP -1021
281 #define CL_DBL_RADIX 2
282 #define CL_DBL_MAX 0x1.fffffffffffffp1023
283 #define CL_DBL_MIN 0x1.0p-1022
284 #define CL_DBL_EPSILON 0x1.0p-52
285
286 #endif
287
288 #include <stddef.h>
289
290
291 #ifdef __cplusplus
292 }
293 #endif
294
295 #endif // __CL_PLATFORM_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 */
31
31
3232 /**
33 * $Id: common_tools.c 3167 2008-12-22 16:38:57Z elias_naur $
33 * $Id: common_tools.c 3449 2010-10-14 19:58:32Z matzon $
3434 *
3535 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 3167 $
36 * @version $Revision: 3449 $
3737 */
3838
3939 #include <jni.h>
4444 static bool debug = false;
4545 static JavaVM *jvm;
4646
47 static jmethodID mByteBuffer_asReadOnlyBuffer;
48 static jmethodID mPointerWrapper_getPointer;
49
4750 void initAttribList(attrib_list_t *list) {
4851 list->current_index = 0;
4952 }
5558 }
5659 list->attribs[list->current_index] = attrib;
5760 list->current_index++;
61 }
62
63 JNIEXPORT jint JNICALL Java_org_lwjgl_DefaultSysImplementation_getPointerSize(JNIEnv *env, jclass clazz) {
64 return (jint)sizeof(void *);
5865 }
5966
6067 JNIEXPORT void JNICALL Java_org_lwjgl_DefaultSysImplementation_setDebug
7986 }
8087
8188 static jstring sprintfJavaString(JNIEnv *env, const char *format, va_list ap) {
82 int buffer_size = 2;
89 int buffer_size = 2048;
8390 char *buffer;
8491 jstring str;
8592 int str_size;
174181 }
175182
176183 // retrieves the locale-specific C string
177 char * GetStringNativeChars(JNIEnv *env, jstring jstr) {
178 jbyteArray bytes = 0;
179 jthrowable exc;
180 char *result = 0;
184 char * GetStringNativeChars(JNIEnv *env, jstring jstr) {
185 jbyteArray bytes = 0;
186 jthrowable exc;
187 char *result = 0;
181188 jclass jcls_str;
182189 jmethodID MID_String_getBytes;
183190
184 /* out of memory error? */
185 if ((*env)->EnsureLocalCapacity(env, 2) < 0) {
186 return 0;
187 }
191 /* out of memory error? */
192 if ((*env)->EnsureLocalCapacity(env, 2) < 0) {
193 return 0;
194 }
188195
189196 // aquire getBytes method
190 jcls_str = (*env)->FindClass(env, "java/lang/String");
191 MID_String_getBytes = (*env)->GetMethodID(env, jcls_str, "getBytes", "()[B");
197 jcls_str = (*env)->FindClass(env, "java/lang/String");
198 MID_String_getBytes = (*env)->GetMethodID(env, jcls_str, "getBytes", "()[B");
192199
193200 // get the bytes
194 bytes = (jbyteArray) (*env)->CallObjectMethod(env, jstr, MID_String_getBytes);
195 exc = (*env)->ExceptionOccurred(env);
201 bytes = (jbyteArray) (*env)->CallObjectMethod(env, jstr, MID_String_getBytes);
202 exc = (*env)->ExceptionOccurred(env);
196203
197204 // if no exception occured while getting bytes - continue
198 if (!exc) {
199 jint len = (*env)->GetArrayLength(env, bytes);
200 result = (char *) malloc(len + 1);
201 if (result == 0) {
202 throwGeneralException(env, "java/lang/OutOfMemoryError", NULL);
203 (*env)->DeleteLocalRef(env, bytes);
204 return 0;
205 }
206 (*env)->GetByteArrayRegion(env, bytes, 0, len, (jbyte *) result);
207 result[len] = 0; /* NULL-terminate */
208 } else {
209 (*env)->DeleteLocalRef(env, exc);
210 }
211 (*env)->DeleteLocalRef(env, bytes);
205 if (!exc) {
206 jint len = (*env)->GetArrayLength(env, bytes);
207 result = (char *) malloc(len + 1);
208 if (result == 0) {
209 throwGeneralException(env, "java/lang/OutOfMemoryError", NULL);
210 (*env)->DeleteLocalRef(env, bytes);
211 return 0;
212 }
213 (*env)->GetByteArrayRegion(env, bytes, 0, len, (jbyte *) result);
214 result[len] = 0; /* NULL-terminate */
215 } else {
216 (*env)->DeleteLocalRef(env, exc);
217 }
218 (*env)->DeleteLocalRef(env, bytes);
212219 return (char*) result;
213220 }
214221
223230 }
224231
225232 // creates locale specific string
226 jstring NewStringNativeWithLength(JNIEnv *env, const char *str, int length) {
233 jstring NewStringNativeWithLength(JNIEnv *env, const char *str, int length) {
227234 jclass jcls_str;
228235 jmethodID jmethod_str;
229 jstring result;
236 jstring result;
230237 jbyteArray bytes;
231 if (str==NULL) {
232 return NULL;
233 }
234
235 jcls_str = (*env)->FindClass(env,"java/lang/String");
238 if (str==NULL) {
239 return NULL;
240 }
241
242 jcls_str = (*env)->FindClass(env,"java/lang/String");
236243 if (jcls_str == NULL)
237244 return NULL;
238 jmethod_str = (*env)->GetMethodID(env,jcls_str, "<init>", "([B)V");
245 jmethod_str = (*env)->GetMethodID(env,jcls_str, "<init>", "([B)V");
239246 if (jmethod_str == NULL)
240247 return NULL;
241248
242 bytes = 0;
243
244 if ((*env)->EnsureLocalCapacity(env,2) < 0) {
245 return NULL; /* out of memory error */
246 }
247
248 bytes = (*env)->NewByteArray(env,length);
249 if (bytes != NULL) {
250 (*env)->SetByteArrayRegion(env,bytes, 0, length, (jbyte *)str);
251 result = (jstring)(*env)->NewObject(env,jcls_str, jmethod_str, bytes);
252 (*env)->DeleteLocalRef(env,bytes);
253 return result;
254 } /* else fall through */
255 return NULL;
249 bytes = 0;
250
251 if ((*env)->EnsureLocalCapacity(env,2) < 0) {
252 return NULL; /* out of memory error */
253 }
254
255 bytes = (*env)->NewByteArray(env,length);
256 if (bytes != NULL) {
257 (*env)->SetByteArrayRegion(env,bytes, 0, length, (jbyte *)str);
258 result = (jstring)(*env)->NewObject(env,jcls_str, jmethod_str, bytes);
259 (*env)->DeleteLocalRef(env,bytes);
260 return result;
261 } /* else fall through */
262 return NULL;
256263 }
257264
258265 bool ext_InitializeFunctions(ExtGetProcAddressPROC gpa, int num_functions, ExtFunction *functions) {
269276 }
270277 }
271278 return true;
279 }
280
281 jobject NewReadOnlyDirectByteBuffer(JNIEnv* env, const void* address, jlong capacity) {
282 jobject buffer = (*env)->NewDirectByteBuffer(env, (void *)address, capacity);
283 return (*env)->CallObjectMethod(env, buffer, mByteBuffer_asReadOnlyBuffer);
272284 }
273285
274286 jobject newJavaManagedByteBuffer(JNIEnv *env, const int size) {
326338 return (*env)->CallStaticBooleanMethod(env, org_lwjgl_LWJGLUtil_class, getBoolean, property) ? true : false;
327339 }
328340
341 jlong getPointerWrapperAddress(JNIEnv *env, jobject wrapper) {
342 return (*env)->CallLongMethod(env, wrapper, mPointerWrapper_getPointer);
343 }
344
329345 JNIEnv *getThreadEnv() {
330346 JNIEnv *env;
331347 (*jvm)->GetEnv(jvm, (void *)&env, JNI_VERSION_1_4);
332348 return env;
333349 }
334350
351 JNIEnv *attachCurrentThread() {
352 JNIEnv *env;
353 (*jvm)->AttachCurrentThread(jvm, (void **)&env, NULL);
354 return env;
355 }
356
357 void detachCurrentThread() {
358 (*jvm)->DetachCurrentThread(jvm);
359 }
360
335361 JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
336 jvm = vm;
337 return JNI_VERSION_1_4;
362 JNIEnv *env;
363 jclass clazz;
364
365 jvm = vm;
366 env = getThreadEnv();
367
368 clazz = (*env)->FindClass(env, "java/nio/ByteBuffer");
369 mByteBuffer_asReadOnlyBuffer = (*env)->GetMethodID(env, clazz, "asReadOnlyBuffer", "()Ljava/nio/ByteBuffer;");
370
371 clazz = (*env)->FindClass(env, "org/lwjgl/PointerWrapper");
372 mPointerWrapper_getPointer = (*env)->GetMethodID(env, clazz, "getPointer", "()J");
373
374 return JNI_VERSION_1_4;
338375 }
339376
340377 JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved) {
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 */
31
31
3232 /**
33 * $Id: common_tools.h 2988 2008-04-07 19:31:23Z elias_naur $
33 * $Id: common_tools.h 3412 2010-09-26 23:43:24Z spasi $
3434 *
3535 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 2988 $
36 * @version $Revision: 3412 $
3737 */
3838
3939 #ifndef _COMMON_TOOLS_H
122122 #endif
123123
124124 extern JNIEnv *getThreadEnv();
125 extern JNIEnv *attachCurrentThread();
126 extern void detachCurrentThread();
125127 extern void initAttribList(attrib_list_t *list);
126128 extern void putAttrib(attrib_list_t *list, int attrib);
127129
139141 extern char * GetStringNativeChars(JNIEnv *env, jstring jstr);
140142 extern jstring NewStringNativeWithLength(JNIEnv *env, const char *str, int length);
141143 extern jstring NewStringNativeUnsigned(JNIEnv *env, const unsigned char *str);
144 extern jobject NewReadOnlyDirectByteBuffer(JNIEnv* env, const void* address, jlong capacity);
142145 extern jobject newJavaManagedByteBuffer(JNIEnv *env, const int size);
143146 extern bool positionBuffer(JNIEnv *env, jobject buffer, jint position);
147 extern jlong getPointerWrapperAddress(JNIEnv *env, jobject wrapper);
144148
145149 extern void ext_InitializeClass(JNIEnv *env, jclass clazz, ExtGetProcAddressPROC gpa, int num_functions, JavaMethodAndExtFunction *functions);
146150 extern bool ext_InitializeFunctions(ExtGetProcAddressPROC gpa, int num_functions, ExtFunction *functions);
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 */
31
31
3232 #include <jni.h>
3333 #include "extal.h"
3434
4141 */
4242 /*void InitializeOpenAL(JNIEnv *env, jstring oalPath) {
4343 //load our library
44 if (!tryLoadLibrary(env, oalPath)) {
44 if (!extal_LoadLibrary(env, oalPath)) {
4545 throwException(env, "Could not load openal library.");
4646 return;
4747 }
48 alGetProcAddress = (alGetProcAddressPROC)NativeGetFunctionPointer("alGetProcAddress");
48 alGetProcAddress = (alGetProcAddressPROC)extal_NativeGetFunctionPointer("alGetProcAddress");
4949 if (alGetProcAddress == NULL) {
50 UnLoadOpenAL();
50 extal_UnloadLibrary();
5151 throwException(env, "Could not load alGetProcAddress function pointer.");
5252 return;
5353 }
6363 void *p;
6464 /* p = alGetProcAddress((const ALubyte*)function);
6565 if (p == NULL) {*/
66 p = NativeGetFunctionPointer(function);
66 p = extal_NativeGetFunctionPointer(function);
6767 if (p == NULL) {
6868 printfDebug("Could not locate symbol %s\n", function);
6969 }
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 */
160160 void extal_InitializeClass(JNIEnv *env, jclass clazz, int num_functions, JavaMethodAndExtFunction *functions);
161161
162162 /* Platform dependent functions */
163 void *NativeGetFunctionPointer(const char *function);
164 void tryLoadLibrary(JNIEnv *env, jstring path);
165 void UnLoadOpenAL();
163 void *extal_NativeGetFunctionPointer(const char *function);
164 void extal_LoadLibrary(JNIEnv *env, jstring path);
165 void extal_UnloadLibrary();
166166
167167 #ifdef __cplusplus
168168 }
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 #include <jni.h>
33 #include "extcl.h"
34
35 typedef CL_API_ENTRY void * (CL_API_CALL *clGetExtensionFunctionAddressPROC) (const char * func_name);
36 static clGetExtensionFunctionAddressPROC clGetExtensionFunctionAddress;
37
38 /**
39 * Retrieves a pointer to the named function
40 *
41 * @param function Name of function
42 * @return pointer to named function, or NULL if not found
43 */
44 void* extcl_GetProcAddress(const char * function) {
45 void *p = NULL;
46
47 if ( clGetExtensionFunctionAddress == NULL )
48 clGetExtensionFunctionAddress = extcl_NativeGetFunctionPointer("clGetExtensionFunctionAddress");
49
50 p = clGetExtensionFunctionAddress(function);
51 if ( p == NULL )
52 p = extcl_NativeGetFunctionPointer(function);
53
54 return p;
55 }
56
57 void extcl_InitializeClass(JNIEnv *env, jclass clazz, int num_functions, JavaMethodAndExtFunction *functions) {
58 ext_InitializeClass(env, clazz, &extcl_GetProcAddress, num_functions, functions);
59 }
60
61 int extcl_CalculateImageSize(const size_t *region, size_t row_pitch, size_t slice_pitch) {
62 if ( slice_pitch == 0 )
63 return region[1] * row_pitch;
64 else
65 return region[2] * slice_pitch;
66 }
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 #ifndef __EXTCL_H__
33 #define __EXTCL_H__
34
35 #include <jni.h>
36
37 #ifdef __APPLE__
38 #include <OpenCL/cl_platform.h>
39 #else
40 #include <CL/cl_platform.h>
41 #endif
42
43 #include "common_tools.h"
44
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48
49 #include "extgl_types.h"
50 #include "extcl_types.h"
51
52 // -----------------[ OpenGL-dependent typedefs ]-----------------
53 typedef GLsync cl_GLsync;
54
55 // -----------------[ Callback function typedefs ]-----------------
56
57 #ifndef CL_CALLBACK
58 #define CL_CALLBACK
59 #endif
60
61 // TODO: This is a bug in current CL implementations (AMD's only?), remove when fixed. (used for cl_native_kernel_func)
62 #if defined(_WIN32)
63 #define CL_USER_FUNC_CALLBACK __cdecl
64 #else
65 #define CL_USER_FUNC_CALLBACK CL_CALLBACK
66 #endif
67
68 typedef void (CL_CALLBACK * cl_create_context_callback)(const char *errinfo, const void *private_info, size_t cb, void *user_data);
69 typedef void (CL_CALLBACK * cl_mem_object_destructor_callback)(cl_mem memobj, void *user_data);
70 typedef void (CL_CALLBACK * cl_build_program_callback)(cl_program program, void *user_data);
71 typedef void (CL_CALLBACK * cl_event_callback)(cl_event event, cl_int event_command_exec_status, void *user_data);
72 typedef void (CL_USER_FUNC_CALLBACK * cl_native_kernel_func)(void *args);
73
74 // -----------------[ Cross-platform functions ]-----------------
75
76 void* extcl_GetProcAddress(const char* function);
77 void extcl_InitializeClass(JNIEnv *env, jclass clazz, int num_functions, JavaMethodAndExtFunction *functions);
78 int extcl_CalculateImageSize(const size_t *region, size_t row_pitch, size_t slice_pitch);
79
80 // -----------------[ Platform dependent functions ]-----------------
81
82 void *extcl_NativeGetFunctionPointer(const char *function);
83 void extcl_LoadLibrary(JNIEnv *env, jstring path);
84 void extcl_UnloadLibrary();
85
86 #ifdef __cplusplus
87 }
88 #endif
89
90 #endif
0 // -----------------[ Core typedefs ]-----------------
1
2 typedef struct _cl_platform_id * cl_platform_id;
3 typedef struct _cl_device_id * cl_device_id;
4 typedef struct _cl_context * cl_context;
5 typedef struct _cl_command_queue * cl_command_queue;
6 typedef struct _cl_mem * cl_mem;
7 typedef struct _cl_program * cl_program;
8 typedef struct _cl_kernel * cl_kernel;
9 typedef struct _cl_event * cl_event;
10 typedef struct _cl_sampler * cl_sampler;
11
12 typedef cl_uint cl_bool; /* WARNING! Unlike cl_ types in cl_platform.h, cl_bool is not guaranteed to be the same size as the bool in kernels. */
13 typedef cl_ulong cl_bitfield;
14 typedef cl_bitfield cl_device_type;
15 typedef cl_uint cl_platform_info;
16 typedef cl_uint cl_device_info;
17 typedef cl_bitfield cl_device_fp_config;
18 typedef cl_uint cl_device_mem_cache_type;
19 typedef cl_uint cl_device_local_mem_type;
20 typedef cl_bitfield cl_device_exec_capabilities;
21 typedef cl_bitfield cl_command_queue_properties;
22
23 typedef intptr_t cl_context_properties;
24 typedef cl_uint cl_context_info;
25 typedef cl_uint cl_command_queue_info;
26 typedef cl_uint cl_channel_order;
27 typedef cl_uint cl_channel_type;
28 typedef cl_bitfield cl_mem_flags;
29 typedef cl_uint cl_mem_object_type;
30 typedef cl_uint cl_mem_info;
31 typedef cl_uint cl_image_info;
32 typedef cl_uint cl_buffer_create_type;
33 typedef cl_uint cl_addressing_mode;
34 typedef cl_uint cl_filter_mode;
35 typedef cl_uint cl_sampler_info;
36 typedef cl_bitfield cl_map_flags;
37 typedef cl_uint cl_program_info;
38 typedef cl_uint cl_program_build_info;
39 typedef cl_int cl_build_status;
40 typedef cl_uint cl_kernel_info;
41 typedef cl_uint cl_kernel_work_group_info;
42 typedef cl_uint cl_event_info;
43 typedef cl_uint cl_command_type;
44 typedef cl_uint cl_profiling_info;
45
46 typedef struct _cl_image_format {
47 cl_channel_order image_channel_order;
48 cl_channel_type image_channel_data_type;
49 } cl_image_format;
50
51 typedef struct _cl_buffer_region {
52 size_t origin;
53 size_t size;
54 } cl_buffer_region;
55
56 // cl_gl.h
57 typedef cl_uint cl_gl_platform_info;
58 typedef cl_uint cl_gl_context_info;
59 typedef cl_uint cl_gl_object_type;
60 typedef cl_uint cl_gl_texture_info;
61
62 // -----------------[ Extension typedefs ]-----------------
63
64 // EXT_device_fission
65 typedef cl_bitfield cl_device_partition_property_ext;
66 // EXT_migrate_memobject
67 typedef cl_bitfield cl_mem_migration_flags_ext;
68
69 // -----------------[ Convenience typedefs ]-----------------
70
71 typedef void cl_void;
6969 #include <string.h>
7070 #include <stddef.h>
7171
72 #ifdef __APPLE__
73 #include <OpenCL/cl_platform.h>
74 #else
75 #include <CL/cl_platform.h>
76 #endif
77
7278 #include "common_tools.h"
7379
7480 #if defined(_WIN32) || defined(_WIN64)
75 #include <windows.h> // fix APIENTRY macro redefinition
76 # define int64_t __int64
77 # define uint64_t unsigned __int64
81 #include <windows.h> // fix APIENTRY macro redefinition
7882 #endif
7983
8084 #ifndef APIENTRY
81 #define APIENTRY
85 #define APIENTRY
8286 #endif
8387
84 #ifdef _MACOSX
85 typedef unsigned long GLenum;
86 typedef unsigned char GLboolean;
87 typedef unsigned long GLbitfield;
88 typedef signed char GLbyte;
89 typedef short GLshort;
90 typedef long GLint;
91 typedef long GLsizei;
92 typedef unsigned char GLubyte;
93 typedef unsigned short GLushort;
94 typedef unsigned long GLuint;
95 typedef float GLfloat;
96 typedef float GLclampf;
97 typedef double GLdouble;
98 typedef double GLclampd;
99 typedef void GLvoid;
100 #else
101 typedef unsigned int GLenum;
102 typedef unsigned char GLboolean;
103 typedef unsigned int GLbitfield;
104 typedef void GLvoid;
105 typedef signed char GLbyte; /* 1-byte signed */
106 typedef short GLshort; /* 2-byte signed */
107 typedef int GLint; /* 4-byte signed */
108 typedef unsigned char GLubyte; /* 1-byte unsigned */
109 typedef unsigned short GLushort; /* 2-byte unsigned */
110 typedef unsigned int GLuint; /* 4-byte unsigned */
111 typedef int GLsizei; /* 4-byte signed */
112 typedef float GLfloat; /* single precision float */
113 typedef float GLclampf; /* single precision float in [0,1] */
114 typedef double GLdouble; /* double precision float */
115 typedef double GLclampd; /* double precision float in [0,1] */
116 #endif
117
118 typedef char GLchar; /* native character */
119
120 typedef ptrdiff_t GLintptr;
121 typedef ptrdiff_t GLsizeiptr;
122 typedef ptrdiff_t GLintptrARB;
123 typedef ptrdiff_t GLsizeiptrARB;
124 typedef char GLcharARB; /* native character */
125 typedef unsigned int GLhandleARB; /* shader object handle */
126 typedef unsigned short GLhalfARB;
127 typedef unsigned short GLhalfNV;
128 typedef unsigned short GLhalf;
129 typedef int64_t GLint64EXT;
130 typedef uint64_t GLuint64EXT;
131 typedef int64_t GLint64;
132 typedef uint64_t GLuint64;
133 typedef struct __GLsync *GLsync;
88 #include "extcl_types.h"
89 #include "extgl_types.h"
13490
13591 /* AMD_debug_output callback function pointer. */
13692 typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id, GLenum category, GLenum severity, GLsizei length, const GLchar* message, GLvoid* userParam);
13793
138 /* helper stuff */
94 /* ARB_debug_output callback function pointer. */
95 typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, GLvoid* userParam);
13996
14097 /* initializes everything, call this right after the rc is created. the function returns true if successful */
14198 extern bool extgl_Open(JNIEnv *env);
0 #if defined(_WIN32) || defined(_WIN64)
1 #define int64_t __int64
2 #define uint64_t unsigned __int64
3 #endif
4
5 #ifdef _MACOSX
6 typedef unsigned long GLenum;
7 typedef unsigned char GLboolean;
8 typedef unsigned long GLbitfield;
9 typedef signed char GLbyte;
10 typedef short GLshort;
11 typedef long GLint;
12 typedef long GLsizei;
13 typedef unsigned char GLubyte;
14 typedef unsigned short GLushort;
15 typedef unsigned long GLuint;
16 typedef float GLfloat;
17 typedef float GLclampf;
18 typedef double GLdouble;
19 typedef double GLclampd;
20 typedef void GLvoid;
21 #else
22 typedef unsigned int GLenum;
23 typedef unsigned char GLboolean;
24 typedef unsigned int GLbitfield;
25 typedef void GLvoid;
26 typedef signed char GLbyte; /* 1-byte signed */
27 typedef short GLshort; /* 2-byte signed */
28 typedef int GLint; /* 4-byte signed */
29 typedef unsigned char GLubyte; /* 1-byte unsigned */
30 typedef unsigned short GLushort; /* 2-byte unsigned */
31 typedef unsigned int GLuint; /* 4-byte unsigned */
32 typedef int GLsizei; /* 4-byte signed */
33 typedef float GLfloat; /* single precision float */
34 typedef float GLclampf; /* single precision float in [0,1] */
35 typedef double GLdouble; /* double precision float */
36 typedef double GLclampd; /* double precision float in [0,1] */
37 #endif
38
39 typedef char GLchar; /* native character */
40
41 typedef ptrdiff_t GLintptr;
42 typedef ptrdiff_t GLsizeiptr;
43 typedef ptrdiff_t GLintptrARB;
44 typedef ptrdiff_t GLsizeiptrARB;
45 typedef char GLcharARB; /* native character */
46 typedef unsigned int GLhandleARB; /* shader object handle */
47 typedef unsigned short GLhalfARB;
48 typedef unsigned short GLhalfNV;
49 typedef unsigned short GLhalf;
50 typedef int64_t GLint64EXT;
51 typedef uint64_t GLuint64EXT;
52 typedef int64_t GLint64;
53 typedef uint64_t GLuint64;
54 typedef struct __GLsync * GLsync;
0 /*******************************************************************************
1 * Copyright (c) 2008-2010 The Khronos Group Inc.
2 *
3 * Permission is hereby granted, free of charge, to any person obtaining a
4 * copy of this software and/or associated documentation files (the
5 * "Materials"), to deal in the Materials without restriction, including
6 * without limitation the rights to use, copy, modify, merge, publish,
7 * distribute, sublicense, and/or sell copies of the Materials, and to
8 * permit persons to whom the Materials are furnished to do so, subject to
9 * the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Materials.
13 *
14 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20 * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
21 ******************************************************************************/
22
23 /* $Revision: 11708 $ on $Date: 2010-06-13 23:36:24 -0700 (Sun, 13 Jun 2010) $ */
24
25 #ifndef __OPENCL_H
26 #define __OPENCL_H
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
32 #ifdef __APPLE__
33
34 #include <OpenCL/cl.h>
35 #include <OpenCL/cl_gl.h>
36 #include <OpenCL/cl_gl_ext.h>
37 #include <OpenCL/cl_ext.h>
38
39 #else
40
41 #include <CL/cl.h>
42 #include <CL/cl_gl.h>
43 #include <CL/cl_gl_ext.h>
44 #include <CL/cl_ext.h>
45
46 #endif
47
48 #include "common_tools.h"
49
50 #ifdef __cplusplus
51 }
52 #endif
53
54 #endif /* __OPENCL_H */
55
0 #include "org_lwjgl_BufferUtils.h"
1
2 JNIEXPORT void JNICALL Java_org_lwjgl_BufferUtils_zeroBuffer0(JNIEnv *env, jclass clazz, jobject buffer, jlong offset, jlong size) {
3 memset((char*)(*env)->GetDirectBufferAddress(env, buffer) + (size_t)offset, 0, (size_t)size);
4 }
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 */
31
31
3232 #include <jni.h>
3333 #include "org_lwjgl_openal_AL.h"
3434 #include "extal.h"
3535
3636 JNIEXPORT void JNICALL Java_org_lwjgl_openal_AL_nCreate(JNIEnv *env, jclass clazz, jstring oalPath) {
37 tryLoadLibrary(env, oalPath);
37 extal_LoadLibrary(env, oalPath);
3838 }
3939
4040 JNIEXPORT void JNICALL Java_org_lwjgl_openal_AL_nDestroy(JNIEnv *env, jclass clazz) {
41 UnLoadOpenAL();
41 extal_UnloadLibrary();
4242 }
4343
4444 JNIEXPORT void JNICALL Java_org_lwjgl_openal_AL_resetNativeStubs(JNIEnv *env, jclass clazz, jclass al_class) {
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 #include <jni.h>
33 #include "org_lwjgl_opencl_CL.h"
34 #include "extcl.h"
35
36 JNIEXPORT void JNICALL Java_org_lwjgl_opencl_CL_nCreate(JNIEnv *env, jclass clazz, jstring oclPath) {
37 extcl_LoadLibrary(env, oclPath);
38 }
39
40 JNIEXPORT void JNICALL Java_org_lwjgl_opencl_CL_nDestroy(JNIEnv *env, jclass clazz) {
41 extcl_UnloadLibrary();
42 }
43
44 JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CL_getFunctionAddress(JNIEnv *env, jclass clazz, jstring function_name) {
45 jlong address_jlong;
46 char *function_name_pointer = GetStringNativeChars(env, function_name);
47 void *address = extcl_GetProcAddress(function_name_pointer);
48 free(function_name_pointer);
49 address_jlong = (jlong)(intptr_t)address;
50 return address_jlong;
51 }
52
53 JNIEXPORT jobject JNICALL Java_org_lwjgl_opencl_CL_getHostBuffer(JNIEnv *env, jclass clazz, jlong address, jint size) {
54 return safeNewBuffer(env, (void *)(intptr_t)address, size);
55 }
56
57 JNIEXPORT void JNICALL Java_org_lwjgl_opencl_CL_resetNativeStubs(JNIEnv *env, jclass clazz, jclass cl_class) {
58 (*env)->UnregisterNatives(env, cl_class);
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
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 "extcl.h"
41 #include "org_lwjgl_opencl_CallbackUtil.h"
42
43 static jmethodID contextCallbackJ;
44 static jmethodID memObjectDestructorCallbackJ;
45 static jmethodID buildProgramCallbackJ;
46 static jmethodID nativeKernelCallbackJ;
47 static jmethodID eventCallbackJ;
48
49 JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CallbackUtil_ncreateGlobalRef(JNIEnv *env, jclass clazz, jobject obj) {
50 return (intptr_t)(*env)->NewGlobalRef(env, obj);
51 }
52
53 JNIEXPORT void JNICALL Java_org_lwjgl_opencl_CallbackUtil_deleteGlobalRef(JNIEnv *env, jclass clazz, jlong globalRef) {
54 (*env)->DeleteGlobalRef(env, (jobject)(intptr_t)globalRef);
55 }
56
57 // ----------------- [ CONTEXT CALLBACK ] -----------------
58
59 static void CL_CALLBACK contextCallback(const char *errinfo, const void *private_info, size_t cb, void *user_data) {
60 JNIEnv *env = attachCurrentThread();
61 jobject private_info_buffer = NULL;
62
63 if ( env != NULL && !(*env)->ExceptionOccurred(env) && contextCallbackJ != NULL ) {
64 if ( private_info != NULL )
65 private_info_buffer = NewReadOnlyDirectByteBuffer(env, private_info, cb);
66
67 (*env)->CallVoidMethod(env, (jobject)user_data, contextCallbackJ,
68 NewStringNativeWithLength(env, errinfo, strlen(errinfo)),
69 private_info_buffer
70 );
71 }
72
73 detachCurrentThread();
74 }
75
76 JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CallbackUtil_getContextCallback(JNIEnv *env, jclass clazz) {
77 // Cache the callback methodID
78 jclass callbackClass;
79 if ( contextCallbackJ == NULL ) {
80 callbackClass = (*env)->FindClass(env, "org/lwjgl/opencl/CLContextCallback");
81 if ( callbackClass != NULL )
82 contextCallbackJ = (*env)->GetMethodID(env, callbackClass, "handleMessage", "(Ljava/lang/String;Ljava/nio/ByteBuffer;)V");
83 }
84
85 return (jlong)(intptr_t)&contextCallback;
86 }
87
88 // ----------------- [ MEM OBJECT DESTRUCTOR CALLBACK ] -----------------
89
90 static void CL_CALLBACK memObjectDestructorCallback(cl_mem memobj, void *user_data) {
91 JNIEnv *env = attachCurrentThread();
92
93 if ( env != NULL && !(*env)->ExceptionOccurred(env) && memObjectDestructorCallbackJ != NULL ) {
94 (*env)->CallVoidMethod(env, (jobject)user_data, memObjectDestructorCallbackJ,
95 (jlong)(intptr_t)memobj
96 );
97 (*env)->DeleteGlobalRef(env, (jobject)user_data);
98 }
99
100 detachCurrentThread();
101 }
102
103 JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CallbackUtil_getMemObjectDestructorCallback(JNIEnv *env, jclass clazz) {
104 // Cache the callback methodID
105 jclass callbackClass;
106 if ( memObjectDestructorCallbackJ == NULL ) {
107 callbackClass = (*env)->FindClass(env, "org/lwjgl/opencl/CLMemObjectDestructorCallback");
108 if ( callbackClass != NULL )
109 memObjectDestructorCallbackJ = (*env)->GetMethodID(env, callbackClass, "handleMessage", "(J)V");
110 }
111
112 return (jlong)(intptr_t)&memObjectDestructorCallback;
113 }
114
115 // ----------------- [ MEM OBJECT DESTRUCTOR CALLBACK ] -----------------
116
117 static void CL_CALLBACK buildProgramCallback(cl_program program, void *user_data) {
118 JNIEnv *env = attachCurrentThread();
119
120 if ( env != NULL && !(*env)->ExceptionOccurred(env) && buildProgramCallbackJ != NULL ) {
121 (*env)->CallVoidMethod(env, (jobject)user_data, buildProgramCallbackJ,
122 (jlong)(intptr_t)program
123 );
124 (*env)->DeleteGlobalRef(env, (jobject)user_data);
125 }
126
127 detachCurrentThread();
128 }
129
130 JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CallbackUtil_getBuildProgramCallback(JNIEnv *env, jclass clazz) {
131 // Cache the callback methodID
132 jclass callbackClass;
133 if ( buildProgramCallbackJ == NULL ) {
134 callbackClass = (*env)->FindClass(env, "org/lwjgl/opencl/CLBuildProgramCallback");
135 if ( callbackClass != NULL )
136 buildProgramCallbackJ = (*env)->GetMethodID(env, callbackClass, "handleMessage", "(J)V");
137 }
138
139 return (jlong)(intptr_t)&buildProgramCallback;
140 }
141
142 // ----------------- [ NATIVE KERNEL CALLBACK ] -----------------
143
144 static void CL_USER_FUNC_CALLBACK nativeKernelCallback(void *args) {
145 JNIEnv *env = attachCurrentThread();
146 jobject user_func = (jobject)(intptr_t)*(jlong *)args;
147 jint num_mem_objects = *(jint *)((char *)args + 8);
148 jobjectArray memobjs = NULL;
149 jobject buffer;
150 jint i;
151
152 if ( env != NULL && !(*env)->ExceptionOccurred(env) && nativeKernelCallbackJ != NULL ) {
153 if ( num_mem_objects > 0 ) {
154 memobjs = (*env)->NewObjectArray(env, num_mem_objects, (*env)->FindClass(env, "java/nio/ByteBuffer"), NULL);
155 for ( i = 0; i < num_mem_objects; i++ ) {
156 buffer = (*env)->NewDirectByteBuffer(env,
157 // Pointer to cl_mem buffer
158 (void *)((char *)args + (12 + 4 + (i * (4 + sizeof(void *))))),
159 // cl_mem buffer size
160 *((jint *)((char *)args + (12 + (i * (4 + sizeof(void *))))))
161 );
162 (*env)->SetObjectArrayElement(env, memobjs, i, buffer);
163 }
164 }
165
166 (*env)->CallVoidMethod(env, user_func, nativeKernelCallbackJ, memobjs);
167
168 if ( num_mem_objects > 0 )
169 (*env)->DeleteLocalRef(env, memobjs);
170 (*env)->DeleteGlobalRef(env, user_func);
171 }
172
173 detachCurrentThread();
174 }
175
176 JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CallbackUtil_getNativeKernelCallback(JNIEnv *env, jclass clazz) {
177 // Cache the callback methodID
178 jclass callbackClass;
179 if ( nativeKernelCallbackJ == NULL ) {
180 callbackClass = (*env)->FindClass(env, "org/lwjgl/opencl/CLNativeKernel");
181 if ( callbackClass != NULL )
182 nativeKernelCallbackJ = (*env)->GetMethodID(env, callbackClass, "execute", "([Ljava/nio/ByteBuffer;)V");
183 }
184
185 return (jlong)(intptr_t)&nativeKernelCallback;
186 }
187
188 // ----------------- [ EVENT CALLBACK ] -----------------
189
190 static void CL_CALLBACK eventCallback(cl_event event, cl_int event_command_exec_status, void *user_data) {
191 JNIEnv *env = attachCurrentThread();
192
193 if ( env != NULL && !(*env)->ExceptionOccurred(env) && eventCallbackJ != NULL ) {
194 (*env)->CallVoidMethod(env, (jobject)user_data, eventCallbackJ,
195 (jlong)(intptr_t)event,
196 event_command_exec_status
197 );
198 (*env)->DeleteGlobalRef(env, (jobject)user_data);
199 }
200
201 detachCurrentThread();
202 }
203
204 JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CallbackUtil_getEventCallback(JNIEnv *env, jclass clazz) {
205 // Cache the callback methodID
206 jclass callbackClass;
207 if ( eventCallbackJ == NULL ) {
208 callbackClass = (*env)->FindClass(env, "org/lwjgl/opencl/CLEventCallback");
209 if ( callbackClass != NULL )
210 eventCallbackJ = (*env)->GetMethodID(env, callbackClass, "handleMessage", "(JI)V");
211 }
212
213 return (jlong)(intptr_t)&eventCallback;
214 }
215
216 // ----------------- [ APPLE_ContextLoggingFunctions CALLBACKS ] -----------------
217
218 JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CallbackUtil_getLogMessageToSystemLogAPPLE(JNIEnv *env, jclass clazz) {
219 return (jlong)(intptr_t)extcl_GetProcAddress("clLogMessagesToSystemLogAPPLE");
220 }
221
222 JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CallbackUtil_getLogMessageToStdoutAPPLE(JNIEnv *env, jclass clazz) {
223 return (jlong)(intptr_t)extcl_GetProcAddress("getLogMessageToStdoutAPPLE");
224 }
225
226 JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CallbackUtil_getLogMessageToStderrAPPLE(JNIEnv *env, jclass clazz) {
227 return (jlong)(intptr_t)extcl_GetProcAddress("getLogMessageToStderrAPPLE");
228 }
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_CallbackUtil.h"
42
43 static jmethodID debugOutputCallbackARBJ;
44 static jmethodID debugOutputCallbackAMDJ;
45
46 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_CallbackUtil_ncreateGlobalRef(JNIEnv *env, jclass clazz, jobject obj) {
47 return (jlong)(*env)->NewGlobalRef(env, obj);
48 }
49
50 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_CallbackUtil_deleteGlobalRef(JNIEnv *env, jclass clazz, jlong globalRef) {
51 (*env)->DeleteGlobalRef(env, (jobject)globalRef);
52 }
53
54 // ----------------- [ ARB_debug_output ] -----------------
55
56 static void APIENTRY debugOutputCallbackARB(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, GLvoid* userParam) {
57 JNIEnv *env = attachCurrentThread();
58
59 if ( env != NULL && !(*env)->ExceptionOccurred(env) && debugOutputCallbackARBJ != NULL ) {
60 (*env)->CallVoidMethod(env, (jobject)userParam, debugOutputCallbackARBJ,
61 (jint)source,
62 (jint)type,
63 (jint)id,
64 (jint)severity,
65 NewStringNativeWithLength(env, message, length)
66 );
67 }
68
69 detachCurrentThread();
70 }
71
72 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_CallbackUtil_getDebugOutputCallbackARB(JNIEnv *env, jclass clazz) {
73 // Cache the callback methodID
74 jclass callbackClass;
75 if ( debugOutputCallbackARBJ == NULL ) {
76 callbackClass = (*env)->FindClass(env, "org/lwjgl/opengl/ARBDebugOutputCallback$Handler");
77 if ( callbackClass != NULL )
78 debugOutputCallbackARBJ = (*env)->GetMethodID(env, callbackClass, "handleMessage", "(IIIILjava/lang/String;)V");
79 }
80
81 return (jlong)(intptr_t)&debugOutputCallbackARB;
82 }
83
84 // ----------------- [ AMD_debug_output ] -----------------
85
86 static void APIENTRY debugOutputCallbackAMD(GLuint id, GLenum category, GLenum severity, GLsizei length, const GLchar* message, GLvoid* userParam) {
87 JNIEnv *env = attachCurrentThread();
88
89 if ( env != NULL && !(*env)->ExceptionOccurred(env) && debugOutputCallbackAMDJ != NULL ) {
90 (*env)->CallVoidMethod(env, (jobject)userParam, debugOutputCallbackAMDJ,
91 (jint)id,
92 (jint)category,
93 (jint)severity,
94 NewStringNativeWithLength(env, message, length)
95 );
96 }
97
98 detachCurrentThread();
99 }
100
101 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_CallbackUtil_getDebugOutputCallbackAMD(JNIEnv *env, jclass clazz) {
102 // Cache the callback methodID
103 jclass callbackClass;
104 if ( debugOutputCallbackAMDJ == NULL ) {
105 callbackClass = (*env)->FindClass(env, "org/lwjgl/opengl/AMDDebugOutputCallback$Handler");
106 if ( callbackClass != NULL )
107 debugOutputCallbackAMDJ = (*env)->GetMethodID(env, callbackClass, "handleMessage", "(IIILjava/lang/String;)V");
108 }
109
110 return (jlong)(intptr_t)&debugOutputCallbackAMD;
111 }
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 */
4040
4141 static void* handleOAL;
4242
43 void *NativeGetFunctionPointer(const char *function) {
43 void *extal_NativeGetFunctionPointer(const char *function) {
4444 return dlsym(handleOAL, function);
4545 }
4646
47 void tryLoadLibrary(JNIEnv *env, jstring path) {
47 void extal_LoadLibrary(JNIEnv *env, jstring path) {
4848 char *path_str = GetStringNativeChars(env, path);
4949 printfDebugJava(env, "Testing '%s'", path_str);
5050 handleOAL = dlopen(path_str, RTLD_LAZY);
5656 free(path_str);
5757 }
5858
59 void UnLoadOpenAL() {
59 void extal_UnloadLibrary() {
6060 if (handleOAL != NULL) {
6161 dlclose(handleOAL);
6262 handleOAL = NULL;
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
32 #include <stdio.h>
33 #include <stdlib.h>
34 #include <string.h>
35 #include "extcl.h"
36 #include "common_tools.h"
37
38 #include <dlfcn.h>
39
40 static void* handleOCL;
41
42 void *extcl_NativeGetFunctionPointer(const char *function) {
43 return dlsym(handleOCL, function);
44 }
45
46 void extcl_LoadLibrary(JNIEnv *env, jstring path) {
47 char *path_str = GetStringNativeChars(env, path);
48 printfDebugJava(env, "Testing '%s'", path_str);
49 handleOCL = dlopen(path_str, RTLD_LAZY);
50 if (handleOCL != NULL) {
51 printfDebugJava(env, "Found OpenCL at '%s'", path_str);
52 } else {
53 throwException(env, "Could not load OpenCL library");
54 }
55 free(path_str);
56 }
57
58 void extcl_UnloadLibrary() {
59 if (handleOCL != NULL) {
60 dlclose(handleOCL);
61 handleOCL = NULL;
62 }
63 }
3030 */
3131
3232 /**
33 * $Id: org_lwjgl_opengl_Display.c 3188 2009-03-19 21:50:30Z elias_naur $
33 * $Id: org_lwjgl_opengl_Display.c 3453 2010-10-28 21:39:55Z kappa1 $
3434 *
3535 * Linux specific display functions.
3636 *
3737 * @author elias_naur <elias_naur@users.sourceforge.net>
38 * @version $Revision: 3188 $
38 * @version $Revision: 3453 $
3939 */
4040
4141 #include <X11/X.h>
306306 cmap = XCreateColormap(disp, parent, vis_info->visual, AllocNone);
307307 attribs.colormap = cmap;
308308 attribs.border_pixel = 0;
309 attribs.event_mask = ExposureMask | FocusChangeMask | VisibilityChangeMask | StructureNotifyMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask;
309 attribs.event_mask = ExposureMask | FocusChangeMask | VisibilityChangeMask | StructureNotifyMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask| EnterWindowMask | LeaveWindowMask;
310310 attribmask = CWColormap | CWEventMask | CWBorderPixel;
311311 if (isLegacyFullscreen(window_mode)) {
312312 attribmask |= CWOverrideRedirect;
3030 */
3131
3232 /**
33 * $Id: org_lwjgl_opengl_LinuxContextImplementation.c 3203 2009-04-24 20:35:33Z elias_naur $
33 * $Id: org_lwjgl_opengl_LinuxContextImplementation.c 3412 2010-09-26 23:43:24Z spasi $
3434 *
3535 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 3203 $
36 * @version $Revision: 3412 $
3737 */
3838
3939 #include <jni.h>
105105 context_info->context = context;
106106 }
107107
108 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_getGLXContext(JNIEnv *env, jclass clazz, jobject context_handle) {
109 X11Context *context_info = (*env)->GetDirectBufferAddress(env, context_handle);
110 return (intptr_t)context_info->context;
111 }
112
113 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_getDisplay(JNIEnv *env, jclass clazz, jobject peer_info_handle) {
114 X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle);
115 return (intptr_t)peer_info->display;
116 }
117
108118 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nSetSwapInterval
109119 (JNIEnv *env, jclass clazz, jobject context_handle, jint value)
110120 {
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 */
4040 #include "common_tools.h"
4141
4242 /**
43 * $Id: macosx_al.c 2985 2008-04-07 18:42:36Z matzon $
43 * $Id: macosx_al.c 3416 2010-09-27 00:25:59Z spasi $
4444 *
4545 * This file contains the AL extension assigning mechanism
4646 *
4747 * @author Brian Matzon <brian@matzon.dk>
48 * @version $Revision: 2985 $
48 * @version $Revision: 3416 $
4949 */
5050
5151 static const struct mach_header* handleOAL = NULL;
5252 static CFBundleRef openal_bundle = NULL;
5353
54 void *NativeGetFunctionPointer(const char *function) {
54 void *extal_NativeGetFunctionPointer(const char *function) {
5555 void *address = NULL;
5656 if (handleOAL != NULL) {
5757 char *mac_symbol_name = (char *)malloc((strlen(function) + 2)*sizeof(char));
8888 return openal_bundle;
8989 }
9090
91 void tryLoadLibrary(JNIEnv *env, jstring path) {
91 void extal_LoadLibrary(JNIEnv *env, jstring path) {
9292 const char *path_str = (*env)->GetStringUTFChars(env, path, NULL);
9393 printfDebugJava(env, "Testing '%s'", path_str);
9494 handleOAL = NSAddImage(path_str, NSADDIMAGE_OPTION_RETURN_ON_ERROR);
103103 /**
104104 * Unloads the OpenAL Library
105105 */
106 void UnLoadOpenAL() {
106 void extal_UnloadLibrary() {
107107 if (openal_bundle != NULL) {
108108 CFRelease(openal_bundle);
109109 openal_bundle = NULL;
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 #include <stdio.h>
33 #include <stdlib.h>
34 #include <string.h>
35 #include <mach-o/dyld.h>
36 #include <stdlib.h>
37 #include <string.h>
38 #include <CoreFoundation/CoreFoundation.h>
39 #include "extcl.h"
40 #include "common_tools.h"
41
42 /**
43 * OpenCL library management
44 */
45 static const struct mach_header* handleOCL = NULL;
46 static CFBundleRef opencl_bundle = NULL;
47
48 void *extcl_NativeGetFunctionPointer(const char *function) {
49 void *address = NULL;
50 if (handleOCL != NULL) {
51 char *mac_symbol_name = (char *)malloc((strlen(function) + 2)*sizeof(char));
52 if (mac_symbol_name == NULL)
53 return NULL;
54 mac_symbol_name[0] = '_';
55 strcpy(&(mac_symbol_name[1]), function);
56 NSSymbol symbol = NSLookupSymbolInImage(handleOCL, mac_symbol_name, NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR);
57 free(mac_symbol_name);
58 if (symbol != NULL) {
59 address = NSAddressOfSymbol(symbol);
60 }
61 } else if (opencl_bundle != NULL) {
62 CFStringRef cf_function = CFStringCreateWithCString(NULL, function, kCFStringEncodingUTF8);
63 address = CFBundleGetFunctionPointerForName(opencl_bundle, cf_function);
64 CFRelease(cf_function);
65 }
66 return address;
67 }
68
69 static CFBundleRef tryLoadFramework(JNIEnv *env) {
70 CFStringRef framework_path = CFSTR("/System/Library/Frameworks/OpenCL.framework");
71 if (framework_path == NULL) {
72 printfDebugJava(env, "Failed to allocate string");
73 return NULL;
74 }
75 CFURLRef url = CFURLCreateWithFileSystemPath(NULL, framework_path, kCFURLPOSIXPathStyle, TRUE);
76 if (url == NULL) {
77 printfDebugJava(env, "Failed to allocate URL");
78 return NULL;
79 }
80 CFBundleRef opencl_bundle = CFBundleCreate(NULL, url);
81 CFRelease(url);
82 return opencl_bundle;
83 }
84
85 void extcl_LoadLibrary(JNIEnv *env, jstring path) {
86 const char *path_str = (*env)->GetStringUTFChars(env, path, NULL);
87 printfDebugJava(env, "Testing '%s'", path_str);
88 handleOCL = NSAddImage(path_str, NSADDIMAGE_OPTION_RETURN_ON_ERROR);
89 if (handleOCL != NULL) {
90 printfDebugJava(env, "Found OpenCL at '%s'", path_str);
91 } else {
92 throwException(env, "Could not load OpenCL library");
93 }
94 (*env)->ReleaseStringUTFChars(env, path, path_str);
95 }
96
97 /**
98 * Unloads the OpenCL Library
99 */
100 void extcl_UnloadLibrary() {
101 if (opencl_bundle != NULL) {
102 CFRelease(opencl_bundle);
103 opencl_bundle = NULL;
104 }
105 }
106
107 JNIEXPORT void JNICALL Java_org_lwjgl_opencl_CL_nCreateDefault(JNIEnv *env, jclass clazz) {
108 opencl_bundle = tryLoadFramework(env);
109 if (opencl_bundle != NULL)
110 printfDebugJava(env, "Found OpenCL Bundle");
111 else
112 throwException(env, "Could not load OpenCL framework");
113 }
3030 */
3131
3232 /**
33 * $Id: org_lwjgl_opengl_WindowsContextImplementation.c 3116 2008-08-19 16:46:03Z spasi $
33 * $Id: org_lwjgl_opengl_WindowsContextImplementation.c 3412 2010-09-26 23:43:24Z spasi $
3434 *
3535 * @author elias_naur <elias_naur@users.sourceforge.net>
36 * @version $Revision: 3116 $
36 * @version $Revision: 3412 $
3737 */
3838
3939 #include <jni.h>
5353 WindowsContext *context_info;
5454 HGLRC context;
5555 HGLRC shared_context = NULL;
56
56
5757 // -- We need to create a temporary context to detect the presence of WGL_ARB_create_context
5858 HDC saved_current_hdc;
5959 HGLRC saved_current_hglrc;
6060 WGLExtensions extensions;
6161 const int *attribList = attribs == NULL ? NULL : ((const int *)(*env)->GetDirectBufferAddress(env, attribs));
62
62
6363 jobject context_handle = newJavaManagedByteBuffer(env, sizeof(WindowsContext));
6464 if (context_handle == NULL) {
6565 throwException(env, "Could not create handle buffer");
119119 return context_handle;
120120 }
121121
122 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_getHGLRC(JNIEnv *env, jclass clazz, jobject context_handle) {
123 WindowsContext *context_info = (WindowsContext *)(*env)->GetDirectBufferAddress(env, context_handle);
124 return (intptr_t)context_info->context;
125 }
126
127 JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_getHDC(JNIEnv *env, jclass clazz, jobject peer_info_handle) {
128 WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
129 return (intptr_t)peer_info->drawable_hdc;
130 }
131
122132 JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nSwapBuffers
123133 (JNIEnv *env, jclass clazz, jobject peer_info_handle) {
124134 WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
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 */
3636 #include "common_tools.h"
3737
3838 /**
39 * $Id: windows_al.c 2985 2008-04-07 18:42:36Z matzon $
39 * $Id: windows_al.c 3412 2010-09-26 23:43:24Z spasi $
4040 *
4141 * This file contains the AL extension assigning mechanism
4242 *
4343 * @author Brian Matzon <brian@matzon.dk>
44 * @version $Revision: 2985 $
44 * @version $Revision: 3412 $
4545 */
4646 /* Handle to OpenAL Library */
4747 static HMODULE handleOAL;
4848
49 void *NativeGetFunctionPointer(const char *function) {
49 void *extal_NativeGetFunctionPointer(const char *function) {
5050 return GetProcAddress(handleOAL, function);
5151 }
5252
53 void tryLoadLibrary(JNIEnv *env, jstring path) {
53 void extal_LoadLibrary(JNIEnv *env, jstring path) {
5454 char *path_str = GetStringNativeChars(env, path);
5555 printfDebugJava(env, "Testing '%s'", path_str);
5656 handleOAL = LoadLibrary(path_str);
6565 /**
6666 * Unloads the OpenAL Library
6767 */
68 void UnLoadOpenAL() {
68 void extal_UnloadLibrary() {
6969 FreeLibrary(handleOAL);
7070 }
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 #include <stdio.h>
33 #include <stdlib.h>
34 #include <string.h>
35 #include <windows.h>
36 #include "extcl.h"
37 #include "common_tools.h"
38
39 /**
40 * This file contains the CL extension assigning mechanism
41 *
42 * @author Spasi
43 */
44
45 /* Handle to OpenCL Library */
46 static HMODULE handleOCL;
47
48 void * extcl_NativeGetFunctionPointer(const char *func_name) {
49 return GetProcAddress(handleOCL, func_name);
50 }
51
52 void extcl_LoadLibrary(JNIEnv *env, jstring path) {
53 char *path_str = GetStringNativeChars(env, path);
54 printfDebugJava(env, "Testing '%s'", path_str);
55 handleOCL = LoadLibrary(path_str);
56 if (handleOCL != NULL) {
57 printfDebugJava(env, "Found OpenCL at '%s'", path_str);
58 } else {
59 throwFormattedException(env, "Could not load OpenCL library (%d)", GetLastError());
60 }
61 free(path_str);
62 }
63
64 /**
65 * Unloads the OpenCL Library
66 */
67 void extcl_UnloadLibrary() {
68 if ( handleOCL != NULL ) {
69 FreeLibrary(handleOCL);
70 handleOCL = NULL;
71 }
72 }
3636 import java.nio.DoubleBuffer;
3737
3838 import org.lwjgl.util.generator.*;
39 import org.lwjgl.util.generator.openal.*;
3940
4041 /**
4142 * <br>
4344 * AL.h version 1.0
4445 *
4546 * @author Brian Matzon <brian@matzon.dk>
46 * @version $Revision: 3380 $
47 * $Id: AL10.java 3380 2010-07-14 13:12:24Z matzon $
47 * @version $Revision: 3412 $
48 * $Id: AL10.java 3412 2010-09-26 23:43:24Z spasi $
4849 */
4950 public interface AL10 {
5051 /** Bad value */
491492 @StripPostfix("data")
492493 @ALvoid
493494 void alGetFloatv(@ALenum int pname, @OutParameter @Check("1") FloatBuffer data);
494
495
495496 /**
496497 * Like OpenGL, AL uses a simplified interface for querying global state.
497498 *
3030 */
3131 package org.lwjgl.openal;
3232
33 import java.nio.Buffer;
3433 import java.nio.IntBuffer;
3534 import java.nio.FloatBuffer;
36 import java.nio.DoubleBuffer;
37
38 import org.lwjgl.openal.AL10;
35
3936 import org.lwjgl.util.generator.*;
37 import org.lwjgl.util.generator.openal.ALenum;
38 import org.lwjgl.util.generator.openal.ALuint;
39 import org.lwjgl.util.generator.openal.ALvoid;
4040
4141 /**
4242 * <br>
5151
5252 /** Source buffer position information in seconds */
5353 public static final int AL_SEC_OFFSET = 0x1024;
54
54
5555 /** Source buffer position information in samples */
5656 public static final int AL_SAMPLE_OFFSET = 0x1025;
57
57
5858 /** Source buffer position information in bytes */
5959 public static final int AL_BYTE_OFFSET = 0x1026;
6060
6161 /** Type of source: Buffer has been attached using AL_BUFFER */
6262 public static final int AL_STATIC = 0x1028;
63
63
6464 /** Type of source: if one or more Buffers have been attached using alSourceQueueBuffers */
6565 public static final int AL_STREAMING = 0x1029;
66
66
6767 /** Type of source: when it has the NULL buffer attached */
6868 public static final int AL_UNDETERMINED = 0x1030;
6969
7070 /** @see AL10#AL_INVALID_OPERATION */
7171 public static final int AL_ILLEGAL_COMMAND = 0xA004;
72
72
7373 /** Speed of Sound in units per second */
7474 public static final int AL_SPEED_OF_SOUND = 0xC003;
75
75
7676 public static final int AL_LINEAR_DISTANCE = 0xD003;
7777 public static final int AL_LINEAR_DISTANCE_CLAMPED = 0xD004;
7878 public static final int AL_EXPONENT_DISTANCE = 0xD005;
7979 public static final int AL_EXPONENT_DISTANCE_CLAMPED = 0xD006;
80
80
8181 /**
8282 * Listener attributes are changed using the Listener group of commands.
8383 *
8888 */
8989 @ALvoid
9090 void alListener3i(@ALenum int pname, int v1, int v2, int v3);
91
91
9292 /**
9393 * Listener state is maintained inside the AL implementation and can be queried in
9494 * full.
100100 @StripPostfix("intdata")
101101 @ALvoid
102102 void alGetListeneriv(@ALenum int pname, @OutParameter @Check("1") FloatBuffer intdata);
103
103
104104 /**
105105 * Specifies the position and other properties as taken into account during
106106 * sound processing.
113113 */
114114 @ALvoid
115115 void alSource3i(@ALuint int source, @ALenum int pname, int v1, int v2, int v3);
116
116
117117 /**
118118 * Specifies the position and other properties as taken into account during
119119 * sound processing.
126126 @StripPostfix("value")
127127 @ALvoid
128128 void alSourceiv(@ALuint int source, @ALenum int pname, @Check("1") @Const IntBuffer value);
129
129
130130 /**
131131 * This function sets a floating point property of a buffer.
132132 * <i>note: There are no relevant buffer properties defined in OpenAL 1.1 which can be affected by
137137 * @param value value of property
138138 */
139139 @ALvoid
140 void alBufferf(@ALuint int buffer, @ALenum int pname, float value);
141
140 void alBufferf(@ALuint int buffer, @ALenum int pname, float value);
141
142142 /**
143143 * This function sets a floating point property of a buffer.
144144 * <i>note: There are no relevant buffer properties defined in OpenAL 1.1 which can be affected by
152152 */
153153 @ALvoid
154154 void alBuffer3f(@ALuint int buffer, @ALenum int pname, float v1, float v2, float v3);
155
155
156156 /**
157157 * This function sets a floating point property of a buffer.
158158 * <i>note: There are no relevant buffer properties defined in OpenAL 1.1 which can be affected by
166166 @StripPostfix("value")
167167 @ALvoid
168168 void alBufferfv(@ALuint int buffer, @ALenum int pname, @Check("1") @Const FloatBuffer value);
169
169
170170 /**
171171 * This function sets an integer property of a buffer.
172172 * <i>note: There are no relevant buffer properties defined in OpenAL 1.1 which can be affected by
177177 * @param value value of property
178178 */
179179 @ALvoid
180 void alBufferi(@ALuint int buffer, @ALenum int pname, int value);
181
180 void alBufferi(@ALuint int buffer, @ALenum int pname, int value);
181
182182 /**
183183 * This function sets an integer property of a buffer.
184184 * <i>note: There are no relevant buffer properties defined in OpenAL 1.1 which can be affected by
192192 */
193193 @ALvoid
194194 void alBuffer3i(@ALuint int buffer, @ALenum int pname, int v1, int v2, int v3);
195
195
196196 /**
197197 * This function sets an integer property of a buffer.
198198 * <i>note: There are no relevant buffer properties defined in OpenAL 1.1 which can be affected by
206206 @StripPostfix("value")
207207 @ALvoid
208208 void alBufferiv(@ALuint int buffer, @ALenum int pname, @Check("1") @Const IntBuffer value);
209
209
210210 /**
211211 * This function retrieves an integer property of a buffer.
212212 * <i>note: There are no relevant buffer properties defined in OpenAL 1.1 which can be affected by
213213 * this call, but this function may be used by OpenAL extensions.</i>
214 *
214 *
215215 * @param buffer Buffer to get property from
216216 * @param pname name of property
217217 * @return int
218218 */
219219 @ALvoid
220220 void alGetBufferi(@ALuint int buffer, @ALenum int pname, @Result int value);
221
221
222222 /**
223223 * This function retrieves an integer property of a buffer.
224 *
224 *
225225 * @param buffer Buffer to get property from
226226 * @param pname name of property
227227 */
234234 * This function retrieves a floating point property of a buffer.
235235 * <i>note: There are no relevant buffer properties defined in OpenAL 1.1 which can be affected by
236236 * this call, but this function may be used by OpenAL extensions.</i>
237 *
237 *
238238 * @param buffer Buffer to get property from
239239 * @param pname name of property
240240 * @return floating point property
246246 * This function retrieves a floating point property of a buffer.
247247 * <i>note: There are no relevant buffer properties defined in OpenAL 1.1 which can be affected by
248248 * this call, but this function may be used by OpenAL extensions.</i>
249 *
249 *
250250 * @param buffer Buffer to get property from
251251 * @param pname name of property
252252 */
254254 @StripPostfix("values")
255255 @ALvoid
256256 void alGetBufferfv(@ALuint int buffer, @ALenum int pname, @OutParameter @Check("1") FloatBuffer values);
257
257
258258 /**
259259 * <p>
260260 * AL_SPEED_OF_SOUND allows the application to change the reference (propagation)
273273 * @param value distance model to be set
274274 */
275275 @ALvoid
276 void alSpeedOfSound(float value);
276 void alSpeedOfSound(float value);
277277 }
3333 import java.nio.FloatBuffer;
3434 import java.nio.IntBuffer;
3535
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;
36 import org.lwjgl.util.generator.*;
37 import org.lwjgl.util.generator.openal.ALenum;
38 import org.lwjgl.util.generator.openal.ALsizei;
39 import org.lwjgl.util.generator.openal.ALuint;
40 import org.lwjgl.util.generator.openal.ALvoid;
4041 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;
4942
5043 /**
5144 * Implementation of the OpenAL extension ALC_EXT_EFX (version 1.0). Contains necessary fields,
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.opencl;
32
33 import org.lwjgl.util.generator.opencl.CLDeviceExtension;
34
35 @CLDeviceExtension
36 public interface AMD_device_attribute_query {
37
38 /**
39 * Accepted as the &lt;param_name&gt; parameter of clGetDeviceInfo. Return the
40 * offset in nano-seconds between an event timestamp and Epoch.
41 */
42 int CL_DEVICE_PROFILING_TIMER_OFFSET_AMD = 0x4036;
43
44 }
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.opencl;
32
33 import org.lwjgl.util.generator.opencl.CLDeviceExtension;
34
35 @CLDeviceExtension
36 public interface AMD_fp64 {
37
38 }
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.opencl;
32
33 import org.lwjgl.util.generator.opencl.CLDeviceExtension;
34
35 @CLDeviceExtension
36 public interface AMD_media_ops {
37
38 }
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.opencl;
32
33 import org.lwjgl.util.generator.opencl.CLDeviceExtension;
34
35 @CLDeviceExtension
36 public interface AMD_printf {
37
38 }
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.opencl;
32
33 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opencl.CLDeviceExtension;
35 import org.lwjgl.util.generator.opencl.cl_char;
36 import org.lwjgl.util.generator.opencl.cl_void;
37 import org.lwjgl.util.generator.opencl.size_t;
38
39 import java.nio.ByteBuffer;
40
41 @Private
42 @CLDeviceExtension
43 public interface APPLE_ContextLoggingFunctions {
44
45 @Extern
46 void clLogMessagesToSystemLogAPPLE(@Check @Const @cl_char ByteBuffer errstr,
47 @Const @cl_void ByteBuffer private_info,
48 @AutoSize("private_info") @size_t long cb,
49 @Check @cl_void ByteBuffer user_data);
50
51 @Extern
52 void clLogMessagesToStdoutAPPLE(@Check @Const @cl_char ByteBuffer errstr,
53 @Const @cl_void ByteBuffer private_info,
54 @AutoSize("private_info") @size_t long cb,
55 @Check @cl_void ByteBuffer user_data);
56
57 @Extern
58 void clLogMessagesToStderrAPPLE(@Check @Const @cl_char ByteBuffer errstr,
59 @Const @cl_void ByteBuffer private_info,
60 @AutoSize("private_info") @size_t long cb,
61 @Check @cl_void ByteBuffer user_data);
62
63 }
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.opencl;
32
33 import org.lwjgl.util.generator.Code;
34 import org.lwjgl.util.generator.Constant;
35 import org.lwjgl.util.generator.PointerWrapper;
36 import org.lwjgl.util.generator.opencl.CLDeviceExtension;
37 import org.lwjgl.util.generator.opencl.cl_int;
38
39 @CLDeviceExtension
40 public interface APPLE_SetMemObjectDestructor {
41
42 @Code(
43 tryBlock = true,
44 // Create a GlobalRef to the callback object.
45 javaBeforeNative = "\t\tlong user_data = CallbackUtil.createGlobalRef(pfn_notify);",
46 // Check if we need to delete the GlobalRef.
47 javaFinally = "\t\t\tCallbackUtil.checkCallback(__result, user_data);"
48 )
49 @cl_int
50 int clSetMemObjectDestructorAPPLE(@PointerWrapper("cl_mem") CLMem memobj,
51 @PointerWrapper("cl_mem_object_destructor_callback") CLMemObjectDestructorCallback pfn_notify,
52 @Constant("user_data") @PointerWrapper("void *") long user_data);
53
54 }
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.opencl;
32
33 import org.lwjgl.PointerBuffer;
34 import org.lwjgl.util.generator.*;
35 import org.lwjgl.util.generator.opencl.CLDeviceExtension;
36 import org.lwjgl.util.generator.opencl.cl_int;
37 import org.lwjgl.util.generator.opencl.cl_void;
38 import org.lwjgl.util.generator.opencl.size_t;
39
40 import java.nio.ByteBuffer;
41
42 @CLDeviceExtension
43 @Extension(postfix = "APPLE", className = "APPLEGLSharing")
44 public interface APPLE_gl_sharing {
45
46 /**
47 * This enumerated value can be specified as part of the &lt;properties&gt; argument passed to clCreateContext
48 * to allow OpenCL compliant devices in an existing CGL share group to be used as the devices in
49 * the newly created CL context. GL objects that were allocated in the given CGL share group can
50 * now be shared between CL and GL.
51 */
52 int CL_CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE = 0x10000000;
53
54 /**
55 * Returns a cl_device_id for the CL device associated with the virtual screen for
56 * the given CGL context. Return type: cl_device_id
57 */
58 int CL_CGL_DEVICE_FOR_CURRENT_VIRTUAL_SCREEN_APPLE = 0x10000002;
59
60 /**
61 * Returns an array of cl_device_ids for the CL device(s) corresponding to
62 * the virtual screen(s) for the given CGL context. Return type: cl_device_id[]
63 */
64 int CL_CGL_DEVICES_FOR_SUPPORTED_VIRTUAL_SCREENS_APPLE = 0x10000003;
65
66 /** Error code returned by clGetGLContextInfoAPPLE if an invalid platform_gl_ctx is provided */
67 int CL_INVALID_GL_CONTEXT_APPLE = -1000;
68
69 @Code(
70 javaBeforeNative = "\t\tif ( param_value_size_ret == null && APIUtil.isDevicesParam(param_name) ) param_value_size_ret = APIUtil.getBufferPointer();",
71 javaAfterNative = "\t\tif ( __result == CL10.CL_SUCCESS && param_value != null && APIUtil.isDevicesParam(param_name) ) context.getParent().registerCLDevices(param_value, param_value_size_ret);"
72 )
73 @cl_int
74 int clGetGLContextInfoAPPLE(@PointerWrapper("cl_context") CLContext context,
75 @Check("1") @NativeType("cl_void") PointerBuffer platform_gl_ctx,
76 @NativeType("cl_gl_platform_info") int param_name,
77 @AutoSize(value = "param_value", canBeNull = true) @size_t long param_value_size,
78 @OutParameter @Check(canBeNull = true) @cl_void ByteBuffer param_value,
79 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("size_t") PointerBuffer param_value_size_ret);
80
81 }
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.opencl;
32
33 import org.lwjgl.PointerBuffer;
34 import org.lwjgl.util.generator.*;
35 import org.lwjgl.util.generator.opencl.*;
36
37 import java.nio.Buffer;
38 import java.nio.ByteBuffer;
39 import java.nio.IntBuffer;
40
41 /** The core OpenCL 1.0 API */
42 public interface CL10 {
43
44 /** Error Codes */
45 int CL_SUCCESS = 0,
46 CL_DEVICE_NOT_FOUND = -1,
47 CL_DEVICE_NOT_AVAILABLE = -2,
48 CL_COMPILER_NOT_AVAILABLE = -3,
49 CL_MEM_OBJECT_ALLOCATION_FAILURE = -4,
50 CL_OUT_OF_RESOURCES = -5,
51 CL_OUT_OF_HOST_MEMORY = -6,
52 CL_PROFILING_INFO_NOT_AVAILABLE = -7,
53 CL_MEM_COPY_OVERLAP = -8,
54 CL_IMAGE_FORMAT_MISMATCH = -9,
55 CL_IMAGE_FORMAT_NOT_SUPPORTED = -10,
56 CL_BUILD_PROGRAM_FAILURE = -11,
57 CL_MAP_FAILURE = -12,
58
59 CL_INVALID_VALUE = -30,
60 CL_INVALID_DEVICE_TYPE = -31,
61 CL_INVALID_PLATFORM = -32,
62 CL_INVALID_DEVICE = -33,
63 CL_INVALID_CONTEXT = -34,
64 CL_INVALID_QUEUE_PROPERTIES = -35,
65 CL_INVALID_COMMAND_QUEUE = -36,
66 CL_INVALID_HOST_PTR = -37,
67 CL_INVALID_MEM_OBJECT = -38,
68 CL_INVALID_IMAGE_FORMAT_DESCRIPTOR = -39,
69 CL_INVALID_IMAGE_SIZE = -40,
70 CL_INVALID_SAMPLER = -41,
71 CL_INVALID_BINARY = -42,
72 CL_INVALID_BUILD_OPTIONS = -43,
73 CL_INVALID_PROGRAM = -44,
74 CL_INVALID_PROGRAM_EXECUTABLE = -45,
75 CL_INVALID_KERNEL_NAME = -46,
76 CL_INVALID_KERNEL_DEFINITION = -47,
77 CL_INVALID_KERNEL = -48,
78 CL_INVALID_ARG_INDEX = -49,
79 CL_INVALID_ARG_VALUE = -50,
80 CL_INVALID_ARG_SIZE = -51,
81 CL_INVALID_KERNEL_ARGS = -52,
82 CL_INVALID_WORK_DIMENSION = -53,
83 CL_INVALID_WORK_GROUP_SIZE = -54,
84 CL_INVALID_WORK_ITEM_SIZE = -55,
85 CL_INVALID_GLOBAL_OFFSET = -56,
86 CL_INVALID_EVENT_WAIT_LIST = -57,
87 CL_INVALID_EVENT = -58,
88 CL_INVALID_OPERATION = -59,
89 CL_INVALID_GL_OBJECT = -60,
90 CL_INVALID_BUFFER_SIZE = -61,
91 CL_INVALID_MIP_LEVEL = -62,
92 CL_INVALID_GLOBAL_WORK_SIZE = -63;
93
94 /** OpenCL Version */
95 int CL_VERSION_1_0 = 1;
96
97 /** cl_bool */
98 int CL_FALSE = 0,
99 CL_TRUE = 1;
100
101 /** cl_platform_info */
102 int CL_PLATFORM_PROFILE = 0x0900,
103 CL_PLATFORM_VERSION = 0x0901,
104 CL_PLATFORM_NAME = 0x0902,
105 CL_PLATFORM_VENDOR = 0x0903,
106 CL_PLATFORM_EXTENSIONS = 0x0904;
107
108 /** cl_device_type - bitfield */
109 int CL_DEVICE_TYPE_DEFAULT = (1 << 0),
110 CL_DEVICE_TYPE_CPU = (1 << 1),
111 CL_DEVICE_TYPE_GPU = (1 << 2),
112 CL_DEVICE_TYPE_ACCELERATOR = (1 << 3),
113 CL_DEVICE_TYPE_ALL = 0xFFFFFFFF;
114
115 /** cl_device_info */
116 int CL_DEVICE_TYPE = 0x1000,
117 CL_DEVICE_VENDOR_ID = 0x1001,
118 CL_DEVICE_MAX_COMPUTE_UNITS = 0x1002,
119 CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS = 0x1003,
120 CL_DEVICE_MAX_WORK_GROUP_SIZE = 0x1004,
121 CL_DEVICE_MAX_WORK_ITEM_SIZES = 0x1005,
122 CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR = 0x1006,
123 CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT = 0x1007,
124 CL_DEVICE_PREFERRED_VECTOR_WIDTH_ = 0x1008,
125 CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG = 0x1009,
126 CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT = 0x100A,
127 CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE = 0x100B,
128 CL_DEVICE_MAX_CLOCK_FREQUENCY = 0x100C,
129 CL_DEVICE_ADDRESS_BITS = 0x100D,
130 CL_DEVICE_MAX_READ_IMAGE_ARGS = 0x100E,
131 CL_DEVICE_MAX_WRITE_IMAGE_ARGS = 0x100F,
132 CL_DEVICE_MAX_MEM_ALLOC_SIZE = 0x1010,
133 CL_DEVICE_IMAGE2D_MAX_WIDTH = 0x1011,
134 CL_DEVICE_IMAGE2D_MAX_HEIGHT = 0x1012,
135 CL_DEVICE_IMAGE3D_MAX_WIDTH = 0x1013,
136 CL_DEVICE_IMAGE3D_MAX_HEIGHT = 0x1014,
137 CL_DEVICE_IMAGE3D_MAX_DEPTH = 0x1015,
138 CL_DEVICE_IMAGE_SUPPORT = 0x1016,
139 CL_DEVICE_MAX_PARAMETER_SIZE = 0x1017,
140 CL_DEVICE_MAX_SAMPLERS = 0x1018,
141 CL_DEVICE_MEM_BASE_ADDR_ALIGN = 0x1019,
142 CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE = 0x101A,
143 CL_DEVICE_SINGLE_FP_CONFIG = 0x101B,
144 CL_DEVICE_GLOBAL_MEM_CACHE_TYPE = 0x101C,
145 CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE = 0x101D,
146 CL_DEVICE_GLOBAL_MEM_CACHE_SIZE = 0x101E,
147 CL_DEVICE_GLOBAL_MEM_SIZE = 0x101F,
148 CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE = 0x1020,
149 CL_DEVICE_MAX_CONSTANT_ARGS = 0x1021,
150 CL_DEVICE_LOCAL_MEM_TYPE = 0x1022,
151 CL_DEVICE_LOCAL_MEM_SIZE = 0x1023,
152 CL_DEVICE_ERROR_CORRECTION_SUPPORT = 0x1024,
153 CL_DEVICE_PROFILING_TIMER_RESOLUTION = 0x1025,
154 CL_DEVICE_ENDIAN_LITTLE = 0x1026,
155 CL_DEVICE_AVAILABLE = 0x1027,
156 CL_DEVICE_COMPILER_AVAILABLE = 0x1028,
157 CL_DEVICE_EXECUTION_CAPABILITIES = 0x1029,
158 CL_DEVICE_QUEUE_PROPERTIES = 0x102A,
159 CL_DEVICE_NAME = 0x102B,
160 CL_DEVICE_VENDOR = 0x102C,
161 CL_DRIVER_VERSION = 0x102D,
162 CL_DEVICE_PROFILE = 0x102E,
163 CL_DEVICE_VERSION = 0x102F,
164 CL_DEVICE_EXTENSIONS = 0x1030,
165 CL_DEVICE_PLATFORM = 0x1031;
166 /* 0x1032 reserved for CL_DEVICE_DOUBLE_FP_CONFIG */
167 /* 0x1033 reserved for CL_DEVICE_HALF_FP_CONFIG */
168
169 /** cl_device_fp_config - bitfield */
170 int CL_FP_DENORM = (1 << 0),
171 CL_FP_INF_NAN = (1 << 1),
172 CL_FP_ROUND_TO_NEAREST = (1 << 2),
173 CL_FP_ROUND_TO_ZERO = (1 << 3),
174 CL_FP_ROUND_TO_INF = (1 << 4),
175 CL_FP_FMA = (1 << 5);
176
177 /** cl_device_mem_cache_type */
178 int CL_NONE = 0x0,
179 CL_READ_ONLY_CACHE = 0x1,
180 CL_READ_WRITE_CACHE = 0x2;
181
182 /** cl_device_local_mem_type */
183 int CL_LOCAL = 0x1,
184 CL_GLOBAL = 0x2;
185
186 /** cl_device_exec_capabilities - bitfield */
187 int CL_EXEC_KERNEL = (1 << 0),
188 CL_EXEC_NATIVE_KERNEL = (1 << 1);
189
190 /** cl_command_queue_properties - bitfield */
191 int CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE = (1 << 0),
192 CL_QUEUE_PROFILING_ENABLE = (1 << 1);
193
194 /** cl_context_info */
195 int CL_CONTEXT_REFERENCE_COUNT = 0x1080,
196 CL_CONTEXT_DEVICES = 0x1081,
197 CL_CONTEXT_PROPERTIES = 0x1082;
198
199 /** cl_context_info + cl_context_properties */
200 int CL_CONTEXT_PLATFORM = 0x1084;
201
202 /** cl_command_queue_info */
203 int CL_QUEUE_CONTEXT = 0x1090,
204 CL_QUEUE_DEVICE = 0x1091,
205 CL_QUEUE_REFERENCE_COUNT = 0x1092,
206 CL_QUEUE_PROPERTIES = 0x1093;
207
208 /** cl_mem_flags - bitfield */
209 int CL_MEM_READ_WRITE = (1 << 0),
210 CL_MEM_WRITE_ONLY = (1 << 1),
211 CL_MEM_READ_ONLY = (1 << 2),
212 CL_MEM_USE_HOST_PTR = (1 << 3),
213 CL_MEM_ALLOC_HOST_PTR = (1 << 4),
214 CL_MEM_COPY_HOST_PTR = (1 << 5);
215
216 /** cl_channel_order */
217 int CL_R = 0x10B0,
218 CL_A = 0x10B1,
219 CL_RG = 0x10B2,
220 CL_RA = 0x10B3,
221 CL_RGB = 0x10B4,
222 CL_RGBA = 0x10B5,
223 CL_BGRA = 0x10B6,
224 CL_ARGB = 0x10B7,
225 CL_INTENSITY = 0x10B8,
226 CL_LUMINANCE = 0x10B9;
227
228 /** cl_channel_type */
229 int CL_SNORM_INT8 = 0x10D0,
230 CL_SNORM_INT16 = 0x10D1,
231 CL_UNORM_INT8 = 0x10D2,
232 CL_UNORM_INT16 = 0x10D3,
233 CL_UNORM_SHORT_565 = 0x10D4,
234 CL_UNORM_SHORT_555 = 0x10D5,
235 CL_UNORM_INT_101010 = 0x10D6,
236 CL_SIGNED_INT8 = 0x10D7,
237 CL_SIGNED_INT16 = 0x10D8,
238 CL_SIGNED_INT32 = 0x10D9,
239 CL_UNSIGNED_INT8 = 0x10DA,
240 CL_UNSIGNED_INT16 = 0x10DB,
241 CL_UNSIGNED_INT32 = 0x10DC,
242 CL_HALF_FLOAT = 0x10DD,
243 CL_FLOAT = 0x10DE;
244
245 /** cl_mem_object_type */
246 int CL_MEM_OBJECT_BUFFER = 0x10F0,
247 CL_MEM_OBJECT_IMAGE2D = 0x10F1,
248 CL_MEM_OBJECT_IMAGE3D = 0x10F2;
249
250 /** cl_mem_info */
251 int CL_MEM_TYPE = 0x1100,
252 CL_MEM_FLAGS = 0x1101,
253 CL_MEM_SIZE = 0x1102,
254 CL_MEM_HOST_PTR = 0x1103,
255 CL_MEM_MAP_COUNT = 0x1104,
256 CL_MEM_REFERENCE_COUNT = 0x1105,
257 CL_MEM_CONTEXT = 0x1106;
258
259 /** cl_image_info */
260 int CL_IMAGE_FORMAT = 0x1110,
261 CL_IMAGE_ELEMENT_SIZE = 0x1111,
262 CL_IMAGE_ROW_PITCH = 0x1112,
263 CL_IMAGE_SLICE_PITCH = 0x1113,
264 CL_IMAGE_WIDTH = 0x1114,
265 CL_IMAGE_HEIGHT = 0x1115,
266 CL_IMAGE_DEPTH = 0x1116;
267
268 /** cl_addressing_mode */
269 int CL_ADDRESS_NONE = 0x1130,
270 CL_ADDRESS_CLAMP_TO_EDGE = 0x1131,
271 CL_ADDRESS_CLAMP = 0x1132,
272 CL_ADDRESS_REPEAT = 0x1133;
273
274 /** cl_filter_mode */
275 int CL_FILTER_NEAREST = 0x1140,
276 CL_FILTER_LINEAR = 0x1141;
277
278 /** cl_sampler_info */
279 int CL_SAMPLER_REFERENCE_COUNT = 0x1150,
280 CL_SAMPLER_CONTEXT = 0x1151,
281 CL_SAMPLER_NORMALIZED_COORDS = 0x1152,
282 CL_SAMPLER_ADDRESSING_MODE = 0x1153,
283 CL_SAMPLER_FILTER_MODE = 0x1154;
284
285 /** cl_map_flags - bitfield */
286 int CL_MAP_READ = (1 << 0),
287 CL_MAP_WRITE = (1 << 1);
288
289 /** cl_program_info */
290 int CL_PROGRAM_REFERENCE_COUNT = 0x1160,
291 CL_PROGRAM_CONTEXT = 0x1161,
292 CL_PROGRAM_NUM_DEVICES = 0x1162,
293 CL_PROGRAM_DEVICES = 0x1163,
294 CL_PROGRAM_SOURCE = 0x1164,
295 CL_PROGRAM_BINARY_SIZES = 0x1165,
296 CL_PROGRAM_BINARIES = 0x1166;
297
298 /** cl_program_build_info */
299 int CL_PROGRAM_BUILD_STATUS = 0x1181,
300 CL_PROGRAM_BUILD_OPTIONS = 0x1182,
301 CL_PROGRAM_BUILD_LOG = 0x1183;
302
303 /** cl_build_status */
304 int CL_BUILD_SUCCESS = 0,
305 CL_BUILD_NONE = -1,
306 CL_BUILD_ERROR = -2,
307 CL_BUILD_IN_PROGRESS = -3;
308
309 /** cl_kernel_info */
310 int CL_KERNEL_FUNCTION_NAME = 0x1190,
311 CL_KERNEL_NUM_ARGS = 0x1191,
312 CL_KERNEL_REFERENCE_COUNT = 0x1192,
313 CL_KERNEL_CONTEXT = 0x1193,
314 CL_KERNEL_PROGRAM = 0x1194;
315
316 /** cl_kernel_work_group_info */
317 int CL_KERNEL_WORK_GROUP_SIZE = 0x11B0,
318 CL_KERNEL_COMPILE_WORK_GROUP_SIZE = 0x11B1,
319 CL_KERNEL_LOCAL_MEM_SIZE = 0x11B2;
320
321 /** cl_event_info */
322 int CL_EVENT_COMMAND_QUEUE = 0x11D0,
323 CL_EVENT_COMMAND_TYPE = 0x11D1,
324 CL_EVENT_REFERENCE_COUNT = 0x11D2,
325 CL_EVENT_COMMAND_EXECUTION_STATUS = 0x11D3;
326
327 /** cl_command_type */
328 int CL_COMMAND_NDRANGE_KERNEL = 0x11F0,
329 CL_COMMAND_TASK = 0x11F1,
330 CL_COMMAND_NATIVE_KERNEL = 0x11F2,
331 CL_COMMAND_READ_BUFFER = 0x11F3,
332 CL_COMMAND_WRITE_BUFFER = 0x11F4,
333 CL_COMMAND_COPY_BUFFER = 0x11F5,
334 CL_COMMAND_READ_IMAGE = 0x11F6,
335 CL_COMMAND_WRITE_IMAGE = 0x11F7,
336 CL_COMMAND_COPY_IMAGE = 0x11F8,
337 CL_COMMAND_COPY_IMAGE_TO_BUFFER = 0x11F9,
338 CL_COMMAND_COPY_BUFFER_TO_IMAGE = 0x11FA,
339 CL_COMMAND_MAP_BUFFER = 0x11FB,
340 CL_COMMAND_MAP_IMAGE = 0x11FC,
341 CL_COMMAND_UNMAP_MEM_OBJECT = 0x11FD,
342 CL_COMMAND_MARKER = 0x11FE,
343 CL_COMMAND_ACQUIRE_GL_OBJECTS = 0x11FF,
344 CL_COMMAND_RELEASE_GL_OBJECTS = 0x1200;
345
346 /** command execution status */
347 int CL_COMPLETE = 0x0,
348 CL_RUNNING = 0x1,
349 CL_SUBMITTED = 0x2,
350 CL_QUEUED = 0x3;
351
352 /** cl_profiling_info */
353 int CL_PROFILING_COMMAND_QUEUED = 0x1280,
354 CL_PROFILING_COMMAND_SUBMIT = 0x1281,
355 CL_PROFILING_COMMAND_START = 0x1282,
356 CL_PROFILING_COMMAND_END = 0x1283;
357
358 /* Platform API */
359
360 @Code(
361 javaBeforeNative = "\t\tif ( num_platforms == null ) num_platforms = APIUtil.getBufferInt();",
362 javaAfterNative = "\t\tif ( __result == CL_SUCCESS && platforms != null ) CLPlatform.registerCLPlatforms(platforms, num_platforms);"
363 )
364 @cl_int
365 int clGetPlatformIDs(@AutoSize(value = "platforms", canBeNull = true) @cl_uint int num_entries,
366 @OutParameter @Check(canBeNull = true) @NativeType("cl_platform_id") PointerBuffer platforms,
367 @OutParameter @Check(value = "1", canBeNull = true) @cl_uint IntBuffer num_platforms);
368
369 @cl_int
370 int clGetPlatformInfo(@PointerWrapper(value = "cl_platform_id", canBeNull = true) CLPlatform platform,
371 @NativeType("cl_platform_info") int param_name,
372 @AutoSize(value = "param_value", canBeNull = true) @size_t long param_value_size,
373 @OutParameter @Check(canBeNull = true) @cl_void ByteBuffer param_value,
374 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("size_t") PointerBuffer param_value_size_ret);
375
376 @Code(
377 javaBeforeNative = "\t\telse\n" +
378 "\t\t\tnum_devices = APIUtil.getBufferInt();",
379 javaAfterNative = "\t\tif ( __result == CL_SUCCESS && devices != null ) platform.registerCLDevices(devices, num_devices);"
380 )
381 @cl_int
382 int clGetDeviceIDs(@PointerWrapper("cl_platform_id") CLPlatform platform,
383 @NativeType("cl_device_type") long device_type,
384 @AutoSize(value = "devices", canBeNull = true) @cl_uint int num_entries,
385 @OutParameter @Check(canBeNull = true) @NativeType("cl_device_id") PointerBuffer devices,
386 @OutParameter @Check(value = "1", canBeNull = true) @cl_uint IntBuffer num_devices);
387
388 @cl_int
389 int clGetDeviceInfo(@PointerWrapper("cl_device_id") CLDevice device,
390 @NativeType("cl_device_info") int param_name,
391 @AutoSize(value = "param_value", canBeNull = true) @size_t long param_value_size,
392 @OutParameter @Check(canBeNull = true) @cl_void ByteBuffer param_value,
393 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("size_t") PointerBuffer param_value_size_ret);
394
395 /** LWJGL requires CL_CONTEXT_PLATFORM to be present in the cl_context_properties buffer. */
396 @Code(
397 tryBlock = true,
398 // Create a GlobalRef to the callback object.
399 javaBeforeNative = "\t\tlong user_data = pfn_notify == null || pfn_notify.isCustom() ? 0 : CallbackUtil.createGlobalRef(pfn_notify);",
400 // Associate context with the GlobalRef, so we can delete it later.
401 javaFinally = "\t\t\tCallbackUtil.registerCallback(__result, user_data);"
402 )
403 @Check(value = "errcode_ret", canBeNull = true)
404 @PointerWrapper(value = "cl_context", params = "APIUtil.getCLPlatform(properties)")
405 CLContext clCreateContext(@NullTerminated @Check("3") @Const @NativeType("cl_context_properties") PointerBuffer properties,
406 @AutoSize("devices") @cl_uint int num_devices,
407 @Check("1") @Const @NativeType("cl_device_id") PointerBuffer devices,
408 @PointerWrapper(value = "cl_create_context_callback", canBeNull = true) CLContextCallback pfn_notify,
409 @Constant("user_data") @PointerWrapper("void *") long user_data,
410 @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret);
411
412 /** LWJGL requires CL_CONTEXT_PLATFORM to be present in the cl_context_properties buffer. */
413 @Alternate("clCreateContext")
414 @Code(
415 tryBlock = true,
416 // Create a GlobalRef to the callback object.
417 javaBeforeNative = "\t\tlong user_data = pfn_notify == null || pfn_notify.isCustom() ? 0 : CallbackUtil.createGlobalRef(pfn_notify);",
418 // Associate context with the GlobalRef, so we can delete it later.
419 javaFinally = "\t\t\tCallbackUtil.registerCallback(__result, user_data);"
420 )
421 @Check(value = "errcode_ret", canBeNull = true)
422 @PointerWrapper(value = "cl_context", params = "APIUtil.getCLPlatform(properties)")
423 CLContext clCreateContext(@NullTerminated @Check("3") @Const @NativeType("cl_context_properties") PointerBuffer properties,
424 @Constant("1") @cl_uint int num_devices,
425 @Constant(value = "APIUtil.getBufferPointer().put(0, device).getBuffer(), 0", keepParam = true) CLDevice device,
426 @PointerWrapper(value = "cl_create_context_callback", canBeNull = true) CLContextCallback pfn_notify,
427 @Constant("user_data") @PointerWrapper("void *") long user_data,
428 @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret);
429
430 /** LWJGL requires CL_CONTEXT_PLATFORM to be present in the cl_context_properties buffer. */
431 @Code(
432 tryBlock = true,
433 // Create a GlobalRef to the callback object.
434 javaBeforeNative = "\t\tlong user_data = CallbackUtil.createGlobalRef(pfn_notify);",
435 // Associate context with the GlobalRef, so we can delete it later.
436 javaFinally = "\t\t\tCallbackUtil.registerCallback(__result, user_data);"
437 )
438 @Check(value = "errcode_ret", canBeNull = true)
439 @PointerWrapper(value = "cl_context", params = "APIUtil.getCLPlatform(properties)")
440 CLContext clCreateContextFromType(@NullTerminated @Check("3") @Const @NativeType("cl_context_properties") PointerBuffer properties,
441 @NativeType("cl_device_type") long device_type,
442 @PointerWrapper(value = "cl_create_context_callback", canBeNull = true) CLContextCallback pfn_notify,
443 @Constant("user_data") @PointerWrapper("void *") long user_data,
444 @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret);
445
446 @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) context.retain();")
447 @cl_int
448 int clRetainContext(@PointerWrapper("cl_context") CLContext context);
449
450 @Code(
451 javaBeforeNative = "\t\tAPIUtil.releaseObjects(context);",
452 javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) CallbackUtil.unregisterCallback(context);"
453 )
454 @cl_int
455 int clReleaseContext(@PointerWrapper("cl_context") CLContext context);
456
457 @Code(
458 javaBeforeNative = "\t\tif ( param_value_size_ret == null && APIUtil.isDevicesParam(param_name) ) param_value_size_ret = APIUtil.getBufferPointer();",
459 javaAfterNative = "\t\tif ( __result == CL_SUCCESS && param_value != null && APIUtil.isDevicesParam(param_name) ) context.getParent().registerCLDevices(param_value, param_value_size_ret);"
460 )
461 @cl_int
462 int clGetContextInfo(@PointerWrapper("cl_context") CLContext context,
463 @NativeType("cl_context_info") int param_name,
464 @AutoSize(value = "param_value", canBeNull = true) @size_t long param_value_size,
465 @OutParameter @Check(canBeNull = true) @cl_void ByteBuffer param_value,
466 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("size_t") PointerBuffer param_value_size_ret);
467
468 @Check(value = "errcode_ret", canBeNull = true)
469 @PointerWrapper(value = "cl_command_queue", params = "context, device")
470 CLCommandQueue clCreateCommandQueue(@PointerWrapper("cl_context") CLContext context,
471 @PointerWrapper("cl_device_id") CLDevice device,
472 @NativeType("cl_command_queue_properties") long properties,
473 @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret);
474
475 @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) command_queue.retain();")
476 @cl_int
477 int clRetainCommandQueue(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue);
478
479 @Code(
480 javaBeforeNative = "\t\tAPIUtil.releaseObjects(command_queue);",
481 javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) command_queue.release();"
482 )
483 @cl_int
484 int clReleaseCommandQueue(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue);
485
486 @cl_int
487 int clGetCommandQueueInfo(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue,
488 @NativeType("cl_command_queue_info") int param_name,
489 @AutoSize(value = "param_value", canBeNull = true) @size_t long param_value_size,
490 @OutParameter @Check(canBeNull = true) @cl_void ByteBuffer param_value,
491 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("size_t") PointerBuffer param_value_size_ret);
492
493 @GenerateAutos
494 @Check(value = "errcode_ret", canBeNull = true)
495 @PointerWrapper(value = "cl_mem", params = "context")
496 CLMem clCreateBuffer(@PointerWrapper("cl_context") CLContext context,
497 @NativeType("cl_mem_flags") long flags,
498 @AutoSize("host_ptr") @size_t long size,
499 @cl_byte
500 @cl_short
501 @cl_int
502 @cl_long
503 @cl_float
504 @cl_double Buffer host_ptr,
505 @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret);
506
507 @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) command_queue.registerCLEvent(event);")
508 @cl_int
509 int clEnqueueReadBuffer(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue,
510 @PointerWrapper("cl_mem") CLMem buffer,
511 @cl_bool int blocking_read,
512 @size_t long offset,
513 @AutoSize("ptr") @size_t long cb,
514 @OutParameter
515 @cl_byte
516 @cl_short
517 @cl_int
518 @cl_long
519 @cl_float
520 @cl_double Buffer ptr,
521 @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list,
522 @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list,
523 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event);
524
525 @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) command_queue.registerCLEvent(event);")
526 @cl_int
527 int clEnqueueWriteBuffer(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue,
528 @PointerWrapper("cl_mem") CLMem buffer,
529 @cl_bool int blocking_write,
530 @size_t long offset,
531 @AutoSize("ptr") @size_t long cb,
532 @Const
533 @cl_byte
534 @cl_short
535 @cl_int
536 @cl_long
537 @cl_float
538 @cl_double Buffer ptr,
539 @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list,
540 @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list,
541 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event);
542
543 @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) command_queue.registerCLEvent(event);")
544 @cl_int
545 int clEnqueueCopyBuffer(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue,
546 @PointerWrapper("cl_mem") CLMem src_buffer,
547 @PointerWrapper("cl_mem") CLMem dst_buffer,
548 @size_t long src_offset,
549 @size_t long dst_offset,
550 @size_t long cb,
551 @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list,
552 @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list,
553 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event);
554
555 @Code(javaAfterNative = "\t\tif ( __result != null ) command_queue.registerCLEvent(event);")
556 @Check(value = "errcode_ret", canBeNull = true)
557 @cl_void
558 @AutoSize("cb")
559 ByteBuffer clEnqueueMapBuffer(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue,
560 @PointerWrapper("cl_mem") CLMem buffer,
561 @cl_bool int blocking_map,
562 @NativeType("cl_map_flags") long map_flags,
563 @size_t long offset,
564 @size_t long cb,
565 @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list,
566 @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list,
567 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event,
568 @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret);
569
570 @Check(value = "errcode_ret", canBeNull = true)
571 @PointerWrapper(value = "cl_mem", params = "context")
572 CLMem clCreateImage2D(@PointerWrapper("cl_context") CLContext context,
573 @NativeType("cl_mem_flags") long flags,
574 @Check("2 * 4") @Const @NativeType("cl_image_format") ByteBuffer image_format,
575 @size_t long image_width,
576 @size_t long image_height,
577 @size_t long image_row_pitch,
578 @Check(value = "CLChecks.calculateImage2DSize(image_format, image_width, image_height, image_row_pitch)", canBeNull = true)
579 @cl_byte
580 @cl_short
581 @cl_int
582 @cl_float Buffer host_ptr,
583 @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret);
584
585 @Check(value = "errcode_ret", canBeNull = true)
586 @PointerWrapper(value = "cl_mem", params = "context")
587 CLMem clCreateImage3D(@PointerWrapper("cl_context") CLContext context,
588 @NativeType("cl_mem_flags") long flags,
589 @Check("2 * 4") @Const @NativeType("cl_image_format") ByteBuffer image_format,
590 @size_t long image_width,
591 @size_t long image_height,
592 @size_t long image_depth,
593 @size_t long image_row_pitch,
594 @size_t long image_slice_pitch,
595 @Check(value = "CLChecks.calculateImage3DSize(image_format, image_width, image_height, image_height, image_row_pitch, image_slice_pitch)", canBeNull = true)
596 @cl_byte
597 @cl_short
598 @cl_int
599 @cl_float Buffer host_ptr,
600 @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret);
601
602 @cl_int
603 int clGetSupportedImageFormats(@PointerWrapper("cl_context") CLContext context,
604 @NativeType("cl_mem_flags") long flags,
605 @NativeType("cl_mem_object_type") int image_type,
606 @AutoSize(value = "image_formats", expression = " / (2 * 4)", canBeNull = true) @cl_uint int num_entries,
607 @OutParameter @Check(canBeNull = true) @NativeType("cl_image_format") ByteBuffer image_formats,
608 @OutParameter @Check(value = "1", canBeNull = true) @cl_uint IntBuffer num_image_formats);
609
610 @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) command_queue.registerCLEvent(event);")
611 @cl_int
612 int clEnqueueReadImage(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue,
613 @PointerWrapper("cl_mem") CLMem image,
614 @cl_bool int blocking_read,
615 @Check("3") @Const @NativeType("size_t") PointerBuffer origin,
616 @Check("3") @Const @NativeType("size_t") PointerBuffer region,
617 @size_t long row_pitch,
618 @size_t long slice_pitch,
619 @OutParameter @Check("CLChecks.calculateImageSize(region, row_pitch, slice_pitch)")
620 @cl_byte
621 @cl_short
622 @cl_int
623 @cl_float Buffer ptr,
624 @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list,
625 @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list,
626 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event);
627
628 @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) command_queue.registerCLEvent(event);")
629 @cl_int
630 int clEnqueueWriteImage(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue,
631 @PointerWrapper("cl_mem") CLMem image,
632 @cl_bool int blocking_write,
633 @Check("3") @Const @NativeType("size_t") PointerBuffer origin,
634 @Check("3") @Const @NativeType("size_t") PointerBuffer region,
635 @size_t long input_row_pitch,
636 @size_t long input_slice_pitch,
637 @Check("CLChecks.calculateImageSize(region, input_row_pitch, input_slice_pitch)") @Const
638 @cl_byte
639 @cl_short
640 @cl_int
641 @cl_float Buffer ptr,
642 @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list,
643 @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list,
644 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event);
645
646 @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) command_queue.registerCLEvent(event);")
647 @cl_int
648 int clEnqueueCopyImage(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue,
649 @PointerWrapper("cl_mem") CLMem src_image,
650 @PointerWrapper("cl_mem") CLMem dst_image,
651 @Check("3") @Const @NativeType("size_t") PointerBuffer src_origin,
652 @Check("3") @Const @NativeType("size_t") PointerBuffer dst_origin,
653 @Check("3") @Const @NativeType("size_t") PointerBuffer region,
654 @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list,
655 @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list,
656 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event);
657
658 @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) command_queue.registerCLEvent(event);")
659 @cl_int
660 int clEnqueueCopyImageToBuffer(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue,
661 @PointerWrapper("cl_mem") CLMem src_image,
662 @PointerWrapper("cl_mem") CLMem dst_buffer,
663 @Check("3") @Const @NativeType("size_t") PointerBuffer src_origin,
664 @Check("3") @Const @NativeType("size_t") PointerBuffer region,
665 @size_t long dst_offset,
666 @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list,
667 @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list,
668 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event);
669
670 @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) command_queue.registerCLEvent(event);")
671 @cl_int
672 int clEnqueueCopyBufferToImage(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue,
673 @PointerWrapper("cl_mem") CLMem src_buffer,
674 @PointerWrapper("cl_mem") CLMem dst_image,
675 @size_t long src_offset,
676 @Check("3") @Const @NativeType("size_t") PointerBuffer dst_origin,
677 @Check("3") @Const @NativeType("size_t") PointerBuffer region,
678 @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list,
679 @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list,
680 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event);
681
682 @Code(javaAfterNative = "\t\tif ( __result != null ) command_queue.registerCLEvent(event);")
683 @Check(value = "errcode_ret", canBeNull = true)
684 @cl_void
685 @AutoSize(value = "extcl_CalculateImageSize(region_address, *image_row_pitch_address, image_slice_pitch == NULL ? 0 : *image_slice_pitch_address)", isNative = true)
686 ByteBuffer clEnqueueMapImage(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue,
687 @PointerWrapper("cl_mem") CLMem image,
688 @cl_bool int blocking_map,
689 @NativeType("cl_map_flags") long map_flags,
690 @Check("3") @Const @NativeType("size_t") PointerBuffer origin,
691 @Check("3") @Const @NativeType("size_t") PointerBuffer region,
692 @OutParameter @Check("1") @NativeType("size_t") PointerBuffer image_row_pitch,
693 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("size_t") PointerBuffer image_slice_pitch,
694 @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list,
695 @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list,
696 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event,
697 @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret);
698
699 @cl_int
700 int clGetImageInfo(@PointerWrapper("cl_mem") CLMem image,
701 @NativeType("cl_image_info") int param_name,
702 @AutoSize(value = "param_value", canBeNull = true) @size_t long param_value_size,
703 @OutParameter @Check(canBeNull = true) @cl_void ByteBuffer param_value,
704 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("size_t") PointerBuffer param_value_size_ret);
705
706 @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) memobj.retain();")
707 @cl_int
708 int clRetainMemObject(@PointerWrapper("cl_mem") CLMem memobj);
709
710 @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) memobj.release();")
711 @cl_int
712 int clReleaseMemObject(@PointerWrapper("cl_mem") CLMem memobj);
713
714 @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) command_queue.registerCLEvent(event);")
715 @cl_int
716 int clEnqueueUnmapMemObject(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue,
717 @PointerWrapper("cl_mem") CLMem memobj,
718 @Check @cl_void ByteBuffer mapped_ptr,
719 @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list,
720 @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list,
721 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event);
722
723 @cl_int
724 int clGetMemObjectInfo(@PointerWrapper("cl_mem") CLMem memobj,
725 @NativeType("cl_mem_info") int param_name,
726 @AutoSize(value = "param_value", canBeNull = true) @size_t long param_value_size,
727 @OutParameter @Check(canBeNull = true) @cl_void ByteBuffer param_value,
728 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("size_t") PointerBuffer param_value_size_ret);
729
730 @Check(value = "errcode_ret", canBeNull = true)
731 @PointerWrapper(value = "cl_sampler", params = "context")
732 CLSampler clCreateSampler(@PointerWrapper("cl_context") CLContext context,
733 @cl_bool int normalized_coords,
734 @NativeType("cl_addressing_mode") int addressing_mode,
735 @NativeType("cl_filter_mode") int filter_mode,
736 @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret);
737
738 @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) sampler.retain();")
739 @cl_int
740 int clRetainSampler(@PointerWrapper("cl_sampler") CLSampler sampler);
741
742 @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) sampler.release();")
743 @cl_int
744 int clReleaseSampler(@PointerWrapper("cl_sampler") CLSampler sampler);
745
746 @cl_int
747 int clGetSamplerInfo(@PointerWrapper("cl_sampler") CLSampler sampler,
748 @NativeType("cl_sampler_info") int param_name,
749 @AutoSize(value = "param_value", canBeNull = true) @size_t long param_value_size,
750 @OutParameter @Check(canBeNull = true) @cl_void ByteBuffer param_value,
751 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("size_t") PointerBuffer param_value_size_ret);
752
753 // ------[ clCreateProgramWithSource ]------
754
755 @Check(value = "errcode_ret", canBeNull = true)
756 @PointerWrapper(value = "cl_program", params = "context")
757 CLProgram clCreateProgramWithSource(@PointerWrapper("cl_context") CLContext context,
758 @Constant("1") @cl_uint int count,
759 @Check @Indirect @Const @cl_char ByteBuffer string,
760 @AutoSize("string") @Indirect @Const @size_t long lengths,
761 @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret);
762
763 @Alternate(value = "clCreateProgramWithSource", nativeAlt = true)
764 @Check(value = "errcode_ret", canBeNull = true)
765 @PointerWrapper(value = "cl_program", params = "context")
766 CLProgram clCreateProgramWithSource2(@PointerWrapper("cl_context") CLContext context,
767 @AutoSize("lengths") @cl_uint int count,
768 @Check("APIUtil.getSize(lengths)") @PointerArray(value = "count", lengths = "lengths") @Const @NativeType("cl_char") ByteBuffer strings,
769 @Check("1") @Const @NativeType("size_t") PointerBuffer lengths,
770 @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret);
771
772 @Alternate(value = "clCreateProgramWithSource", nativeAlt = true)
773 @Check(value = "errcode_ret", canBeNull = true)
774 @PointerWrapper(value = "cl_program", params = "context")
775 CLProgram clCreateProgramWithSource3(@PointerWrapper("cl_context") CLContext context,
776 @Constant("strings.length") @cl_uint int count,
777 @Check("1") @PointerArray(value = "count") @Const @NativeType("cl_char") ByteBuffer[] strings,
778 @Constant("APIUtil.getLengths(strings).getBuffer(), 0") @Const @NativeType("size_t") PointerBuffer lengths,
779 @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret);
780
781 @Alternate("clCreateProgramWithSource")
782 @Check(value = "errcode_ret", canBeNull = true)
783 @PointerWrapper(value = "cl_program", params = "context")
784 CLProgram clCreateProgramWithSource(@PointerWrapper("cl_context") CLContext context,
785 @Constant("1") @cl_uint int count,
786 CharSequence string,
787 @Constant("string.length()") @Indirect @Const @size_t long lengths,
788 @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret);
789
790 @Alternate(value = "clCreateProgramWithSource", nativeAlt = true)
791 @Check(value = "errcode_ret", canBeNull = true)
792 @PointerWrapper(value = "cl_program", params = "context")
793 CLProgram clCreateProgramWithSource4(@PointerWrapper("cl_context") CLContext context,
794 @Constant("strings.length") @cl_uint int count,
795 @Const @PointerArray(value = "count", lengths = "lengths") CharSequence[] strings,
796 @Constant("APIUtil.getLengths(strings).getBuffer(), 0") @Const @NativeType("size_t") PointerBuffer lengths,
797 @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret);
798
799 // ------[ clCreateProgramWithBinary ]------
800
801 @Check(value = "errcode_ret", canBeNull = true)
802 @PointerWrapper(value = "cl_program", params = "context")
803 CLProgram clCreateProgramWithBinary(@PointerWrapper("cl_context") CLContext context,
804 @Constant("1") @cl_uint int num_devices,
805 @Const @Indirect @PointerWrapper("cl_device_id") CLDevice device,
806 @AutoSize("binary") @Const @Indirect @size_t long lengths,
807 @Const @Indirect @cl_uchar ByteBuffer binary,
808 @OutParameter @Check("1") @cl_int IntBuffer binary_status,
809 @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret);
810
811 @Alternate(value = "clCreateProgramWithBinary", nativeAlt = true)
812 @Check(value = "errcode_ret", canBeNull = true)
813 @PointerWrapper(value = "cl_program", params = "context")
814 CLProgram clCreateProgramWithBinary2(@PointerWrapper("cl_context") CLContext context,
815 @AutoSize("device_list") @cl_uint int num_devices,
816 @Check("1") @Const @NativeType("cl_device_id") PointerBuffer device_list,
817 @Check("device_list.remaining()") @Const @NativeType("size_t") PointerBuffer lengths,
818 @Check("APIUtil.getSize(lengths)") @PointerArray(value = "num_devices", lengths = "lengths") @Const @NativeType("cl_uchar") ByteBuffer binaries,
819 @OutParameter @Check("device_list.remaining()") @cl_int IntBuffer binary_status,
820 @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret);
821
822 @Alternate(value = "clCreateProgramWithBinary", nativeAlt = true)
823 @Check(value = "errcode_ret", canBeNull = true)
824 @PointerWrapper(value = "cl_program", params = "context")
825 CLProgram clCreateProgramWithBinary3(@PointerWrapper("cl_context") CLContext context,
826 @Constant("binaries.length") @cl_uint int num_devices,
827 @Check("binaries.length") @Const @NativeType("cl_device_id") PointerBuffer device_list,
828 @Constant("APIUtil.getLengths(binaries).getBuffer(), 0") @Const @NativeType("size_t") PointerBuffer lengths,
829 @Check("1") @PointerArray("num_devices") @Const @NativeType("cl_uchar") ByteBuffer[] binaries,
830 @OutParameter @Check("binaries.length") @cl_int IntBuffer binary_status,
831 @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret);
832
833 @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) program.retain();")
834 @cl_int
835 int clRetainProgram(@PointerWrapper("cl_program") CLProgram program);
836
837 @Code(
838 javaBeforeNative = "\t\tAPIUtil.releaseObjects(program);",
839 javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) program.release();"
840 )
841 @cl_int
842 int clReleaseProgram(@PointerWrapper("cl_program") CLProgram program);
843
844 @Code(
845 tryBlock = true,
846 // Create a GlobalRef to the callback object.
847 javaBeforeNative = "\t\tlong user_data = CallbackUtil.createGlobalRef(pfn_notify);",
848 // Check if we need to delete the GlobalRef.
849 javaFinally = "\t\t\tCallbackUtil.checkCallback(__result, user_data);"
850 )
851 @cl_int
852 int clBuildProgram(@PointerWrapper("cl_program") CLProgram program,
853 @AutoSize(value = "device_list", canBeNull = true) @cl_uint int num_devices,
854 @Check(canBeNull = true) @Const @NativeType("cl_device_id") PointerBuffer device_list,
855 @Check @NullTerminated @Const @cl_char ByteBuffer options,
856 @PointerWrapper(value = "cl_build_program_callback", canBeNull = true) CLBuildProgramCallback pfn_notify,
857 @Constant("user_data") @PointerWrapper("void *") long user_data);
858
859 @Alternate("clBuildProgram")
860 @Code(
861 tryBlock = true,
862 // Create a GlobalRef to the callback object.
863 javaBeforeNative = "\t\tlong user_data = CallbackUtil.createGlobalRef(pfn_notify);",
864 // Check if we need to delete the GlobalRef.
865 javaFinally = "\t\t\tCallbackUtil.checkCallback(__result, user_data);"
866 )
867 @cl_int
868 int clBuildProgram(@PointerWrapper("cl_program") CLProgram program,
869 @AutoSize(value = "device_list", canBeNull = true) @cl_uint int num_devices,
870 @Check(canBeNull = true) @Const @NativeType("cl_device_id") PointerBuffer device_list,
871 @NullTerminated @Const CharSequence options,
872 @PointerWrapper(value = "cl_build_program_callback", canBeNull = true) CLBuildProgramCallback pfn_notify,
873 @Constant("user_data") @PointerWrapper("void *") long user_data);
874
875 @Alternate("clBuildProgram")
876 @Code(
877 tryBlock = true,
878 // Create a GlobalRef to the callback object.
879 javaBeforeNative = "\t\tlong user_data = CallbackUtil.createGlobalRef(pfn_notify);",
880 // Check if we need to delete the GlobalRef.
881 javaFinally = "\t\t\tCallbackUtil.checkCallback(__result, user_data);"
882 )
883 @cl_int
884 int clBuildProgram(@PointerWrapper("cl_program") CLProgram program,
885 @Constant("1") @cl_uint int num_devices,
886 @Constant(value = "APIUtil.getBufferPointer().put(0, device).getBuffer(), 0", keepParam = true) CLDevice device,
887 @NullTerminated @Const CharSequence options,
888 @PointerWrapper(value = "cl_build_program_callback", canBeNull = true) CLBuildProgramCallback pfn_notify,
889 @Constant("user_data") @PointerWrapper("void *") long user_data);
890
891 @cl_int
892 int clUnloadCompiler();
893
894 @cl_int
895 int clGetProgramInfo(@PointerWrapper("cl_program") CLProgram program,
896 @NativeType("cl_program_info") int param_name,
897 @AutoSize(value = "param_value", canBeNull = true) @size_t long param_value_size,
898 @OutParameter @Check(canBeNull = true) @cl_void ByteBuffer param_value,
899 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("size_t") PointerBuffer param_value_size_ret);
900
901 /**
902 * This method can be used to get program binaries. The binary for each device (in the
903 * order returned by <code>CL_PROGRAM_DEVICES</code>) will be written sequentially to
904 * the <code>param_value</code> buffer. The buffer size must be big enough to hold
905 * all the binaries, as returned by <code>CL_PROGRAM_BINARY_SIZES</code>.
906 *
907 * @param program the program
908 * @param param_value the buffers where the binaries will be written to.
909 * @param param_value_size_ret optional size result
910 *
911 * @return the error code
912 */
913 @Alternate(value = "clGetProgramInfo", nativeAlt = true)
914 @cl_int
915 int clGetProgramInfo2(@PointerWrapper("cl_program") CLProgram program,
916 @Constant("CL_PROGRAM_BINARIES") @NativeType("cl_program_info") int param_name,
917 @Constant("sizes.remainingByte()") @size_t long param_value_size,
918 @Helper(passToNative = true) @Check("1") @Const @NativeType("size_t") PointerBuffer sizes,
919 @OutParameter @Check("APIUtil.getSize(sizes)") @PointerArray(value = "param_value_size", lengths = "sizes") @NativeType("cl_uchar") ByteBuffer param_value,
920 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("size_t") PointerBuffer param_value_size_ret);
921
922 /**
923 * This method can be used to get program binaries. The binary for each device (in the
924 * order returned by <code>CL_PROGRAM_DEVICES</code>) will be written to the corresponding
925 * slot of the <code>param_value</code> array. The size of each buffer must be big enough to
926 * hold the corresponding binary, as returned by <code>CL_PROGRAM_BINARY_SIZES</code>.
927 *
928 * @param program the program
929 * @param param_value the buffers where the binaries will be written to.
930 * @param param_value_size_ret optional size result
931 *
932 * @return the error code
933 */
934 @Alternate(value = "clGetProgramInfo", nativeAlt = true)
935 @cl_int
936 int clGetProgramInfo3(@PointerWrapper("cl_program") CLProgram program,
937 @Constant("CL_PROGRAM_BINARIES") @NativeType("cl_program_info") int param_name,
938 @Constant("param_value.length * PointerBuffer.getPointerSize()") @size_t long param_value_size,
939 @PointerArray("param_value_size") @NativeType("cl_uchar") ByteBuffer[] param_value,
940 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("size_t") PointerBuffer param_value_size_ret);
941
942 @cl_int
943 int clGetProgramBuildInfo(@PointerWrapper("cl_program") CLProgram program,
944 @PointerWrapper("cl_device_id") CLDevice device,
945 @NativeType("cl_program_build_info") int param_name,
946 @AutoSize(value = "param_value", canBeNull = true) @size_t long param_value_size,
947 @OutParameter @Check(canBeNull = true) @cl_void ByteBuffer param_value,
948 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("size_t") PointerBuffer param_value_size_ret);
949
950 @Check(value = "errcode_ret", canBeNull = true)
951 @PointerWrapper(value = "cl_kernel", params = "program")
952 CLKernel clCreateKernel(@PointerWrapper("cl_program") CLProgram program,
953 @NullTerminated @Const @cl_char ByteBuffer kernel_name,
954 @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret);
955
956 @Alternate("clCreateKernel")
957 @Check(value = "errcode_ret", canBeNull = true)
958 @PointerWrapper(value = "cl_kernel", params = "program")
959 CLKernel clCreateKernel(@PointerWrapper("cl_program") CLProgram program,
960 @NullTerminated @Const CharSequence kernel_name,
961 @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret);
962
963 @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS && kernels != null ) program.registerCLKernels(kernels);")
964 @cl_int
965 int clCreateKernelsInProgram(@PointerWrapper("cl_program") CLProgram program,
966 @AutoSize(value = "kernels", canBeNull = true) @cl_uint int num_kernels,
967 @OutParameter @Check(canBeNull = true) @NativeType("cl_kernel") PointerBuffer kernels,
968 @OutParameter @Check(value = "1", canBeNull = true) @cl_uint IntBuffer num_kernels_ret);
969
970 @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) kernel.retain();")
971 @cl_int
972 int clRetainKernel(@PointerWrapper("cl_kernel") CLKernel kernel);
973
974 @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) kernel.release();")
975 @cl_int
976 int clReleaseKernel(@PointerWrapper("cl_kernel") CLKernel kernel);
977
978 @cl_int
979 int clSetKernelArg(@PointerWrapper("cl_kernel") CLKernel kernel,
980 @cl_uint int arg_index,
981 @AutoSize("arg_value") @size_t long arg_size,
982 @Const
983 @cl_byte
984 @cl_short
985 @cl_int
986 @cl_long
987 @cl_float
988 @cl_double Buffer arg_value);
989
990 @Alternate("clSetKernelArg")
991 @cl_int
992 int clSetKernelArg(@PointerWrapper("cl_kernel") CLKernel kernel,
993 @cl_uint int arg_index,
994 @Constant("PointerBuffer.getPointerSize()") @size_t long arg_size,
995 @Check(canBeNull = true) @Const
996 @Constant(value = "APIUtil.getBufferPointer().put(0, arg_value == null ? 0 : arg_value.getPointer()).getBuffer(), 0", keepParam = true) CLObject arg_value);
997
998 /** Sets the size of a __local kernel argument at the specified index. */
999 @Alternate("clSetKernelArg")
1000 @cl_int
1001 int clSetKernelArg2(@PointerWrapper("cl_kernel") CLKernel kernel,
1002 @cl_uint int arg_index,
1003 @size_t long arg_size,
1004 @Constant("null, 0") Buffer arg_value);
1005
1006 // This is used by CLKernelUtil. Assumes arg_value.position() == 0.
1007
1008 @Alternate("clSetKernelArg")
1009 @Private
1010 @cl_int
1011 int clSetKernelArg3(@PointerWrapper("cl_kernel") CLKernel kernel,
1012 @cl_uint int arg_index,
1013 @size_t long arg_size,
1014 @Constant(value = "arg_value, 0", keepParam = true) Buffer arg_value);
1015
1016 @cl_int
1017 int clGetKernelInfo(@PointerWrapper("cl_kernel") CLKernel kernel,
1018 @NativeType("cl_kernel_info") int param_name,
1019 @AutoSize(value = "param_value", canBeNull = true) @size_t long param_value_size,
1020 @OutParameter @Check(canBeNull = true) @cl_void ByteBuffer param_value,
1021 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("size_t") PointerBuffer param_value_size_ret);
1022
1023 @cl_int
1024 int clGetKernelWorkGroupInfo(@PointerWrapper("cl_kernel") CLKernel kernel,
1025 @PointerWrapper(value = "cl_device_id", canBeNull = true) CLDevice device,
1026 @NativeType("cl_kernel_work_group_info") int param_name,
1027 @AutoSize(value = "param_value", canBeNull = true) @size_t long param_value_size,
1028 @OutParameter @Check(canBeNull = true) @cl_void ByteBuffer param_value,
1029 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("size_t") PointerBuffer param_value_size_ret);
1030
1031 @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) command_queue.registerCLEvent(event);")
1032 @cl_int
1033 int clEnqueueNDRangeKernel(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue,
1034 @PointerWrapper("cl_kernel") CLKernel kernel,
1035 @cl_uint int work_dim,
1036 @Check(value = "work_dim", canBeNull = true) @Const @NativeType("size_t") PointerBuffer global_work_offset,
1037 @Check(value = "work_dim", canBeNull = true) @Const @NativeType("size_t") PointerBuffer global_work_size,
1038 @Check(value = "work_dim", canBeNull = true) @Const @NativeType("size_t") PointerBuffer local_work_size,
1039 @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list,
1040 @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list,
1041 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event);
1042
1043 @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) command_queue.registerCLEvent(event);")
1044 @cl_int
1045 int clEnqueueTask(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue,
1046 @PointerWrapper("cl_kernel") CLKernel kernel,
1047 @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list,
1048 @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list,
1049 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event);
1050
1051 /**
1052 * Enqueues a native kernel to the specified command queue. The <code>mem_list</code> parameter
1053 * can be used to pass a list of <code>CLMem</code> objects that will be mapped to global memory space and
1054 * exposed as a <code>ByteBuffer</code> array in the <code>CLNativeKernel#execute</code> method. The
1055 * <code>sizes</code> parameter will be used to allocate direct <code>ByteBuffer</code>s with the correct
1056 * capacities. The user is responsible for passing appropriate values to avoid crashes.
1057 *
1058 * @param command_queue the command queue
1059 * @param user_func the native kernel
1060 * @param mem_list the CLMem objects
1061 * @param sizes the CLMem object sizes
1062 * @param event_wait_list the event wait list
1063 * @param event the queue event
1064 *
1065 * @return the error code
1066 */
1067 @Code(
1068 tryBlock = true,
1069 // Build the args buffer and create a GlobalRef to the user_func object.
1070 javaBeforeNative = "\t\tlong user_func_ref = CallbackUtil.createGlobalRef(user_func);\n" +
1071 "\t\tByteBuffer args = APIUtil.getNativeKernelArgs(user_func_ref, mem_list, sizes);",
1072 // Register CLEvent
1073 javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) command_queue.registerCLEvent(event);",
1074 // Check if we need to delete the GlobalRef.
1075 javaFinally = "\t\t\tCallbackUtil.checkCallback(__result, user_func_ref);",
1076 nativeAfterVars = "\tvoid **args_mem_loc = num_mem_objects == 0 ? NULL : (void **)malloc(num_mem_objects * sizeof(void *));",
1077 nativeBeforeCall = "\t_ptr_i = 0;\n" +
1078 "\twhile ( _ptr_i < num_mem_objects ) {\n" +
1079 "\t\targs_mem_loc[_ptr_i] = (cl_void *)((char *)args_address + (4 + _ptr_i * (4 + sizeof(void *))));\n" +
1080 "\t\t_ptr_i++;\n" +
1081 "\t}",
1082 nativeAfterCall = "\tfree(args_mem_loc);"
1083 )
1084 @cl_int
1085 int clEnqueueNativeKernel(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue,
1086 @PointerWrapper("cl_native_kernel_func") CLNativeKernel user_func,
1087 @Constant("args, 0") @cl_void ByteBuffer args,
1088 @AutoSize("args") @size_t long cb_args,
1089 @Constant("mem_list == null ? 0 : mem_list.length") @cl_uint int num_mem_objects,
1090 @Check(value = "1", canBeNull = true) @PointerArray("num_mem_objects") @Const @NativeType("cl_mem") CLMem[] mem_list,
1091 @Check(value = "mem_list.length", canBeNull = true) @Helper long[] sizes,
1092 @Constant(value = "(const void**)args_mem_loc", isNative = true) @Const @Indirect @cl_void ByteBuffer args_mem_loc,
1093 @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list,
1094 @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list,
1095 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event);
1096
1097 @cl_int
1098 int clWaitForEvents(@AutoSize("event_list") @cl_uint int num_events,
1099 @Check("1") @Const @NativeType("cl_event") PointerBuffer event_list);
1100
1101 @Alternate("clWaitForEvents")
1102 @cl_int
1103 int clWaitForEvents(@Constant("1") @cl_uint int num_events,
1104 @Constant(value = "APIUtil.getBufferPointer().put(0, event).getBuffer(), 0", keepParam = true) CLEvent event);
1105
1106 @cl_int
1107 int clGetEventInfo(@PointerWrapper("cl_event") CLEvent event,
1108 @NativeType("cl_event_info") int param_name,
1109 @AutoSize(value = "param_value", canBeNull = true) @size_t long param_value_size,
1110 @OutParameter @Check(canBeNull = true) @cl_void ByteBuffer param_value,
1111 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("size_t") PointerBuffer param_value_size_ret);
1112
1113 @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) event.retain();")
1114 @cl_int
1115 int clRetainEvent(@PointerWrapper("cl_event") CLEvent event);
1116
1117 @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) event.release();")
1118 @cl_int
1119 int clReleaseEvent(@PointerWrapper("cl_event") CLEvent event);
1120
1121 @Code(javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) command_queue.registerCLEvent(event);")
1122 @cl_int
1123 int clEnqueueMarker(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue,
1124 @OutParameter @Check("1") @NativeType("cl_event") PointerBuffer event);
1125
1126 @cl_int
1127 int clEnqueueBarrier(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue);
1128
1129 @cl_int
1130 int clEnqueueWaitForEvents(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue,
1131 @AutoSize("event_list") @cl_uint int num_events,
1132 @Check("1") @Const @NativeType("cl_event") PointerBuffer event_list);
1133
1134 @Alternate("clEnqueueWaitForEvents")
1135 @cl_int
1136 int clEnqueueWaitForEvents(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue,
1137 @Constant("1") @cl_uint int num_events,
1138 @Constant(value = "APIUtil.getBufferPointer().put(0, event).getBuffer(), 0", keepParam = true) CLEvent event);
1139
1140 @cl_int
1141 int clGetEventProfilingInfo(@PointerWrapper("cl_event") CLEvent event,
1142 @NativeType("cl_profiling_info") int param_name,
1143 @AutoSize(value = "param_value", canBeNull = true) @size_t long param_value_size,
1144 @OutParameter @Check(canBeNull = true) @cl_void ByteBuffer param_value,
1145 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("size_t") PointerBuffer param_value_size_ret);
1146
1147 @cl_int
1148 int clFlush(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue);
1149
1150 @cl_int
1151 int clFinish(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue);
1152
1153 @Private
1154 @PointerWrapper("void *")
1155 CLFunctionAddress clGetExtensionFunctionAddress(@Check("1") @Const @cl_char ByteBuffer func_name);
1156
1157 @Alternate("clGetExtensionFunctionAddress")
1158 @Private
1159 @PointerWrapper("void *")
1160 CLFunctionAddress clGetExtensionFunctionAddress(CharSequence func_name);
1161
1162 }
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.opencl;
32
33 import org.lwjgl.PointerBuffer;
34 import org.lwjgl.util.generator.*;
35 import org.lwjgl.util.generator.opencl.cl_int;
36 import org.lwjgl.util.generator.opencl.cl_uint;
37 import org.lwjgl.util.generator.opencl.cl_void;
38 import org.lwjgl.util.generator.opencl.size_t;
39
40 import java.nio.ByteBuffer;
41 import java.nio.IntBuffer;
42
43 /** The core OpenCL 1.0 OpenGL interrop functionality. */
44 public interface CL10GL {
45
46 /** cl_gl_object_type */
47 int CL_GL_OBJECT_BUFFER = 0x2000,
48 CL_GL_OBJECT_TEXTURE2D = 0x2001,
49 CL_GL_OBJECT_TEXTURE3D = 0x2002,
50 CL_GL_OBJECT_RENDERBUFFER = 0x2003;
51
52 /** cl_gl_texture_info */
53 int CL_GL_TEXTURE_TARGET = 0x2004,
54 CL_GL_MIPMAP_LEVEL = 0x2005;
55
56 @Check(value = "errcode_ret", canBeNull = true)
57 @PointerWrapper(value = "cl_mem", params = "context")
58 CLMem clCreateFromGLBuffer(@PointerWrapper("cl_context") CLContext context,
59 @NativeType("cl_mem_flags") long flags,
60 @NativeType("GLuint") int bufobj,
61 @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret);
62
63 @Check(value = "errcode_ret", canBeNull = true)
64 @PointerWrapper(value = "cl_mem", params = "context")
65 CLMem clCreateFromGLTexture2D(@PointerWrapper("cl_context") CLContext context,
66 @NativeType("cl_mem_flags") long flags,
67 @NativeType("GLenum") int target,
68 @NativeType("GLint") int miplevel,
69 @NativeType("GLuint") int texture,
70 @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret);
71
72 @Check(value = "errcode_ret", canBeNull = true)
73 @PointerWrapper(value = "cl_mem", params = "context")
74 CLMem clCreateFromGLTexture3D(@PointerWrapper("cl_context") CLContext context,
75 @NativeType("cl_mem_flags") long flags,
76 @NativeType("GLenum") int target,
77 @NativeType("GLint") int miplevel,
78 @NativeType("GLuint") int texture,
79 @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret);
80
81 @Check(value = "errcode_ret", canBeNull = true)
82 @PointerWrapper(value = "cl_mem", params = "context")
83 CLMem clCreateFromGLRenderbuffer(@PointerWrapper("cl_context") CLContext context,
84 @NativeType("cl_mem_flags") long flags,
85 @NativeType("GLuint") int renderbuffer,
86 @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret);
87
88 @cl_int
89 int clGetGLObjectInfo(@PointerWrapper("cl_mem") CLMem memobj,
90 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_gl_object_type") IntBuffer gl_object_type,
91 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("GLuint") IntBuffer gl_object_name);
92
93 @cl_int
94 int clGetGLTextureInfo(@PointerWrapper("cl_mem") CLMem memobj,
95 @NativeType("cl_gl_texture_info") int param_name,
96 @AutoSize(value = "param_value", canBeNull = true) @size_t long param_value_size,
97 @OutParameter @Check(canBeNull = true) @cl_void ByteBuffer param_value,
98 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("size_t") PointerBuffer param_value_size_ret);
99
100 @Code(javaAfterNative = "\t\tif ( __result == CL10.CL_SUCCESS ) command_queue.registerCLEvent(event);")
101 @cl_int
102 int clEnqueueAcquireGLObjects(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue,
103 @AutoSize("mem_objects") @cl_uint int num_objects,
104 @Check("1") @Const @NativeType("cl_mem") PointerBuffer mem_objects,
105 @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list,
106 @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list,
107 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event);
108
109 @Alternate("clEnqueueAcquireGLObjects")
110 @Code(javaAfterNative = "\t\tif ( __result == CL10.CL_SUCCESS ) command_queue.registerCLEvent(event);")
111 @cl_int
112 int clEnqueueAcquireGLObjects(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue,
113 @Constant("1") @cl_uint int num_objects,
114 @Constant(value = "APIUtil.getBufferPointer().put(0, mem_object).getBuffer(), 0", keepParam = true) CLMem mem_object,
115 @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list,
116 @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list,
117 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event);
118
119 @Code(javaAfterNative = "\t\tif ( __result == CL10.CL_SUCCESS ) command_queue.registerCLEvent(event);")
120 @cl_int
121 int clEnqueueReleaseGLObjects(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue,
122 @AutoSize("mem_objects") @cl_uint int num_objects,
123 @Check("1") @Const @NativeType("cl_mem") PointerBuffer mem_objects,
124 @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list,
125 @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list,
126 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event);
127
128 @Alternate("clEnqueueReleaseGLObjects")
129 @Code(javaAfterNative = "\t\tif ( __result == CL10.CL_SUCCESS ) command_queue.registerCLEvent(event);")
130 @cl_int
131 int clEnqueueReleaseGLObjects(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue,
132 @Constant("1") @cl_uint int num_objects,
133 @Constant(value = "APIUtil.getBufferPointer().put(0, mem_object).getBuffer(), 0", keepParam = true) CLMem mem_object,
134 @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list,
135 @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list,
136 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event);
137 }
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.opencl;
32
33 import org.lwjgl.PointerBuffer;
34 import org.lwjgl.util.generator.*;
35 import org.lwjgl.util.generator.opencl.*;
36
37 import java.nio.Buffer;
38 import java.nio.ByteBuffer;
39 import java.nio.IntBuffer;
40
41 /** The core OpenCL 1.1 API */
42 public interface CL11 {
43
44 /** Error Codes */
45 int CL_MISALIGNED_SUB_BUFFER_OFFSET = -13,
46 CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST = -14,
47 CL_INVALID_PROPERTY = -64;
48
49 /** OpenCL Version */
50 int CL_VERSION_1_1 = 1;
51
52 /** cl_device_info */
53 int CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF = 0x1034,
54 CL_DEVICE_HOST_UNIFIED_MEMORY = 0x1035,
55 CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR = 0x1036,
56 CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT = 0x1037,
57 CL_DEVICE_NATIVE_VECTOR_WIDTH_INT = 0x1038,
58 CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG = 0x1039,
59 CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT = 0x103A,
60 CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE = 0x103B,
61 CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF = 0x103C,
62 CL_DEVICE_OPENCL_C_VERSION = 0x103D;
63
64 /** cl_device_fp_config - bitfield */
65 int CL_FP_SOFT_FLOAT = (1 << 6);
66
67 /** cl_context_info */
68 int CL_CONTEXT_NUM_DEVICES = 0x1083;
69
70 /** cl_channel_order */
71 int CL_Rx = 0x10BA,
72 CL_RGx = 0x10BB,
73 CL_RGBx = 0x10BC;
74
75 /** cl_mem_info */
76 int CL_MEM_ASSOCIATED_MEMOBJECT = 0x1107,
77 CL_MEM_OFFSET = 0x1108;
78
79 /** cl_addressing_mode */
80 int CL_ADDRESS_MIRRORED_REPEAT = 0x1134;
81
82 /** cl_kernel_work_group_info */
83 int CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE = 0x11B3,
84 CL_KERNEL_PRIVATE_MEM_SIZE = 0x11B4;
85
86 /** cl_event_info */
87 int CL_EVENT_CONTEXT = 0x11D4;
88
89 /** cl_command_type */
90 int CL_COMMAND_READ_BUFFER_RECT = 0x1201,
91 CL_COMMAND_WRITE_BUFFER_RECT = 0x1202,
92 CL_COMMAND_COPY_BUFFER_RECT = 0x1203,
93 CL_COMMAND_USER = 0x1204;
94
95 /** cl_buffer_create_type */
96 int CL_BUFFER_CREATE_TYPE_REGION = 0x1220;
97
98 @Check(value = "errcode_ret", canBeNull = true)
99 @PointerWrapper(value = "cl_mem", factory = "CLMem.create", params = "buffer.getParent()")
100 CLMem clCreateSubBuffer(@PointerWrapper("cl_mem") CLMem buffer,
101 @NativeType("cl_mem_flags") long flags,
102 @NativeType("cl_buffer_create_type") int buffer_create_type,
103 @Const @Check("2 * PointerBuffer.getPointerSize()") @NativeType("cl_void") ByteBuffer buffer_create_info,
104 @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret);
105
106 @Code(
107 tryBlock = true,
108 // Create a GlobalRef to the callback object.
109 javaBeforeNative = "\t\tlong user_data = CallbackUtil.createGlobalRef(pfn_notify);",
110 // Check if we need to delete the GlobalRef.
111 javaFinally = "\t\t\tCallbackUtil.checkCallback(__result, user_data);"
112 )
113 @cl_int
114 int clSetMemObjectDestructorCallback(@PointerWrapper("cl_mem") CLMem memobj,
115 @PointerWrapper("cl_mem_object_destructor_callback") CLMemObjectDestructorCallback pfn_notify,
116 @Constant("user_data") @PointerWrapper("void *") long user_data);
117
118 @Code(javaAfterNative = "\t\tif ( __result == CL10.CL_SUCCESS ) command_queue.registerCLEvent(event);")
119 @cl_int
120 int clEnqueueReadBufferRect(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue,
121 @PointerWrapper("cl_mem") CLMem buffer,
122 @cl_bool int blocking_read,
123 @Const @Check("3") @NativeType("size_t") PointerBuffer buffer_origin,
124 @Const @Check("3") @NativeType("size_t") PointerBuffer host_origin,
125 @Const @Check("3") @NativeType("size_t") PointerBuffer region,
126 @size_t long buffer_row_pitch,
127 @size_t long buffer_slice_pitch,
128 @size_t long host_row_pitch,
129 @size_t long host_slice_pitch,
130 @OutParameter @Check("CLChecks.calculateBufferRectSize(host_origin, region, host_row_pitch, host_slice_pitch)")
131 @cl_byte
132 @cl_short
133 @cl_int
134 @cl_long
135 @cl_float
136 @cl_double Buffer ptr,
137 @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list,
138 @Const @Check(canBeNull = true) @NativeType("cl_event") PointerBuffer event_wait_list,
139 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event);
140
141 @Code(javaAfterNative = "\t\tif ( __result == CL10.CL_SUCCESS ) command_queue.registerCLEvent(event);")
142 @cl_int
143 int clEnqueueWriteBufferRect(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue,
144 @PointerWrapper("cl_mem") CLMem buffer,
145 @cl_bool int blocking_write,
146 @Const @Check("3") @NativeType("size_t") PointerBuffer buffer_origin,
147 @Const @Check("3") @NativeType("size_t") PointerBuffer host_origin,
148 @Const @Check("3") @NativeType("size_t") PointerBuffer region,
149 @size_t long buffer_row_pitch,
150 @size_t long buffer_slice_pitch,
151 @size_t long host_row_pitch,
152 @size_t long host_slice_pitch,
153 @Const @Check("CLChecks.calculateBufferRectSize(host_origin, region, host_row_pitch, host_slice_pitch)")
154 @cl_byte
155 @cl_short
156 @cl_int
157 @cl_long
158 @cl_float
159 @cl_double Buffer ptr,
160 @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list,
161 @Const @Check(canBeNull = true) @NativeType("cl_event") PointerBuffer event_wait_list,
162 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event);
163
164 @Code(javaAfterNative = "\t\tif ( __result == CL10.CL_SUCCESS ) command_queue.registerCLEvent(event);")
165 @cl_int
166 int clEnqueueCopyBufferRect(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue,
167 @PointerWrapper("cl_mem") CLMem src_buffer,
168 @PointerWrapper("cl_mem") CLMem dst_buffer,
169 @Const @Check("3") @NativeType("size_t") PointerBuffer src_origin,
170 @Const @Check("3") @NativeType("size_t") PointerBuffer dst_origin,
171 @Const @Check("3") @NativeType("size_t") PointerBuffer region,
172 @size_t long src_row_pitch,
173 @size_t long src_slice_pitch,
174 @size_t long dst_row_pitch,
175 @size_t long dst_slice_pitch,
176 @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list,
177 @Const @Check(canBeNull = true) @NativeType("cl_event") PointerBuffer event_wait_list,
178 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event);
179
180 @Check(value = "errcode_ret", canBeNull = true)
181 @PointerWrapper(value = "cl_event", params = "context")
182 CLEvent clCreateUserEvent(@PointerWrapper("cl_context") CLContext context,
183 @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret);
184
185 @cl_int
186 int clSetUserEventStatus(@PointerWrapper("cl_event") CLEvent event,
187 @cl_int int execution_status);
188
189 @Code(
190 tryBlock = true,
191 // Create a GlobalRef to the callback object.
192 javaBeforeNative = "\t\tlong user_data = CallbackUtil.createGlobalRef(pfn_notify);",
193 // Check if we need to delete the GlobalRef.
194 javaFinally = "\t\t\tCallbackUtil.checkCallback(__result, user_data);"
195 )
196 @cl_int
197 int clSetEventCallback(@PointerWrapper("cl_event") CLEvent event,
198 @cl_int int command_exec_callback_type,
199 @PointerWrapper("cl_event_callback") CLEventCallback pfn_notify,
200 @Constant("user_data") @PointerWrapper("void *") long user_data);
201
202 }
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.opencl;
32
33 import org.lwjgl.PointerBuffer;
34 import org.lwjgl.util.generator.*;
35 import org.lwjgl.util.generator.opencl.CLDeviceExtension;
36 import org.lwjgl.util.generator.opencl.cl_int;
37 import org.lwjgl.util.generator.opencl.cl_uint;
38
39 import java.nio.IntBuffer;
40 import java.nio.LongBuffer;
41
42 @CLDeviceExtension
43 public interface EXT_device_fission {
44
45 /**
46 * Accepted as a property name in the &lt;properties&gt; parameter of
47 * clCreateSubDeviceEXT:
48 */
49 int CL_DEVICE_PARTITION_EQUALLY_EXT = 0x4050,
50 CL_DEVICE_PARTITION_BY_COUNTS_EXT = 0x4051,
51 CL_DEVICE_PARTITION_BY_NAMES_EXT = 0x4052,
52 CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN_EXT = 0x4053;
53
54 /**
55 * Accepted as a property name, when accompanying the
56 * CL_DEVICE_PARITION_BY_AFFINITY_DOMAIN_EXT property, in the &lt;properties&gt;
57 * parameter of clCreateSubDeviceEXT:
58 */
59 int CL_AFFINITY_DOMAIN_L1_CACHE_EXT = 0x1,
60 CL_AFFINITY_DOMAIN_L2_CACHE_EXT = 0x2,
61 CL_AFFINITY_DOMAIN_L3_CACHE_EXT = 0x3,
62 CL_AFFINITY_DOMAIN_L4_CACHE_EXT = 0x4,
63 CL_AFFINITY_DOMAIN_NUMA_EXT = 0x10,
64 CL_AFFINITY_DOMAIN_NEXT_FISSIONABLE_EXT = 0x100;
65
66 /**
67 * Accepted as a property being queried in the &lt;param_name&gt; argument of
68 * clGetDeviceInfo:
69 */
70 int CL_DEVICE_PARENT_DEVICE_EXT = 0x4054,
71 CL_DEVICE_PARITION_TYPES_EXT = 0x4055,
72 CL_DEVICE_AFFINITY_DOMAINS_EXT = 0x4056,
73 CL_DEVICE_REFERENCE_COUNT_EXT = 0x4057,
74 CL_DEVICE_PARTITION_STYLE_EXT = 0x4058;
75
76 /**
77 * Accepted as the property list terminator in the &lt;properties&gt; parameter of
78 * clCreateSubDeviceEXT:
79 */
80 int CL_PROPERTIES_LIST_END_EXT = 0x0;
81
82 /**
83 * Accepted as the partition counts list terminator in the &lt;properties&gt;
84 * parameter of clCreateSubDeviceEXT:
85 */
86 int CL_PARTITION_BY_COUNTS_LIST_END_EXT = 0x0;
87
88 /**
89 * Accepted as the partition names list terminator in the &lt;properties&gt;
90 * parameter of clCreateSubDeviceEXT:
91 */
92 int CL_PARTITION_BY_NAMES_LIST_END_EXT = -1;
93
94 /**
95 * Returned by clCreateSubDevicesEXT when the indicated partition scheme is
96 * supported by the implementation, but the implementation can not further
97 * partition the device in this way.
98 */
99 int CL_DEVICE_PARTITION_FAILED_EXT = -1057;
100
101 /**
102 * Returned by clCreateSubDevicesEXT when the total number of compute units
103 * requested exceeds CL_DEVICE_MAX_COMPUTE_UNITS, or the number of compute
104 * units for any one sub-device is less than 1.
105 */
106 int CL_INVALID_PARTITION_COUNT_EXT = -1058;
107
108 /**
109 * Returned by clCreateSubDevicesEXT when a compute unit name appearing in a
110 * name list following CL_DEVICE_PARTITION_BY_NAMES_EXT is not in range.
111 */
112 int CL_INVALID_PARTITION_NAME_EXT = -1059;
113
114 @Code(javaAfterNative = "\t\tif ( __result == CL10.CL_SUCCESS ) device.retain();")
115 @cl_int
116 int clRetainDeviceEXT(@PointerWrapper("cl_device_id") CLDevice device);
117
118 /**
119 * Warning: LWJGL will not automatically release any objects associated with sub-devices.
120 * The user is responsible for tracking and releasing everything prior to calling this method.
121 *
122 * @param device the parent CLDevice
123 *
124 * @return the error code
125 */
126 @Code(
127 javaBeforeNative = "\t\tAPIUtil.releaseObjects(device);",
128 javaAfterNative = "\t\tif ( __result == CL10.CL_SUCCESS ) device.release();"
129 )
130 @cl_int
131 int clReleaseDeviceEXT(@PointerWrapper("cl_device_id") CLDevice device);
132
133 @Code(javaAfterNative = "\t\tif ( __result == CL10.CL_SUCCESS && out_devices != null ) in_device.registerSubCLDevices(out_devices);")
134 @cl_int
135 int clCreateSubDevicesEXT(
136 @PointerWrapper("cl_device_id") CLDevice in_device,
137 // TODO: cl_device_partition_property_ext is a cl_bitfield (ulong), but the spec says properties is a {property-value, cl_int[]} list...
138 @NullTerminated @Const @NativeType("cl_device_partition_property_ext") LongBuffer properties,
139 @AutoSize(value = "out_devices", canBeNull = true) @cl_uint int num_entries,
140 @OutParameter @Check(canBeNull = true) @NativeType("cl_device_id") PointerBuffer out_devices,
141 @OutParameter @Check(value = "1", canBeNull = true) @cl_uint IntBuffer num_devices);
142
143 }
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.opencl;
32
33 import org.lwjgl.PointerBuffer;
34 import org.lwjgl.util.generator.*;
35 import org.lwjgl.util.generator.opencl.CLDeviceExtension;
36 import org.lwjgl.util.generator.opencl.cl_bitfield;
37 import org.lwjgl.util.generator.opencl.cl_int;
38 import org.lwjgl.util.generator.opencl.cl_uint;
39
40 @CLDeviceExtension
41 public interface EXT_migrate_memobject {
42
43 /**
44 * Besides a value of zero, the following cl_mem_migration_flags_ext values are
45 * allowed:
46 */
47 int CL_MIGRATE_MEM_OBJECT_HOST_EXT = 0x1;
48
49 /**
50 * Returned in the &lt;param_value&gt; parameter of the clGetEventInfo when
51 * &lt;param_name&gt; is CL_EVENT_COMMAND_TYPE:
52 */
53 int CL_COMMAND_MIGRATE_MEM_OBJECT_EXT = 0x4040;
54
55 @Code(javaAfterNative = "\t\tif ( __result == CL10.CL_SUCCESS ) command_queue.registerCLEvent(event);")
56 @cl_int
57 int clEnqueueMigrateMemObjectEXT(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue,
58 @AutoSize("mem_objects") @cl_uint int num_mem_objects,
59 @Check("1") @Const @NativeType("cl_mem") PointerBuffer mem_objects,
60 @cl_bitfield @NativeType("cl_mem_migration_flags_ext") long flags,
61 @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list,
62 @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list,
63 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event);
64
65 @Alternate("clEnqueueMigrateMemObjectEXT")
66 @Code(javaAfterNative = "\t\tif ( __result == CL10.CL_SUCCESS ) command_queue.registerCLEvent(event);")
67 @cl_int
68 int clEnqueueMigrateMemObjectEXT(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue,
69 @Constant("1") @cl_uint int num_mem_objects,
70 @Constant(value = "APIUtil.getBufferPointer().put(0, mem_object).getBuffer(), 0", keepParam = true) CLMem mem_object,
71 @cl_bitfield @NativeType("cl_mem_migration_flags_ext") long flags,
72 @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list,
73 @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list,
74 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event);
75
76 }
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.opencl;
32
33 import org.lwjgl.util.generator.opencl.CLDeviceExtension;
34
35 @CLDeviceExtension
36 public interface KHR_3d_image_writes {
37
38 }
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.opencl;
32
33 import org.lwjgl.util.generator.opencl.CLDeviceExtension;
34
35 @CLDeviceExtension
36 public interface KHR_byte_addressable_store {
37
38 }
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.opencl;
32
33 import org.lwjgl.util.generator.opencl.CLPlatformExtension;
34
35 @CLPlatformExtension
36 public interface KHR_d3d10_sharing {
37 // Not implemented
38 }
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.opencl;
32
33 import org.lwjgl.util.generator.opencl.CLDeviceExtension;
34
35 @CLDeviceExtension
36 public interface KHR_fp16 {
37
38 /** cl_device_info */
39 int CL_DEVICE_HALF_FP_CONFIG = 0x1033;
40
41 }
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.opencl;
32
33 import org.lwjgl.util.generator.opencl.CLDeviceExtension;
34
35 @CLDeviceExtension
36 public interface KHR_fp64 {
37
38 /** cl_device_info */
39 int CL_DEVICE_DOUBLE_FP_CONFIG = 0x1032;
40
41 }
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.opencl;
32
33 import org.lwjgl.opengl.GLSync;
34 import org.lwjgl.util.generator.*;
35 import org.lwjgl.util.generator.opencl.CLDeviceExtension;
36 import org.lwjgl.util.generator.opencl.CLPlatformExtension;
37 import org.lwjgl.util.generator.opencl.cl_int;
38
39 import java.nio.IntBuffer;
40
41 @Imports("org.lwjgl.opengl.GLSync")
42 @CLPlatformExtension
43 @CLDeviceExtension
44 @Extension(postfix = "KHR", className = "KHRGLEvent")
45 public interface KHR_gl_event {
46
47 /** Returned by clGetEventInfo when param_name is CL_EVENT_COMMAND_TYPE: */
48 int CL_COMMAND_GL_FENCE_SYNC_OBJECT_KHR = 0x200D;
49
50 @Check(value = "errcode_ret", canBeNull = true)
51 @PointerWrapper(value = "cl_event", params = "context")
52 CLEvent clCreateEventFromGLsyncKHR(@PointerWrapper("cl_context") CLContext context,
53 @PointerWrapper("cl_GLsync") GLSync sync,
54 @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret);
55 }
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.opencl;
32
33 import org.lwjgl.PointerBuffer;
34 import org.lwjgl.util.generator.*;
35 import org.lwjgl.util.generator.opencl.*;
36
37 import java.nio.ByteBuffer;
38
39 @CLPlatformExtension
40 @CLDeviceExtension
41 @Extension(postfix = "KHR", className = "KHRGLSharing")
42 public interface KHR_gl_sharing {
43
44 /**
45 * Returned by clCreateContext, clCreateContextFromType, and
46 * clGetGLContextInfoKHR when an invalid OpenGL context or share group
47 * object handle is specified in &lt;properties&gt;:
48 */
49 int CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR = -1000;
50
51 /** Accepted as the &lt;param_name&gt; argument of clGetGLContextInfoKHR: */
52 int CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR = 0x2006,
53 CL_DEVICES_FOR_GL_CONTEXT_KHR = 0x2007;
54
55 /**
56 * Accepted as an attribute name in the 'properties' argument of
57 * clCreateContext and clCreateContextFromType:
58 */
59 int CL_GL_CONTEXT_KHR = 0x2008,
60 CL_EGL_DISPLAY_KHR = 0x2009,
61 CL_GLX_DISPLAY_KHR = 0x200A,
62 CL_WGL_HDC_KHR = 0x200B,
63 CL_CGL_SHAREGROUP_KHR = 0x200C;
64
65 @Code(
66 javaBeforeNative = "\t\tif ( param_value_size_ret == null && APIUtil.isDevicesParam(param_name) ) param_value_size_ret = APIUtil.getBufferPointer();",
67 javaAfterNative = "\t\tif ( __result == CL10.CL_SUCCESS && param_value != null && APIUtil.isDevicesParam(param_name) ) APIUtil.getCLPlatform(properties).registerCLDevices(param_value, param_value_size_ret);"
68 )
69 @cl_int
70 int clGetGLContextInfoKHR(@NullTerminated @Const @NativeType("cl_context_properties") PointerBuffer properties,
71 @NativeType("cl_gl_context_info") int param_name,
72 @AutoSize(value = "param_value", canBeNull = true) @size_t long param_value_size,
73 @OutParameter @Check(canBeNull = true) @cl_void ByteBuffer param_value,
74 @OutParameter @Check(value = "1", canBeNull = true) @NativeType("size_t") PointerBuffer param_value_size_ret);
75
76 }
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.opencl;
32
33 import org.lwjgl.util.generator.opencl.CLDeviceExtension;
34
35 @CLDeviceExtension
36 public interface KHR_global_int32_base_atomics {
37
38 }
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.opencl;
32
33 import org.lwjgl.util.generator.opencl.CLDeviceExtension;
34
35 @CLDeviceExtension
36 public interface KHR_global_int32_extended_atomics {
37
38 }
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.opencl;
32
33 import org.lwjgl.PointerBuffer;
34 import org.lwjgl.util.generator.*;
35 import org.lwjgl.util.generator.opencl.CLPlatformExtension;
36 import org.lwjgl.util.generator.opencl.cl_int;
37 import org.lwjgl.util.generator.opencl.cl_uint;
38
39 import java.nio.IntBuffer;
40
41 @CLPlatformExtension
42 @Extension(postfix = "KHR", className = "KHRICD")
43 public interface KHR_icd {
44
45 /** Accepted as &lt;param_name&gt; to the function clGetPlatformInfo */
46 int CL_PLATFORM_ICD_SUFFIX_KHR = 0x0920;
47
48 /** Returned by clGetPlatformIDs when no platforms are found */
49 int CL_PLATFORM_NOT_FOUND_KHR = -1001;
50
51 @Optional(reason = "AMD Stream does not expose this (version tested: 2.2)")
52 @cl_int
53 int clIcdGetPlatformIDsKHR(@AutoSize(value = "platforms", canBeNull = true) @cl_uint int num_entries,
54 @OutParameter @Check(canBeNull = true) @NativeType("cl_platform_id") PointerBuffer platforms,
55 @OutParameter @Check(value = "1", canBeNull = true) @cl_uint IntBuffer num_platforms);
56
57 }
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.opencl;
32
33 import org.lwjgl.util.generator.opencl.CLDeviceExtension;
34
35 @CLDeviceExtension
36 public interface KHR_int64_base_atomics {
37
38 }
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.opencl;
32
33 import org.lwjgl.util.generator.opencl.CLDeviceExtension;
34
35 @CLDeviceExtension
36 public interface KHR_int64_extended_atomics {
37
38 }
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.opencl;
32
33 import org.lwjgl.util.generator.opencl.CLDeviceExtension;
34
35 @CLDeviceExtension
36 public interface KHR_local_int32_base_atomics {
37
38 }
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.opencl;
32
33 import org.lwjgl.util.generator.opencl.CLDeviceExtension;
34
35 @CLDeviceExtension
36 public interface KHR_local_int32_extended_atomics {
37
38 }
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.opencl;
32
33 import org.lwjgl.util.generator.opencl.CLDeviceExtension;
34
35 @CLDeviceExtension
36 public interface KHR_select_fprounding_mode {
37
38 }
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.opencl;
32
33 import org.lwjgl.util.generator.opencl.CLDeviceExtension;
34
35 @CLDeviceExtension
36 public interface NV_compiler_options {
37
38 }
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.opencl;
32
33 import org.lwjgl.util.generator.opencl.CLDeviceExtension;
34
35 @CLDeviceExtension
36 public interface NV_device_attribute_query {
37
38 /** Accepted as the &lt;param_name&gt; parameter of clGetDeviceInfo. */
39 int CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV = 0x4000,
40 CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV = 0x4001,
41 CL_DEVICE_REGISTERS_PER_BLOCK_NV = 0x4002,
42 CL_DEVICE_WARP_SIZE_NV = 0x4003,
43 CL_DEVICE_GPU_OVERLAP_NV = 0x4004,
44 CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV = 0x4005,
45 CL_DEVICE_INTEGRATED_MEMORY_NV = 0x4006;
46
47 }
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.opencl;
32
33 import org.lwjgl.util.generator.opencl.CLDeviceExtension;
34
35 @CLDeviceExtension
36 public interface NV_pragma_unroll {
37
38 }
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.PointerWrapper;
35 import org.lwjgl.util.generator.Alias;
36 import org.lwjgl.util.generator.Alternate;
37 import org.lwjgl.util.generator.opengl.*;
3438
3539 import java.nio.ByteBuffer;
3640 import java.nio.IntBuffer;
7680 * The {@code AMDDebugOutputCallback.Handler} implementation passed to this method will be used for
7781 * AMD_debug_output messages. If callback is null, any previously registered handler for the current
7882 * 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.
8383 *
8484 * @param callback the callback function to use
85 * @param userParam the user-specified data
8685 */
87 void glDebugMessageCallbackAMD(@GLpointer(value = "GLDEBUGPROCAMD", canBeNull = true) AMDDebugOutputCallback callback, @Check(canBeNull = true) @GLvoid ByteBuffer userParam);
86 @Code(
87 // Create a GlobalRef to the callback object and register it with the current context.
88 javaBeforeNative = "\t\tlong userParam = callback == null ? 0 : CallbackUtil.createGlobalRef(callback.getHandler());\n" +
89 "\t\tCallbackUtil.registerContextCallbackAMD(userParam);"
90 )
91 void glDebugMessageCallbackAMD(@PointerWrapper(value = "GLDEBUGPROCAMD", canBeNull = true) AMDDebugOutputCallback callback,
92 @Constant("userParam") @PointerWrapper("GLvoid *") long userParam);
8893
8994 @GLuint
9095 int glGetDebugMessageLogAMD(@GLuint int count,
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.opengl;
32
33 public interface AMD_depth_clamp_separate {
34
35 /**
36 * Accepted by the &lt;cap&gt; parameter of Enable, Disable, and IsEnabled,
37 * and by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
38 * GetFloatv, and GetDoublev:
39 */
40 int GL_DEPTH_CLAMP_NEAR_AMD = 0x901E,
41 GL_DEPTH_CLAMP_FAR_AMD = 0x901F;
42
43 }
3030 */
3131 package org.lwjgl.opengl;
3232
33 import org.lwjgl.util.generator.GLenum;
34 import org.lwjgl.util.generator.GLuint;
33 import org.lwjgl.util.generator.opengl.GLenum;
34 import org.lwjgl.util.generator.opengl.GLuint;
3535
3636 public interface AMD_draw_buffers_blend {
3737
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
35 import org.lwjgl.util.generator.opengl.GLenum;
36 import org.lwjgl.util.generator.opengl.GLreturn;
37 import org.lwjgl.util.generator.opengl.GLsizei;
38 import org.lwjgl.util.generator.opengl.GLuint;
3439
3540 import java.nio.IntBuffer;
3641
5257 void glDeleteNamesAMD(@GLenum int identifier, @AutoSize("names") @GLsizei int num, @Const @GLuint IntBuffer names);
5358
5459 @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);
60 void glDeleteNamesAMD(@GLenum int identifier, @Constant("1") @GLsizei int num, @Constant(value = "APIUtil.getBufferInt().put(0, name), 0", keepParam = true) int name);
5661
5762 boolean glIsNameAMD(@GLenum int identifier, @GLuint int name);
5863
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
35 import org.lwjgl.util.generator.opengl.*;
3436
3537 import java.nio.ByteBuffer;
3638 import java.nio.IntBuffer;
9799 void glDeletePerfMonitorsAMD(@AutoSize("monitors") @GLsizei int n, @GLuint IntBuffer monitors);
98100
99101 @Alternate("glDeletePerfMonitorsAMD")
100 void glDeletePerfMonitorsAMD(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, monitor), 0", keepParam = true) int monitor);
102 void glDeletePerfMonitorsAMD(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, monitor), 0", keepParam = true) int monitor);
101103
102104 void glSelectPerfMonitorCountersAMD(@GLuint int monitor, boolean enable, @GLuint int group, @AutoSize("counterList") int numCounters, @GLuint IntBuffer counterList);
103105
104106 @Alternate("glSelectPerfMonitorCountersAMD")
105 void glSelectPerfMonitorCountersAMD(@GLuint int monitor, boolean enable, @GLuint int group, @Constant("1") int numCounters, @Constant(value = "APIUtils.getBufferInt().put(0, counter), 0", keepParam = true) int counter);
107 void glSelectPerfMonitorCountersAMD(@GLuint int monitor, boolean enable, @GLuint int group, @Constant("1") int numCounters, @Constant(value = "APIUtil.getBufferInt().put(0, counter), 0", keepParam = true) int counter);
106108
107109 void glBeginPerfMonitorAMD(@GLuint int monitor);
108110
3030 */
3131 package org.lwjgl.opengl;
3232
33 import org.lwjgl.util.generator.GLenum;
33 import org.lwjgl.util.generator.opengl.GLenum;
3434
3535 public interface AMD_vertex_shader_tessellator {
3636
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.*;
3435
3536 import java.nio.Buffer;
3637 import java.nio.IntBuffer;
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
35 import org.lwjgl.util.generator.opengl.GLenum;
36 import org.lwjgl.util.generator.opengl.GLreturn;
37 import org.lwjgl.util.generator.opengl.GLsizei;
38 import org.lwjgl.util.generator.opengl.GLuint;
3439
3540 import java.nio.IntBuffer;
3641
4954 void glDeleteFencesAPPLE(@AutoSize("fences") @GLsizei int n, @Const @GLuint IntBuffer fences);
5055
5156 @Alternate("glDeleteFencesAPPLE")
52 void glDeleteFencesAPPLE(@Constant("1") @GLsizei int n, @Const @GLuint @Constant(value = "APIUtils.getBufferInt().put(0, fence), 0", keepParam = true) int fence);
57 void glDeleteFencesAPPLE(@Constant("1") @GLsizei int n, @Const @GLuint @Constant(value = "APIUtil.getBufferInt().put(0, fence), 0", keepParam = true) int fence);
5358
5459 void glSetFenceAPPLE(@GLuint int fence);
5560
3030 */
3131 package org.lwjgl.opengl;
3232
33 import org.lwjgl.util.generator.GLenum;
34 import org.lwjgl.util.generator.GLintptr;
35 import org.lwjgl.util.generator.GLsizeiptr;
33 import org.lwjgl.util.generator.opengl.GLenum;
34 import org.lwjgl.util.generator.opengl.GLintptr;
35 import org.lwjgl.util.generator.opengl.GLsizeiptr;
3636
3737 public interface APPLE_flush_buffer_range {
3838
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
35 import org.lwjgl.util.generator.opengl.GLenum;
36 import org.lwjgl.util.generator.opengl.GLreturn;
37 import org.lwjgl.util.generator.opengl.GLuint;
3438
3539 import java.nio.IntBuffer;
3640
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.GLenum;
35 import org.lwjgl.util.generator.opengl.GLsizei;
36 import org.lwjgl.util.generator.opengl.GLvoid;
3437
3538 import java.nio.Buffer;
3639 import java.nio.ByteBuffer;
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
35 import org.lwjgl.util.generator.opengl.GLreturn;
36 import org.lwjgl.util.generator.opengl.GLsizei;
37 import org.lwjgl.util.generator.opengl.GLuint;
3438
3539 import java.nio.IntBuffer;
3640
4751 void glDeleteVertexArraysAPPLE(@AutoSize("arrays") @GLsizei int n, @Const @GLuint IntBuffer arrays);
4852
4953 @Alternate("glDeleteVertexArraysAPPLE")
50 void glDeleteVertexArraysAPPLE(@Constant("1") @GLsizei int n, @Const @GLuint @Constant(value = "APIUtils.getBufferInt().put(0, array), 0", keepParam = true) int array);
54 void glDeleteVertexArraysAPPLE(@Constant("1") @GLsizei int n, @Const @GLuint @Constant(value = "APIUtil.getBufferInt().put(0, array), 0", keepParam = true) int array);
5155
5256 void glGenVertexArraysAPPLE(@AutoSize("arrays") @GLsizei int n, @OutParameter @GLuint IntBuffer arrays);
5357
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.AutoSize;
34 import org.lwjgl.util.generator.GLenum;
35 import org.lwjgl.util.generator.GLsizei;
36 import org.lwjgl.util.generator.GLvoid;
34 import org.lwjgl.util.generator.opengl.GLenum;
35 import org.lwjgl.util.generator.opengl.GLsizei;
36 import org.lwjgl.util.generator.opengl.GLvoid;
3737
3838 import java.nio.ByteBuffer;
3939
3232
3333 import org.lwjgl.util.generator.Check;
3434 import org.lwjgl.util.generator.Const;
35 import org.lwjgl.util.generator.GLenum;
36 import org.lwjgl.util.generator.GLuint;
35 import org.lwjgl.util.generator.opengl.GLenum;
36 import org.lwjgl.util.generator.opengl.GLuint;
3737
3838 import java.nio.DoubleBuffer;
3939 import java.nio.FloatBuffer;
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 import org.lwjgl.util.generator.opengl.*;
35
36 import java.nio.ByteBuffer;
37 import java.nio.IntBuffer;
38
39 public interface ARB_ES2_compatibility {
40
41 /**
42 * Accepted by the &lt;value&gt; parameter of GetBooleanv, GetIntegerv,
43 * GetInteger64v, GetFloatv, and GetDoublev:
44 */
45 int GL_SHADER_COMPILER = 0x8DFA,
46 GL_NUM_SHADER_BINARY_FORMATS = 0x8DF9,
47 GL_MAX_VERTEX_UNIFORM_VECTORS = 0x8DFB,
48 GL_MAX_VARYING_VECTORS = 0x8DFC,
49 GL_MAX_FRAGMENT_UNIFORM_VECTORS = 0x8DFD,
50 GL_IMPLEMENTATION_COLOR_READ_TYPE = 0x8B9A,
51 GL_IMPLEMENTATION_COLOR_READ_FORMAT = 0x8B9B;
52
53 /** Accepted by the &lt;type&gt; parameter of VertexAttribPointer: */
54 int GL_FIXED = 0x140C;
55
56 /**
57 * Accepted by the &lt;precisiontype&gt; parameter of
58 * GetShaderPrecisionFormat:
59 */
60 int GL_LOW_FLOAT = 0x8DF0,
61 GL_MEDIUM_FLOAT = 0x8DF1,
62 GL_HIGH_FLOAT = 0x8DF2,
63 GL_LOW_INT = 0x8DF3,
64 GL_MEDIUM_INT = 0x8DF4,
65 GL_HIGH_INT = 0x8DF5;
66
67 @Reuse("GL41")
68 void glReleaseShaderCompiler();
69
70 @Reuse("GL41")
71 void glShaderBinary(@AutoSize("shaders") @GLsizei int count, @Const @GLuint IntBuffer shaders,
72 @GLenum int binaryformat, @Const @GLvoid ByteBuffer binary, @AutoSize("binary") @GLsizei int length);
73
74 @Reuse("GL41")
75 void glGetShaderPrecisionFormat(@GLenum int shadertype, @GLenum int precisiontype,
76 @OutParameter @Check("2") IntBuffer range,
77 @OutParameter @Check("1") IntBuffer precision);
78
79 @Reuse("GL41")
80 void glDepthRangef(@GLclampf float n, @GLclampf float f);
81
82 @Reuse("GL41")
83 void glClearDepthf(@GLclampf float d);
84
85 }
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
35 import org.lwjgl.util.generator.opengl.GLchar;
36 import org.lwjgl.util.generator.opengl.GLuint;
3437
3538 import java.nio.ByteBuffer;
3639
5255 */
5356 int GL_MAX_DUAL_SOURCE_DRAW_BUFFERS = 0x88FC;
5457
58 @Reuse("GL33")
5559 void glBindFragDataLocationIndexed(@GLuint int program, @GLuint int colorNumber, @GLuint int index, @NullTerminated @Const @GLchar ByteBuffer name);
5660
61 @Reuse("GL33")
5762 @Alternate("glBindFragDataLocationIndexed")
5863 void glBindFragDataLocationIndexed(@GLuint int program, @GLuint int colorNumber, @GLuint int index, @NullTerminated CharSequence name);
5964
65 @Reuse("GL33")
6066 int glGetFragDataIndex(@GLuint int program, @NullTerminated @Const @GLchar ByteBuffer name);
6167
68 @Reuse("GL33")
6269 @Alternate("glGetFragDataIndex")
6370 int glGetFragDataIndex(@GLuint int program, @NullTerminated CharSequence name);
6471
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
35 import org.lwjgl.util.generator.opengl.*;
3436
3537 import java.nio.Buffer;
3638 import java.nio.ByteBuffer;
6870 void glDeleteBuffersARB(@AutoSize("buffers") @GLsizei int n, @Const @GLuint IntBuffer buffers);
6971
7072 @Alternate("glDeleteBuffersARB")
71 void glDeleteBuffersARB(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, buffer), 0", keepParam = true) int buffer);
73 void glDeleteBuffersARB(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, buffer), 0", keepParam = true) int buffer);
7274
7375 void glGenBuffersARB(@AutoSize("buffers") @GLsizei int n, @OutParameter @GLuint IntBuffer buffers);
7476
130132 */
131133 @CachedResult
132134 @GLvoid
133 @AutoResultSize("GLChecks.getBufferObjectSizeARB(caps, target)")
135 @AutoSize("GLChecks.getBufferObjectSizeARB(caps, target)")
134136 ByteBuffer glMapBufferARB(@GLenum int target, @GLenum int access);
135137
136138 boolean glUnmapBufferARB(@GLenum int target);
144146 void glGetBufferParameterivARB2(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
145147
146148 @StripPostfix("pointer")
147 @AutoResultSize("GLChecks.getBufferObjectSizeARB(caps, target)")
149 @AutoSize("GLChecks.getBufferObjectSizeARB(caps, target)")
148150 void glGetBufferPointervARB(@GLenum int target, @GLenum int pname, @Result @GLvoid ByteBuffer pointer);
149151 }
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.opencl.CLContext;
34 import org.lwjgl.opencl.CLEvent;
35 import org.lwjgl.util.generator.Extension;
36 import org.lwjgl.util.generator.Imports;
37 import org.lwjgl.util.generator.PointerWrapper;
38 import org.lwjgl.util.generator.opengl.GLbitfield;
39
40 @Imports("org.lwjgl.opencl.*")
41 @Extension(postfix = "ARB", className = "ARBCLEvent")
42 public interface ARB_cl_event {
43
44 /** Returned in &lt;values&gt; for GetSynciv &lt;pname&gt; OBJECT_TYPE. */
45 int GL_SYNC_CL_EVENT_ARB = 0x8240;
46
47 /** Returned in &lt;values&gt; for GetSynciv &lt;pname&gt; SYNC_CONDITION. */
48 int GL_SYNC_CL_EVENT_COMPLETE_ARB = 0x8241;
49
50 @PointerWrapper("GLsync")
51 GLSync glCreateSyncFromCLeventARB(@PointerWrapper("cl_context") CLContext context, @PointerWrapper("cl_event") CLEvent event, @GLbitfield int flags);
52
53 }
3030 */
3131 package org.lwjgl.opengl;
3232
33 import org.lwjgl.util.generator.GLenum;
33 import org.lwjgl.util.generator.opengl.GLenum;
3434
3535 public interface ARB_color_buffer_float {
3636
3030 */
3131 package org.lwjgl.opengl;
3232
33 import org.lwjgl.util.generator.GLenum;
34 import org.lwjgl.util.generator.GLintptr;
35 import org.lwjgl.util.generator.GLsizeiptr;
33 import org.lwjgl.util.generator.Reuse;
34 import org.lwjgl.util.generator.opengl.GLenum;
35 import org.lwjgl.util.generator.opengl.GLintptr;
36 import org.lwjgl.util.generator.opengl.GLsizeiptr;
3637
3738 public interface ARB_copy_buffer {
3839
4647 int GL_COPY_READ_BUFFER = 0x8F36;
4748 int GL_COPY_WRITE_BUFFER = 0x8F37;
4849
50 @Reuse("GL31")
4951 void glCopyBufferSubData(@GLenum int readTarget, @GLenum int writeTarget,
5052 @GLintptr long readOffset, @GLintptr long writeOffset,
5153 @GLsizeiptr long size);
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 import org.lwjgl.util.generator.opengl.GLchar;
35 import org.lwjgl.util.generator.opengl.GLenum;
36 import org.lwjgl.util.generator.opengl.GLsizei;
37 import org.lwjgl.util.generator.opengl.GLuint;
38
39 import java.nio.ByteBuffer;
40 import java.nio.IntBuffer;
41
42 public interface ARB_debug_output {
43
44 /**
45 * Tokens accepted by the &lt;target&gt; parameters of Enable, Disable,
46 * and IsEnabled:
47 */
48 int GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB = 0x8242;
49
50 /**
51 * Tokens accepted by the &lt;value&gt; parameters of GetBooleanv,
52 * GetIntegerv, GetFloatv, and GetDoublev:
53 */
54 int GL_MAX_DEBUG_MESSAGE_LENGTH_ARB = 0x9143,
55 GL_MAX_DEBUG_LOGGED_MESSAGES_ARB = 0x9144,
56 GL_DEBUG_LOGGED_MESSAGES_ARB = 0x9145,
57 GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB = 0x8243;
58
59 /** Tokens accepted by the &lt;pname&gt; parameter of GetPointerv: */
60 int GL_DEBUG_CALLBACK_FUNCTION_ARB = 0x8244,
61 GL_DEBUG_CALLBACK_USER_PARAM_ARB = 0x8245;
62
63 /**
64 * Tokens accepted or provided by the &lt;source&gt; parameters of
65 * DebugMessageControlARB, DebugMessageInsertARB and DEBUGPROCARB,
66 * and the &lt;sources&gt; parameter of GetDebugMessageLogARB:
67 */
68 int GL_DEBUG_SOURCE_API_ARB = 0x8246,
69 GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB = 0x8247,
70 GL_DEBUG_SOURCE_SHADER_COMPILER_ARB = 0x8248,
71 GL_DEBUG_SOURCE_THIRD_PARTY_ARB = 0x8249,
72 GL_DEBUG_SOURCE_APPLICATION_ARB = 0x824A,
73 GL_DEBUG_SOURCE_OTHER_ARB = 0x824B;
74
75 /**
76 * Tokens accepted or provided by the &lt;type&gt; parameters of
77 * DebugMessageControlARB, DebugMessageInsertARB and DEBUGPROCARB,
78 * and the &lt;types&gt; parameter of GetDebugMessageLogARB:
79 */
80 int GL_DEBUG_TYPE_ERROR_ARB = 0x824C,
81 GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB = 0x824D,
82 GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB = 0x824E,
83 GL_DEBUG_TYPE_PORTABILITY_ARB = 0x824F,
84 GL_DEBUG_TYPE_PERFORMANCE_ARB = 0x8250,
85 GL_DEBUG_TYPE_OTHER_ARB = 0x8251;
86
87 /**
88 * Tokens accepted or provided by the &lt;severity&gt; parameters of
89 * DebugMessageControlARB, DebugMessageInsertARB and DEBUGPROCARB
90 * callback functions, and the &lt;severities&gt; parameter of
91 * GetDebugMessageLogARB:
92 */
93 int GL_DEBUG_SEVERITY_HIGH_ARB = 0x9146,
94 GL_DEBUG_SEVERITY_MEDIUM_ARB = 0x9147,
95 GL_DEBUG_SEVERITY_LOW_ARB = 0x9148;
96
97 void glDebugMessageControlARB(@GLenum int source,
98 @GLenum int type,
99 @GLenum int severity,
100 @AutoSize(value = "ids", canBeNull = true) @GLsizei int count,
101 @Check(canBeNull = true) @Const @GLuint IntBuffer ids,
102 boolean enabled);
103
104 void glDebugMessageInsertARB(@GLenum int source, @GLenum int type, @GLuint int id, @GLenum int severity, @AutoSize("buf") @GLsizei int length, @Const @GLchar ByteBuffer buf);
105
106 @Alternate("glDebugMessageInsertARB")
107 void glDebugMessageInsertARB(@GLenum int source, @GLenum int type, @GLuint int id, @GLenum int severity, @Constant("buf.length()") @GLsizei int length, CharSequence buf);
108
109 /**
110 * The {@code ARBDebugOutputCallback.Handler} implementation passed to this method will be used for
111 * ARB_debug_output messages. If callback is null, any previously registered handler for the current
112 * thread will be unregistered and stop receiving messages.
113 *
114 * @param callback the callback function to use
115 */
116 @Code(
117 // Create a GlobalRef to the callback object and register it with the current context.
118 javaBeforeNative = "\t\tlong userParam = callback == null ? 0 : CallbackUtil.createGlobalRef(callback.getHandler());\n" +
119 "\t\tCallbackUtil.registerContextCallbackARB(userParam);"
120 )
121 void glDebugMessageCallbackARB(@PointerWrapper(value = "GLDEBUGPROCARB", canBeNull = true) ARBDebugOutputCallback callback,
122 @Constant("userParam") @PointerWrapper("GLvoid *") long userParam);
123
124 @GLuint
125 int glGetDebugMessageLogARB(@GLuint int count,
126 @AutoSize(value = "messageLog", canBeNull = true) @GLsizei int logSize,
127 @Check(value = "count", canBeNull = true) @GLenum IntBuffer sources,
128 @Check(value = "count", canBeNull = true) @GLenum IntBuffer types,
129 @Check(value = "count", canBeNull = true) @GLuint IntBuffer ids,
130 @Check(value = "count", canBeNull = true) @GLenum IntBuffer severities,
131 @Check(value = "count", canBeNull = true) @GLsizei IntBuffer lengths,
132 @Check(canBeNull = true) @OutParameter @GLchar ByteBuffer messageLog);
133
134 // Not really useful and a pain to implement in Java
135 //void glGetPointerv(@GLenum int pname, void**params);
136
137 }
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
35 import org.lwjgl.util.generator.opengl.GLenum;
36 import org.lwjgl.util.generator.opengl.GLsizei;
3437
3538 import java.nio.*;
3639
6164 void glDrawBuffersARB(@AutoSize("buffers") @GLsizei int size, @Const @GLenum IntBuffer buffers);
6265
6366 @Alternate("glDrawBuffersARB")
64 void glDrawBuffersARB(@Constant("1") @GLsizei int size, @Constant(value = "APIUtils.getBufferInt().put(0, buffer), 0", keepParam = true) int buffer);
67 void glDrawBuffersARB(@Constant("1") @GLsizei int size, @Constant(value = "APIUtil.getBufferInt().put(0, buffer), 0", keepParam = true) int buffer);
6568 }
3030 */
3131 package org.lwjgl.opengl;
3232
33 import org.lwjgl.util.generator.GLenum;
34 import org.lwjgl.util.generator.GLuint;
33 import org.lwjgl.util.generator.opengl.GLenum;
34 import org.lwjgl.util.generator.opengl.GLuint;
3535
3636 public interface ARB_draw_buffers_blend {
3737
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.*;
3435
3536 import java.nio.Buffer;
3637
3738 public interface ARB_draw_elements_base_vertex {
3839
40 @Reuse("GL32")
3941 void glDrawElementsBaseVertex(@GLenum int mode, @AutoSize("indices") @GLsizei int count, @AutoType("indices") @GLenum int type,
4042 @BufferObject(BufferKind.ElementVBO)
4143 @Const
4345 @GLushort
4446 @GLuint Buffer indices, int basevertex);
4547
48 @Reuse("GL32")
4649 void glDrawRangeElementsBaseVertex(@GLenum int mode, @GLuint int start, @GLuint int end, @AutoSize("indices") @GLsizei int count, @AutoType("indices") @GLenum int type,
4750 @BufferObject(BufferKind.ElementVBO)
4851 @Const
5053 @GLushort
5154 @GLuint Buffer indices, int basevertex);
5255
56 @Reuse("GL32")
5357 void glDrawElementsInstancedBaseVertex(@GLenum int mode, @AutoSize("indices") @GLsizei int count, @AutoType("indices") @GLenum int type,
5458 @BufferObject(BufferKind.ElementVBO)
5559 @Const
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.GLenum;
35 import org.lwjgl.util.generator.opengl.GLvoid;
3436
3537 import java.nio.IntBuffer;
3638
5355 */
5456 int GL_DRAW_INDIRECT_BUFFER_BINDING = 0x8F43;
5557
58 @Reuse("GL40")
5659 void glDrawArraysIndirect(@GLenum int mode, @BufferObject(BufferKind.IndirectBO) @Check("4") @NullTerminated @Const @GLvoid(PrimitiveType.Kind.INT) IntBuffer indirect);
5760
61 @Reuse("GL40")
5862 void glDrawElementsIndirect(@GLenum int mode, @GLenum int type, @BufferObject(BufferKind.IndirectBO) @Check("5") @NullTerminated @Const @GLvoid(PrimitiveType.Kind.INT) IntBuffer indirect);
5963
6064 }
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.*;
3435
3536 import java.nio.Buffer;
3637
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
35 import org.lwjgl.util.generator.opengl.*;
3436
3537 import java.nio.IntBuffer;
3638
183185 /** Accepted by the &lt;value&gt; parameter of GetTexLevelParameter: */
184186 int GL_TEXTURE_STENCIL_SIZE = 0x88F1;
185187
188 @Reuse("GL30")
186189 boolean glIsRenderbuffer(@GLuint int renderbuffer);
187190
191 @Reuse("GL30")
188192 void glBindRenderbuffer(@GLenum int target, @GLuint int renderbuffer);
189193
194 @Reuse("GL30")
190195 void glDeleteRenderbuffers(@AutoSize("renderbuffers") @GLsizei int n, @Const @GLuint IntBuffer renderbuffers);
191196
197 @Reuse("GL30")
192198 @Alternate("glDeleteRenderbuffers")
193 void glDeleteRenderbuffers(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, renderbuffer), 0", keepParam = true) int renderbuffer);
194
199 void glDeleteRenderbuffers(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, renderbuffer), 0", keepParam = true) int renderbuffer);
200
201 @Reuse("GL30")
195202 void glGenRenderbuffers(@AutoSize("renderbuffers") @GLsizei int n, @OutParameter @GLuint IntBuffer renderbuffers);
196203
204 @Reuse("GL30")
197205 @Alternate("glGenRenderbuffers")
198206 @GLreturn("renderbuffers")
199207 void glGenRenderbuffers2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer renderbuffers);
200208
209 @Reuse("GL30")
201210 void glRenderbufferStorage(@GLenum int target, @GLenum int internalformat,
202211 @GLsizei int width, @GLsizei int height);
203212
213 @Reuse("GL30")
204214 void glRenderbufferStorageMultisample(@GLenum int target, @GLsizei int samples,
205215 @GLenum int internalformat,
206216 @GLsizei int width, @GLsizei int height);
207217
218 @Reuse("GL30")
208219 @StripPostfix("params")
209220 void glGetRenderbufferParameteriv(@GLenum int target, @GLenum int pname, @Check("4") @OutParameter IntBuffer params);
210221
222 @Reuse("GL30")
211223 @Alternate("glGetRenderbufferParameteriv")
212224 @GLreturn("params")
213225 @StripPostfix("params")
214226 void glGetRenderbufferParameteriv2(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
215227
228 @Reuse("GL30")
216229 boolean glIsFramebuffer(@GLuint int framebuffer);
217230
231 @Reuse("GL30")
218232 void glBindFramebuffer(@GLenum int target, @GLuint int framebuffer);
219233
234 @Reuse("GL30")
220235 void glDeleteFramebuffers(@AutoSize("framebuffers") @GLsizei int n, @Const @GLuint IntBuffer framebuffers);
221236
237 @Reuse("GL30")
222238 @Alternate("glDeleteFramebuffers")
223 void glDeleteFramebuffers(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, framebuffer), 0", keepParam = true) int framebuffer);
224
239 void glDeleteFramebuffers(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, framebuffer), 0", keepParam = true) int framebuffer);
240
241 @Reuse("GL30")
225242 void glGenFramebuffers(@AutoSize("framebuffers") @GLsizei int n, @OutParameter @GLuint IntBuffer framebuffers);
226243
244 @Reuse("GL30")
227245 @Alternate("glGenFramebuffers")
228246 @GLreturn("framebuffers")
229247 void glGenFramebuffers2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer framebuffers);
230248
249 @Reuse("GL30")
231250 @GLenum
232251 int glCheckFramebufferStatus(@GLenum int target);
233252
253 @Reuse("GL30")
234254 void glFramebufferTexture1D(@GLenum int target, @GLenum int attachment,
235255 @GLenum int textarget, @GLuint int texture, int level);
236256
257 @Reuse("GL30")
237258 void glFramebufferTexture2D(@GLenum int target, @GLenum int attachment,
238259 @GLenum int textarget, @GLuint int texture, int level);
239260
261 @Reuse("GL30")
240262 void glFramebufferTexture3D(@GLenum int target, @GLenum int attachment,
241263 @GLenum int textarget, @GLuint int texture,
242264 int level, int layer);
243265
266 @Reuse("GL30")
244267 void glFramebufferTextureLayer(@GLenum int target, @GLenum int attachment,
245268 @GLuint int texture, int level, int layer);
246269
270 @Reuse("GL30")
247271 void glFramebufferRenderbuffer(@GLenum int target, @GLenum int attachment,
248272 @GLenum int renderbuffertarget, @GLuint int renderbuffer);
249273
274 @Reuse("GL30")
250275 @StripPostfix("params")
251276 void glGetFramebufferAttachmentParameteriv(@GLenum int target, @GLenum int attachment,
252277 @GLenum int pname, @Check("4") @OutParameter IntBuffer params);
253278
279 @Reuse("GL30")
254280 @Alternate("glGetFramebufferAttachmentParameteriv")
255281 @GLreturn("params")
256282 @StripPostfix("params")
257283 void glGetFramebufferAttachmentParameteriv2(@GLenum int target, @GLenum int attachment,
258284 @GLenum int pname, @OutParameter IntBuffer params);
259285
286 @Reuse("GL30")
260287 void glBlitFramebuffer(int srcX0, int srcY0, int srcX1, int srcY1,
261288 int dstX0, int dstY0, int dstX1, int dstY1,
262289 @GLbitfield int mask, @GLenum int filter);
263290
291 @Reuse("GL30")
264292 void glGenerateMipmap(@GLenum int target);
265293
266294 }
3030 */
3131 package org.lwjgl.opengl;
3232
33 import org.lwjgl.util.generator.GLenum;
34 import org.lwjgl.util.generator.GLuint;
33 import org.lwjgl.util.generator.opengl.GLenum;
34 import org.lwjgl.util.generator.opengl.GLuint;
3535
3636 public interface ARB_geometry_shader4 {
3737
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 import org.lwjgl.util.generator.opengl.GLenum;
35 import org.lwjgl.util.generator.opengl.GLsizei;
36 import org.lwjgl.util.generator.opengl.GLuint;
37 import org.lwjgl.util.generator.opengl.GLvoid;
38
39 import java.nio.ByteBuffer;
40 import java.nio.IntBuffer;
41
42 public interface ARB_get_program_binary {
43
44 /**
45 * Accepted by the &lt;pname&gt; parameter of ProgramParameteri and
46 * GetProgramiv:
47 */
48 int GL_PROGRAM_BINARY_RETRIEVABLE_HINT = 0x8257;
49
50 /** Accepted by the &lt;pname&gt; parameter of GetProgramiv: */
51 int GL_PROGRAM_BINARY_LENGTH = 0x8741;
52
53 /**
54 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
55 * GetInteger64v, GetFloatv and GetDoublev:
56 */
57 int GL_NUM_PROGRAM_BINARY_FORMATS = 0x87FE,
58 GL_PROGRAM_BINARY_FORMATS = 0x87FF;
59
60 @Reuse("GL41")
61 void glGetProgramBinary(@GLuint int program, @AutoSize("binary") @GLsizei int bufSize,
62 @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length,
63 @Check("1") @GLenum IntBuffer binaryFormat,
64 @OutParameter @GLvoid ByteBuffer binary);
65
66 @Reuse("GL41")
67 void glProgramBinary(@GLuint int program, @GLenum int binaryFormat, @Const @GLvoid ByteBuffer binary, @AutoSize("binary") @GLsizei int length);
68
69 @Reuse("GL41")
70 void glProgramParameteri(@GLuint int program, @GLenum int pname, int value);
71
72 }
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.GLsizei;
35 import org.lwjgl.util.generator.opengl.GLuint;
3436
3537 import java.nio.*;
3638
5658 int GL_DOUBLE_MAT4x2 = 0x8F4D;
5759 int GL_DOUBLE_MAT4x3 = 0x8F4E;
5860
61 @Reuse("GL40")
5962 void glUniform1d(int location, double x);
6063
64 @Reuse("GL40")
6165 void glUniform2d(int location, double x, double y);
6266
67 @Reuse("GL40")
6368 void glUniform3d(int location, double x, double y, double z);
6469
70 @Reuse("GL40")
6571 void glUniform4d(int location, double x, double y, double z, double w);
6672
73 @Reuse("GL40")
6774 @StripPostfix("value")
6875 void glUniform1dv(int location, @AutoSize("value") @GLsizei int count, @Const DoubleBuffer value);
6976
77 @Reuse("GL40")
7078 @StripPostfix("value")
7179 void glUniform2dv(int location, @AutoSize(value = "value", expression = " >> 1") @GLsizei int count, @Const DoubleBuffer value);
7280
81 @Reuse("GL40")
7382 @StripPostfix("value")
7483 void glUniform3dv(int location, @AutoSize(value = "value", expression = " / 3") @GLsizei int count, @Const DoubleBuffer value);
7584
85 @Reuse("GL40")
7686 @StripPostfix("value")
7787 void glUniform4dv(int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, @Const DoubleBuffer value);
7888
89 @Reuse("GL40")
7990 @StripPostfix("value")
8091 void glUniformMatrix2dv(int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
8192
93 @Reuse("GL40")
8294 @StripPostfix("value")
8395 void glUniformMatrix3dv(int location, @AutoSize(value = "value", expression = " / (3 * 3)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
8496
97 @Reuse("GL40")
8598 @StripPostfix("value")
8699 void glUniformMatrix4dv(int location, @AutoSize(value = "value", expression = " >> 4") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
87100
101 @Reuse("GL40")
88102 @StripPostfix("value")
89103 void glUniformMatrix2x3dv(int location, @AutoSize(value = "value", expression = " / (2 * 3)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
90104
105 @Reuse("GL40")
91106 @StripPostfix("value")
92107 void glUniformMatrix2x4dv(int location, @AutoSize(value = "value", expression = " >> 3") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
93108
109 @Reuse("GL40")
94110 @StripPostfix("value")
95111 void glUniformMatrix3x2dv(int location, @AutoSize(value = "value", expression = " / (3 * 2)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
96112
113 @Reuse("GL40")
97114 @StripPostfix("value")
98115 void glUniformMatrix3x4dv(int location, @AutoSize(value = "value", expression = " / (3 * 4)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
99116
117 @Reuse("GL40")
100118 @StripPostfix("value")
101119 void glUniformMatrix4x2dv(int location, @AutoSize(value = "value", expression = " >> 3") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
102120
121 @Reuse("GL40")
103122 @StripPostfix("value")
104123 void glUniformMatrix4x3dv(int location, @AutoSize(value = "value", expression = " / (4 * 3)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
105124
125 @Reuse("GL40")
106126 @StripPostfix("params")
107127 void glGetUniformdv(@GLuint int program, int location, @OutParameter @Check DoubleBuffer params);
108128
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.*;
3435
3536 import java.nio.*;
3637
3940 * The GL12 imaging subset extension.
4041 *
4142 * @author cix_foo <cix_foo@users.sourceforge.net>
42 * @version $Revision: 3116 $
43 * $Id: ARB_imaging.java 3116 2008-08-19 16:46:03Z spasi $
43 * @version $Revision: 3412 $
44 * $Id: ARB_imaging.java 3412 2010-09-26 23:43:24Z spasi $
4445 */
4546
4647 @Extension(postfix = "")
172173 @DeprecatedGL
173174 void glGetColorTableParameterfv(@GLenum int target, @GLenum int pname, @Check("4") FloatBuffer params);
174175
176 @Reuse("GL14")
175177 void glBlendEquation(@GLenum int mode);
176178
179 @Reuse("GL14")
177180 void glBlendColor(@GLclampf float red, @GLclampf float green, @GLclampf float blue, @GLclampf float alpha);
178181
179182 @DeprecatedGL
3030 */
3131 package org.lwjgl.opengl;
3232
33 import org.lwjgl.util.generator.GLuint;
33 import org.lwjgl.util.generator.opengl.GLuint;
3434
3535 public interface ARB_instanced_arrays {
3636
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.*;
3435
3536 import java.nio.ByteBuffer;
3637
5859 *
5960 * @return A ByteBuffer representing the mapped buffer memory.
6061 */
62 @Reuse("GL30")
6163 @CachedResult(isRange = true)
6264 @GLvoid
63 @AutoResultSize("length")
65 @AutoSize("length")
6466 ByteBuffer glMapBufferRange(@GLenum int target, @GLintptr long offset, @GLsizeiptr long length, @GLbitfield int access);
6567
68 @Reuse("GL30")
6669 void glFlushMappedBufferRange(@GLenum int target, @GLintptr long offset, @GLsizeiptr long length);
6770
6871 }
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.*;
3435
3536 import java.nio.*;
3637
3030 */
3131 package org.lwjgl.opengl;
3232
33 import org.lwjgl.util.generator.*;
33 import org.lwjgl.util.generator.opengl.GLclampf;
3434
3535 public interface ARB_multisample {
3636
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.GLenum;
3435
3536 public interface ARB_multitexture {
3637
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
35 import org.lwjgl.util.generator.opengl.GLenum;
36 import org.lwjgl.util.generator.opengl.GLreturn;
37 import org.lwjgl.util.generator.opengl.GLsizei;
38 import org.lwjgl.util.generator.opengl.GLuint;
3439
3540 import java.nio.IntBuffer;
3641
6267 void glDeleteQueriesARB(@AutoSize("ids") @GLsizei int n, @GLuint IntBuffer ids);
6368
6469 @Alternate("glDeleteQueriesARB")
65 void glDeleteQueriesARB(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, id), 0", keepParam = true) int id);
70 void glDeleteQueriesARB(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, id), 0", keepParam = true) int id);
6671
6772 boolean glIsQueryARB(@GLuint int id);
6873
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.GLenum;
3435
3536 import java.nio.*;
3637
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
35 import org.lwjgl.util.generator.opengl.*;
3436
3537 import java.nio.*;
3638
125127 void glDeleteProgramsARB(@AutoSize("programs") @GLsizei int n, @Const @GLuint IntBuffer programs);
126128
127129 @Alternate("glDeleteProgramsARB")
128 void glDeleteProgramsARB(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, program), 0", keepParam = true) int program);
130 void glDeleteProgramsARB(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, program), 0", keepParam = true) int program);
129131
130132 void glGenProgramsARB(@AutoSize("programs") @GLsizei int n, @OutParameter @GLuint IntBuffer programs);
131133
3030 */
3131 package org.lwjgl.opengl;
3232
33 import org.lwjgl.util.generator.GLenum;
33 import org.lwjgl.util.generator.Reuse;
34 import org.lwjgl.util.generator.opengl.GLenum;
3435
3536 public interface ARB_provoking_vertex {
3637
4546 int GL_PROVOKING_VERTEX = 0x8E4F;
4647 int GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION = 0x8E4C;
4748
49 @Reuse("GL32")
4850 void glProvokingVertex(@GLenum int mode);
4951
5052 }
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 import org.lwjgl.util.generator.opengl.*;
35
36 import java.nio.*;
37
38 @Dependent
39 @DeprecatedGL
40 public interface ARB_robustness {
41
42 /** Returned by GetGraphicsResetStatusARB: */
43 int GL_NO_ERROR = 0x0000,
44 GL_GUILTY_CONTEXT_RESET_ARB = 0x8253,
45 GL_INNOCENT_CONTEXT_RESET_ARB = 0x8254,
46 GL_UNKNOWN_CONTEXT_RESET_ARB = 0x8255;
47
48 /**
49 * Accepted by the &lt;value&gt; parameter of GetBooleanv, GetIntegerv,
50 * GetInteger64v, GetFloatv, and GetDoublev:
51 */
52 int GL_RESET_NOTIFICATION_STRATEGY_ARB = 0x8256;
53
54 /**
55 * Returned by GetIntegerv and related simple queries when
56 * &lt;value&gt; is RESET_NOTIFICATION_STRATEGY_ARB:
57 */
58 int GL_LOSE_CONTEXT_ON_RESET_ARB = 0x8252,
59 GL_NO_RESET_NOTIFICATION_ARB = 0x8261;
60
61 /** Returned by GetIntegerv when &lt;pname&gt; is CONTEXT_FLAGS: */
62 int GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB = 0x00000004;
63
64 @GLenum
65 int glGetGraphicsResetStatusARB();
66
67 @DeprecatedGL
68 void glGetnMapdvARB(@GLenum int target, @GLenum int query, @Constant("v.remaining() << 3") @GLsizei int bufSize, @OutParameter @Check DoubleBuffer v);
69
70 @DeprecatedGL
71 void glGetnMapfvARB(@GLenum int target, @GLenum int query, @Constant("v.remaining() << 2") @GLsizei int bufSize, @OutParameter @Check FloatBuffer v);
72
73 @DeprecatedGL
74 void glGetnMapivARB(@GLenum int target, @GLenum int query, @Constant("v.remaining() << 2") @GLsizei int bufSize, @OutParameter @Check IntBuffer v);
75
76 @DeprecatedGL
77 void glGetnPixelMapfvARB(@GLenum int map, @Constant("values.remaining() << 2") @GLsizei int bufSize, @OutParameter @Check FloatBuffer values);
78
79 @DeprecatedGL
80 void glGetnPixelMapuivARB(@GLenum int map, @Constant("values.remaining() << 2") @GLsizei int bufSize, @OutParameter @Check @GLuint IntBuffer values);
81
82 @DeprecatedGL
83 void glGetnPixelMapusvARB(@GLenum int map, @Constant("values.remaining() << 1") @GLsizei int bufSize, @OutParameter @Check @GLushort ShortBuffer values);
84
85 @DeprecatedGL
86 void glGetnPolygonStippleARB(@AutoSize("pattern") @GLsizei int bufSize, @OutParameter @GLubyte ByteBuffer pattern);
87
88 void glGetnTexImageARB(@GLenum int target, int level, @GLenum int format, @GLenum int type, @AutoSize("img") @GLsizei int bufSize,
89 @OutParameter
90 @BufferObject(BufferKind.PackPBO)
91 @GLbyte
92 @GLshort
93 @GLint
94 @GLfloat
95 @GLdouble Buffer img);
96
97 void glReadnPixelsARB(int x, int y, @GLsizei int width, @GLsizei int height,
98 @GLenum int format, @GLenum int type, @AutoSize("data") @GLsizei int bufSize,
99 @OutParameter
100 @BufferObject(BufferKind.PackPBO)
101 @GLbyte
102 @GLshort
103 @GLint
104 @GLfloat
105 @GLdouble Buffer data);
106
107 @Dependent("GL_ARB_imaging")
108 void glGetnColorTableARB(@GLenum int target, @GLenum int format, @GLenum int type, @AutoSize("table") @GLsizei int bufSize,
109 @OutParameter
110 @GLbyte
111 @GLfloat
112 @GLdouble Buffer table);
113
114 @Dependent("GL_ARB_imaging")
115 void glGetnConvolutionFilterARB(@GLenum int target, @GLenum int format, @GLenum int type, @AutoSize("image") @GLsizei int bufSize,
116 @OutParameter
117 @BufferObject(BufferKind.PackPBO)
118 @GLbyte
119 @GLshort
120 @GLint
121 @GLfloat
122 @GLdouble Buffer image);
123
124 @Dependent("GL_ARB_imaging")
125 void glGetnSeparableFilterARB(@GLenum int target, @GLenum int format, @GLenum int type,
126 @AutoSize("row") @GLsizei int rowBufSize,
127 @OutParameter
128 @BufferObject(BufferKind.PackPBO)
129 @GLbyte
130 @GLshort
131 @GLint
132 @GLfloat
133 @GLdouble Buffer row,
134 @AutoSize("column") @GLsizei int columnBufSize,
135 @OutParameter
136 @BufferObject(BufferKind.PackPBO)
137 @GLbyte
138 @GLshort
139 @GLint
140 @GLfloat
141 @GLdouble Buffer column,
142 @OutParameter
143 @BufferObject(BufferKind.PackPBO)
144 @Check
145 @GLbyte
146 @GLshort
147 @GLint
148 @GLfloat
149 @GLdouble Buffer span);
150
151 @Dependent("GL_ARB_imaging")
152 void glGetnHistogramARB(@GLenum int target, boolean reset, @GLenum int format, @GLenum int type, @AutoSize("values") @GLsizei int bufSize,
153 @OutParameter
154 @BufferObject(BufferKind.PackPBO)
155 @GLbyte
156 @GLshort
157 @GLint
158 @GLfloat
159 @GLdouble Buffer values);
160
161 @Dependent("GL_ARB_imaging")
162 void glGetnMinmaxARB(@GLenum int target, boolean reset, @GLenum int format, @GLenum int type, @AutoSize("values") @GLsizei int bufSize,
163 @OutParameter
164 @BufferObject(BufferKind.PackPBO)
165 @GLbyte
166 @GLshort
167 @GLint
168 @GLfloat
169 @GLdouble Buffer values);
170
171 @Dependent("OpenGL13")
172 void glGetnCompressedTexImageARB(@GLenum int target, int lod, @AutoSize("img") @GLsizei int bufSize,
173 @OutParameter
174 @BufferObject(BufferKind.PackPBO)
175 @GLbyte
176 @GLshort
177 @GLint Buffer img);
178
179 @Dependent("OpenGL20")
180 void glGetnUniformfvARB(@GLuint int program, int location, @Constant("params.remaining() << 2") @GLsizei int bufSize, @OutParameter @Check FloatBuffer params);
181
182 @Dependent("OpenGL20")
183 void glGetnUniformivARB(@GLuint int program, int location, @Constant("params.remaining() << 2") @GLsizei int bufSize, @OutParameter @Check IntBuffer params);
184
185 @Dependent("OpenGL20")
186 void glGetnUniformuivARB(@GLuint int program, int location, @Constant("params.remaining() << 2") @GLsizei int bufSize, @OutParameter @Check @GLuint IntBuffer params);
187
188 @Dependent("OpenGL20")
189 void glGetnUniformdvARB(@GLuint int program, int location, @Constant("params.remaining() << 3") @GLsizei int bufSize, @OutParameter @Check DoubleBuffer params);
190 }
3030 */
3131 package org.lwjgl.opengl;
3232
33 import org.lwjgl.util.generator.GLclampf;
33 import org.lwjgl.util.generator.opengl.GLclampf;
3434
3535 public interface ARB_sample_shading {
3636
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
35 import org.lwjgl.util.generator.opengl.GLenum;
36 import org.lwjgl.util.generator.opengl.GLreturn;
37 import org.lwjgl.util.generator.opengl.GLsizei;
38 import org.lwjgl.util.generator.opengl.GLuint;
3439
3540 import java.nio.FloatBuffer;
3641 import java.nio.IntBuffer;
4449 */
4550 int GL_SAMPLER_BINDING = 0x8919;
4651
52 @Reuse("GL33")
4753 void glGenSamplers(@AutoSize("samplers") @GLsizei int count, @OutParameter @GLuint IntBuffer samplers);
4854
55 @Reuse("GL33")
4956 @Alternate("glGenSamplers")
5057 @GLreturn("samplers")
5158 void glGenSamplers2(@Constant("1") @GLsizei int count, @OutParameter @GLuint IntBuffer samplers);
5259
60 @Reuse("GL33")
5361 void glDeleteSamplers(@AutoSize("samplers") @GLsizei int count, @Const @GLuint IntBuffer samplers);
5462
63 @Reuse("GL33")
5564 @Alternate("glDeleteSamplers")
56 void glDeleteSamplers(@Constant("1") @GLsizei int count, @Constant(value = "APIUtils.getBufferInt().put(0, sampler), 0", keepParam = true) int sampler);
65 void glDeleteSamplers(@Constant("1") @GLsizei int count, @Constant(value = "APIUtil.getBufferInt().put(0, sampler), 0", keepParam = true) int sampler);
5766
67 @Reuse("GL33")
5868 boolean glIsSampler(@GLuint int sampler);
5969
70 @Reuse("GL33")
6071 void glBindSampler(@GLenum int unit, @GLuint int sampler);
6172
73 @Reuse("GL33")
6274 void glSamplerParameteri(@GLuint int sampler, @GLenum int pname, int param);
6375
76 @Reuse("GL33")
6477 void glSamplerParameterf(@GLuint int sampler, @GLenum int pname, float param);
6578
79 @Reuse("GL33")
6680 @StripPostfix("params")
6781 void glSamplerParameteriv(@GLuint int sampler, @GLenum int pname, @Check("4") @Const IntBuffer params);
6882
83 @Reuse("GL33")
6984 @StripPostfix("params")
7085 void glSamplerParameterfv(@GLuint int sampler, @GLenum int pname, @Check("4") @Const FloatBuffer params);
7186
87 @Reuse("GL33")
7288 @StripPostfix("params")
7389 void glSamplerParameterIiv(@GLuint int sampler, @GLenum int pname, @Check("4") @Const IntBuffer params);
7490
91 @Reuse("GL33")
7592 @StripPostfix("params")
7693 void glSamplerParameterIuiv(@GLuint int sampler, @GLenum int pname, @Check("4") @Const @GLuint IntBuffer params);
7794
95 @Reuse("GL33")
7896 @StripPostfix("params")
7997 void glGetSamplerParameteriv(@GLuint int sampler, @GLenum int pname, @Check("4") @OutParameter IntBuffer params);
8098
99 @Reuse("GL33")
81100 @Alternate("glGetSamplerParameteriv")
82101 @GLreturn("params")
83102 @StripPostfix(value = "params", postfix = "v")
84103 void glGetSamplerParameteriv2(@GLuint int sampler, @GLenum int pname, @OutParameter IntBuffer params);
85104
105 @Reuse("GL33")
86106 @StripPostfix("params")
87107 void glGetSamplerParameterfv(@GLuint int sampler, @GLenum int pname, @Check("4") @OutParameter FloatBuffer params);
88108
109 @Reuse("GL33")
89110 @Alternate("glGetSamplerParameterfv")
90111 @GLreturn("params")
91112 @StripPostfix(value = "params", postfix = "v")
92113 void glGetSamplerParameterfv2(@GLuint int sampler, @GLenum int pname, @OutParameter FloatBuffer params);
93114
115 @Reuse("GL33")
94116 @StripPostfix("params")
95117 void glGetSamplerParameterIiv(@GLuint int sampler, @GLenum int pname, @Check("4") @OutParameter IntBuffer params);
96118
119 @Reuse("GL33")
97120 @Alternate("glGetSamplerParameterIiv")
98121 @GLreturn("params")
99122 @StripPostfix(value = "params", postfix = "v")
100123 void glGetSamplerParameterIiv2(@GLuint int sampler, @GLenum int pname, @OutParameter IntBuffer params);
101124
125 @Reuse("GL33")
102126 @StripPostfix("params")
103127 void glGetSamplerParameterIuiv(@GLuint int sampler, @GLenum int pname, @Check("4") @OutParameter IntBuffer params);
104128
129 @Reuse("GL33")
105130 @Alternate("glGetSamplerParameterIuiv")
106131 @GLreturn("params")
107132 @StripPostfix(value = "params", postfix = "v")
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 import org.lwjgl.util.generator.Alternate;
35 import org.lwjgl.util.generator.opengl.*;
36
37 import java.nio.ByteBuffer;
38 import java.nio.DoubleBuffer;
39 import java.nio.FloatBuffer;
40 import java.nio.IntBuffer;
41
42 @Extension(postfix = "")
43 public interface ARB_separate_shader_objects {
44
45 /** Accepted by &lt;stages&gt; parameter to UseProgramStages: */
46 int GL_VERTEX_SHADER_BIT = 0x00000001,
47 GL_FRAGMENT_SHADER_BIT = 0x00000002,
48 GL_GEOMETRY_SHADER_BIT = 0x00000004,
49 GL_TESS_CONTROL_SHADER_BIT = 0x00000008,
50 GL_TESS_EVALUATION_SHADER_BIT = 0x00000010,
51 GL_ALL_SHADER_BITS = 0xFFFFFFFF;
52
53 /**
54 * Accepted by the &lt;pname&gt; parameter of ProgramParameteri and
55 * GetProgramiv:
56 */
57 int GL_PROGRAM_SEPARABLE = 0x8258;
58
59 /** Accepted by &lt;type&gt; parameter to GetProgramPipelineiv: */
60 int GL_ACTIVE_PROGRAM = 0x8259;
61
62 /**
63 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
64 * GetInteger64v, GetFloatv, and GetDoublev:
65 */
66 int GL_PROGRAM_PIPELINE_BINDING = 0x825A;
67
68 @Reuse("GL41")
69 void glUseProgramStages(@GLuint int pipeline, @GLbitfield int stages, @GLuint int program);
70
71 @Reuse("GL41")
72 void glActiveShaderProgram(@GLuint int pipeline, @GLuint int program);
73
74 @Reuse("GL41")
75 @StripPostfix(value = "strings", postfix = "v")
76 @GLuint
77 int glCreateShaderProgramv(@GLenum int type, @GLsizei int count, @Check @Const @Indirect @GLchar ByteBuffer strings);
78
79 @Reuse("GL41")
80 @Alternate("glCreateShaderProgramv")
81 @StripPostfix(value = "string", postfix = "v")
82 @GLuint
83 int glCreateShaderProgramv(@GLenum int type, @Constant("1") @GLsizei int count, @NullTerminated CharSequence string);
84
85 @Reuse("GL41")
86 @Alternate("glCreateShaderProgramv")
87 @StripPostfix(value = "strings", postfix = "v")
88 @GLuint
89 int glCreateShaderProgramv(@GLenum int type, @Constant("strings.length") @GLsizei int count,
90 @Const @NullTerminated @PointerArray(value = "count") CharSequence[] strings);
91
92 @Reuse("GL41")
93 void glBindProgramPipeline(@GLuint int pipeline);
94
95 @Reuse("GL41")
96 void glDeleteProgramPipelines(@AutoSize("pipelines") @GLsizei int n, @Const @GLuint IntBuffer pipelines);
97
98 @Reuse("GL41")
99 @Alternate("glDeleteProgramPipelines")
100 void glDeleteProgramPipelines(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, pipeline), 0", keepParam = true) int pipeline);
101
102 @Reuse("GL41")
103 void glGenProgramPipelines(@AutoSize("pipelines") @GLsizei int n, @OutParameter @GLuint IntBuffer pipelines);
104
105 @Reuse("GL41")
106 @Alternate("glGenProgramPipelines")
107 @GLreturn("pipelines")
108 void glGenProgramPipelines2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer pipelines);
109
110 @Reuse("GL41")
111 boolean glIsProgramPipeline(@GLuint int pipeline);
112
113 @Reuse("GL41")
114 void glProgramParameteri(@GLuint int program, @GLenum int pname, int value);
115
116 @Reuse("GL41")
117 @StripPostfix("params")
118 void glGetProgramPipelineiv(@GLuint int pipeline, @GLenum int pname, @OutParameter @Check("1") IntBuffer params);
119
120 @Reuse("GL41")
121 @Alternate("glGetProgramPipelineiv")
122 @GLreturn("params")
123 @StripPostfix("params")
124 void glGetProgramPipelineiv2(@GLuint int pipeline, @GLenum int pname, @OutParameter IntBuffer params);
125
126 @Reuse("GL41")
127 void glProgramUniform1i(@GLuint int program, int location, int v0);
128
129 @Reuse("GL41")
130 void glProgramUniform2i(@GLuint int program, int location, int v0, int v1);
131
132 @Reuse("GL41")
133 void glProgramUniform3i(@GLuint int program, int location, int v0, int v1, int v2);
134
135 @Reuse("GL41")
136 void glProgramUniform4i(@GLuint int program, int location, int v0, int v1, int v2, int v3);
137
138 @Reuse("GL41")
139 void glProgramUniform1f(@GLuint int program, int location, float v0);
140
141 @Reuse("GL41")
142 void glProgramUniform2f(@GLuint int program, int location, float v0, float v1);
143
144 @Reuse("GL41")
145 void glProgramUniform3f(@GLuint int program, int location, float v0, float v1, float v2);
146
147 @Reuse("GL41")
148 void glProgramUniform4f(@GLuint int program, int location, float v0, float v1, float v2, float v3);
149
150 @Reuse("GL41")
151 void glProgramUniform1d(@GLuint int program, int location, double v0);
152
153 @Reuse("GL41")
154 void glProgramUniform2d(@GLuint int program, int location, double v0, double v1);
155
156 @Reuse("GL41")
157 void glProgramUniform3d(@GLuint int program, int location, double v0, double v1, double v2);
158
159 @Reuse("GL41")
160 void glProgramUniform4d(@GLuint int program, int location, double v0, double v1, double v2, double v3);
161
162 @Reuse("GL41")
163 @StripPostfix("value")
164 void glProgramUniform1iv(@GLuint int program, int location, @AutoSize("value") @GLsizei int count, @Const IntBuffer value);
165
166 @Reuse("GL41")
167 @StripPostfix("value")
168 void glProgramUniform2iv(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 1") @GLsizei int count, @Const IntBuffer value);
169
170 @Reuse("GL41")
171 @StripPostfix("value")
172 void glProgramUniform3iv(@GLuint int program, int location, @AutoSize(value = "value", expression = " / 3") @GLsizei int count, @Const IntBuffer value);
173
174 @Reuse("GL41")
175 @StripPostfix("value")
176 void glProgramUniform4iv(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, @Const IntBuffer value);
177
178 @Reuse("GL41")
179 @StripPostfix("value")
180 void glProgramUniform1fv(@GLuint int program, int location, @AutoSize("value") @GLsizei int count, @Const FloatBuffer value);
181
182 @Reuse("GL41")
183 @StripPostfix("value")
184 void glProgramUniform2fv(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 1") @GLsizei int count, @Const FloatBuffer value);
185
186 @Reuse("GL41")
187 @StripPostfix("value")
188 void glProgramUniform3fv(@GLuint int program, int location, @AutoSize(value = "value", expression = " / 3") @GLsizei int count, @Const FloatBuffer value);
189
190 @Reuse("GL41")
191 @StripPostfix("value")
192 void glProgramUniform4fv(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, @Const FloatBuffer value);
193
194 @Reuse("GL41")
195 @StripPostfix("value")
196 void glProgramUniform1dv(@GLuint int program, int location, @AutoSize("value") @GLsizei int count, @Const DoubleBuffer value);
197
198 @Reuse("GL41")
199 @StripPostfix("value")
200 void glProgramUniform2dv(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 1") @GLsizei int count, @Const DoubleBuffer value);
201
202 @Reuse("GL41")
203 @StripPostfix("value")
204 void glProgramUniform3dv(@GLuint int program, int location, @AutoSize(value = "value", expression = " / 3") @GLsizei int count, @Const DoubleBuffer value);
205
206 @Reuse("GL41")
207 @StripPostfix("value")
208 void glProgramUniform4dv(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, @Const DoubleBuffer value);
209
210 @Reuse("GL41")
211 void glProgramUniform1ui(@GLuint int program, int location, int v0);
212
213 @Reuse("GL41")
214 void glProgramUniform2ui(@GLuint int program, int location, int v0, int v1);
215
216 @Reuse("GL41")
217 void glProgramUniform3ui(@GLuint int program, int location, int v0, int v1, int v2);
218
219 @Reuse("GL41")
220 void glProgramUniform4ui(@GLuint int program, int location, int v0, int v1, int v2, int v3);
221
222 @Reuse("GL41")
223 @StripPostfix("value")
224 void glProgramUniform1uiv(@GLuint int program, int location, @AutoSize("value") @GLsizei int count, @Const IntBuffer value);
225
226 @Reuse("GL41")
227 @StripPostfix("value")
228 void glProgramUniform2uiv(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 1") @GLsizei int count, @Const IntBuffer value);
229
230 @Reuse("GL41")
231 @StripPostfix("value")
232 void glProgramUniform3uiv(@GLuint int program, int location, @AutoSize(value = "value", expression = " / 3") @GLsizei int count, @Const IntBuffer value);
233
234 @Reuse("GL41")
235 @StripPostfix("value")
236 void glProgramUniform4uiv(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, @Const IntBuffer value);
237
238 @Reuse("GL41")
239 @StripPostfix("value")
240 void glProgramUniformMatrix2fv(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, boolean transpose, @Const FloatBuffer value);
241
242 @Reuse("GL41")
243 @StripPostfix("value")
244 void glProgramUniformMatrix3fv(@GLuint int program, int location, @AutoSize(value = "value", expression = " / (3 * 3)") @GLsizei int count, boolean transpose, @Const FloatBuffer value);
245
246 @Reuse("GL41")
247 @StripPostfix("value")
248 void glProgramUniformMatrix4fv(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 4") @GLsizei int count, boolean transpose, @Const FloatBuffer value);
249
250 @Reuse("GL41")
251 @StripPostfix("value")
252 void glProgramUniformMatrix2dv(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
253
254 @Reuse("GL41")
255 @StripPostfix("value")
256 void glProgramUniformMatrix3dv(@GLuint int program, int location, @AutoSize(value = "value", expression = " / (3 * 3)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
257
258 @Reuse("GL41")
259 @StripPostfix("value")
260 void glProgramUniformMatrix4dv(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 4") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
261
262 @Reuse("GL41")
263 @StripPostfix("value")
264 void glProgramUniformMatrix2x3fv(@GLuint int program, int location,
265 @AutoSize(value = "value", expression = " / (2 * 3)") @GLsizei int count, boolean transpose, @Const FloatBuffer value);
266
267 @Reuse("GL41")
268 @StripPostfix("value")
269 void glProgramUniformMatrix3x2fv(@GLuint int program, int location,
270 @AutoSize(value = "value", expression = " / (3 * 2)") @GLsizei int count, boolean transpose, @Const FloatBuffer value);
271
272 @Reuse("GL41")
273 @StripPostfix("value")
274 void glProgramUniformMatrix2x4fv(@GLuint int program, int location,
275 @AutoSize(value = "value", expression = " >> 3") @GLsizei int count, boolean transpose, @Const FloatBuffer value);
276
277 @Reuse("GL41")
278 @StripPostfix("value")
279 void glProgramUniformMatrix4x2fv(@GLuint int program, int location,
280 @AutoSize(value = "value", expression = " >> 3") @GLsizei int count, boolean transpose, @Const FloatBuffer value);
281
282 @Reuse("GL41")
283 @StripPostfix("value")
284 void glProgramUniformMatrix3x4fv(@GLuint int program, int location,
285 @AutoSize(value = "value", expression = " / (3 * 4)") @GLsizei int count, boolean transpose, @Const FloatBuffer value);
286
287 @Reuse("GL41")
288 @StripPostfix("value")
289 void glProgramUniformMatrix4x3fv(@GLuint int program, int location,
290 @AutoSize(value = "value", expression = " / (4 * 3)") @GLsizei int count, boolean transpose, @Const FloatBuffer value);
291
292 @Reuse("GL41")
293 @StripPostfix("value")
294 void glProgramUniformMatrix2x3dv(@GLuint int program, int location,
295 @AutoSize(value = "value", expression = " / (2 * 3)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
296
297 @Reuse("GL41")
298 @StripPostfix("value")
299 void glProgramUniformMatrix3x2dv(@GLuint int program, int location,
300 @AutoSize(value = "value", expression = " / (3 * 2)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
301
302 @Reuse("GL41")
303 @StripPostfix("value")
304 void glProgramUniformMatrix2x4dv(@GLuint int program, int location,
305 @AutoSize(value = "value", expression = " >> 3") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
306
307 @Reuse("GL41")
308 @StripPostfix("value")
309 void glProgramUniformMatrix4x2dv(@GLuint int program, int location,
310 @AutoSize(value = "value", expression = " >> 3") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
311
312 @Reuse("GL41")
313 @StripPostfix("value")
314 void glProgramUniformMatrix3x4dv(@GLuint int program, int location,
315 @AutoSize(value = "value", expression = " / (3 * 4)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
316
317 @Reuse("GL41")
318 @StripPostfix("value")
319 void glProgramUniformMatrix4x3dv(@GLuint int program, int location,
320 @AutoSize(value = "value", expression = " / (4 * 3)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
321
322 @Reuse("GL41")
323 void glValidateProgramPipeline(@GLuint int pipeline);
324
325 @Reuse("GL41")
326 void glGetProgramPipelineInfoLog(@GLuint int pipeline, @AutoSize("infoLog") @GLsizei int bufSize,
327 @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length,
328 @OutParameter @GLchar ByteBuffer infoLog);
329
330 @Reuse("GL41")
331 @Alternate("glGetProgramPipelineInfoLog")
332 @GLreturn(value = "infoLog", maxLength = "bufSize")
333 void glGetProgramPipelineInfoLog2(@GLuint int pipeline, @GLsizei int bufSize,
334 @OutParameter @GLsizei @Constant("infoLog_length, 0") IntBuffer length,
335 @OutParameter @GLchar ByteBuffer infoLog);
336
337 }
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
35 import org.lwjgl.util.generator.opengl.*;
3436
3537 import java.nio.ByteBuffer;
3638 import java.nio.FloatBuffer;
106108
107109 @Alternate(value = "glShaderSourceARB", nativeAlt = true)
108110 void glShaderSourceARB3(@GLhandleARB int shader, @Constant("strings.length") @GLsizei int count,
109 @Const @StringList(value = "count", lengths = "length") CharSequence[] strings,
110 @Constant("APIUtils.getLengths(strings), 0") @Const IntBuffer length);
111 @Const @PointerArray(value = "count", lengths = "length") CharSequence[] strings,
112 @Constant("APIUtil.getLengths(strings), 0") @Const IntBuffer length);
111113
112114 void glCompileShaderARB(@GLhandleARB int shaderObj);
113115
231233 @Alternate(value = "glGetActiveUniformARB", javaAlt = true)
232234 @GLreturn(value = "name", maxLength = "maxLength")
233235 void glGetActiveUniformARB(@GLhandleARB int programObj, @GLuint int index, @GLsizei int maxLength,
234 @OutParameter @GLsizei @Constant("name_length, 0, APIUtils.getBufferInt(), 0, APIUtils.getBufferInt(), 1") IntBuffer length,
236 @OutParameter @GLsizei @Constant("name_length, 0, APIUtil.getBufferInt(), 0, APIUtil.getBufferInt(), 1") IntBuffer length,
235237 @OutParameter @GLcharARB ByteBuffer name);
236238
237239 /** Overloads glGetActiveUniformARB. This version returns only the uniform size. */
241243 @OutParameter @GLsizei @Constant("null, 0") IntBuffer length,
242244 @OutParameter IntBuffer size,
243245 @OutParameter @GLenum @Constant("size, 1") IntBuffer type, // Reuse size buffer and ignore
244 @OutParameter @GLcharARB @Constant("APIUtils.getBufferByte(0), 0") ByteBuffer name);
246 @OutParameter @GLcharARB @Constant("APIUtil.getBufferByte(0), 0") ByteBuffer name);
245247
246248 /** Overloads glGetActiveUniformARB. This version returns only the uniform type. */
247249 @Alternate(value = "glGetActiveUniformARB", javaAlt = true)
250252 @OutParameter @GLsizei @Constant("null, 0") IntBuffer length,
251253 @OutParameter @Constant("type, 1") IntBuffer size, // Reuse type buffer and ignore
252254 @OutParameter @GLenum IntBuffer type,
253 @OutParameter @GLcharARB @Constant("APIUtils.getBufferByte(0), 0") ByteBuffer name);
255 @OutParameter @GLcharARB @Constant("APIUtil.getBufferByte(0), 0") ByteBuffer name);
254256
255257 @StripPostfix("params")
256258 void glGetUniformfvARB(@GLhandleARB int programObj, int location, @OutParameter @Check FloatBuffer params);
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 ARB_shader_precision {
34 }
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 ARB_shader_stencil_export {
34 }
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
35 import org.lwjgl.util.generator.opengl.*;
3436
3537 import java.nio.ByteBuffer;
3638 import java.nio.IntBuffer;
5860 int GL_UNIFORM_SIZE = GL31.GL_UNIFORM_SIZE;
5961 int GL_UNIFORM_NAME_LENGTH = GL31.GL_UNIFORM_NAME_LENGTH;
6062
63 @Reuse("GL40")
6164 int glGetSubroutineUniformLocation(@GLuint int program, @GLenum int shadertype, @Const @NullTerminated ByteBuffer name);
6265
66 @Reuse("GL40")
6367 @GLuint
6468 int glGetSubroutineIndex(@GLuint int program, @GLenum int shadertype, @Const @NullTerminated ByteBuffer name);
6569
70 @Reuse("GL40")
6671 @StripPostfix("values")
6772 void glGetActiveSubroutineUniformiv(@GLuint int program, @GLenum int shadertype, @GLuint int index, @GLenum int pname,
6873 @Check("1") @OutParameter IntBuffer values);
6974
75 @Reuse("GL40")
7076 @Alternate("glGetActiveSubroutineUniformiv")
7177 @GLreturn("values")
7278 @StripPostfix("values")
7379 void glGetActiveSubroutineUniformiv2(@GLuint int program, @GLenum int shadertype, @GLuint int index, @GLenum int pname,
7480 @OutParameter IntBuffer values);
7581
82 @Reuse("GL40")
7683 void glGetActiveSubroutineUniformName(@GLuint int program, @GLenum int shadertype, @GLuint int index, @AutoSize("name") @GLsizei int bufsize,
7784 @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length,
7885 @OutParameter ByteBuffer name);
7986
87 @Reuse("GL40")
8088 @Alternate("glGetActiveSubroutineUniformName")
8189 @GLreturn(value = "name", maxLength = "bufsize")
8290 void glGetActiveSubroutineUniformName2(@GLuint int program, @GLenum int shadertype, @GLuint int index, @GLsizei int bufsize,
8391 @OutParameter @Constant("name_length, 0") @GLsizei IntBuffer length,
8492 @OutParameter @GLchar ByteBuffer name);
8593
94 @Reuse("GL40")
8695 void glGetActiveSubroutineName(@GLuint int program, @GLenum int shadertype, @GLuint int index, @AutoSize("name") @GLsizei int bufsize,
8796 @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length,
8897 @OutParameter ByteBuffer name);
8998
99 @Reuse("GL40")
90100 @Alternate("glGetActiveSubroutineName")
91101 @GLreturn(value = "name", maxLength = "bufsize")
92102 void glGetActiveSubroutineName2(@GLuint int program, @GLenum int shadertype, @GLuint int index, @GLsizei int bufsize,
93103 @OutParameter @Constant("name_length, 0") @GLsizei IntBuffer length,
94104 @OutParameter @GLchar ByteBuffer name);
95105
106 @Reuse("GL40")
96107 @StripPostfix("indices")
97108 void glUniformSubroutinesuiv(@GLenum int shadertype, @AutoSize("indices") @GLsizei int count, @Const @GLuint IntBuffer indices);
98109
110 @Reuse("GL40")
99111 @StripPostfix("params")
100112 void glGetUniformSubroutineuiv(@GLenum int shadertype, int location, @Check("1") @OutParameter @GLuint IntBuffer params);
101113
114 @Reuse("GL40")
102115 @Alternate("glGetUniformSubroutineuiv")
103116 @GLreturn("params")
104117 @StripPostfix("params")
105118 void glGetUniformSubroutineuiv2(@GLenum int shadertype, int location, @OutParameter @GLuint IntBuffer params);
106119
120 @Reuse("GL40")
107121 @StripPostfix("values")
108122 void glGetProgramStageiv(@GLuint int program, @GLenum int shadertype, @GLenum int pname, @Check("1") @OutParameter IntBuffer values);
109123
124 @Reuse("GL40")
110125 @Alternate("glGetProgramStageiv")
111126 @GLreturn("values")
112127 @StripPostfix("values")
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
35 import org.lwjgl.util.generator.opengl.*;
3436
3537 import java.nio.ByteBuffer;
3638 import java.nio.IntBuffer;
5961 void glDeleteNamedStringARB(@Constant("name.length()") int namelen, CharSequence name);
6062
6163 void glCompileShaderIncludeARB(@GLuint int shader, @GLsizei int count,
62 @Const @NullTerminated("count") @StringList("count") @GLchar ByteBuffer path,
64 @Const @NullTerminated("count") @PointerArray("count") @GLchar ByteBuffer path,
6365 @Constant("null, 0") @Const IntBuffer length);
6466
6567 @Alternate(value = "glCompileShaderIncludeARB", nativeAlt = true)
6668 void glCompileShaderIncludeARB2(@GLuint int shader, @Constant("path.length") @GLsizei int count,
67 @Const @StringList(value = "count", lengths = "length") CharSequence[] path,
68 @Constant("APIUtils.getLengths(path), 0") @Const IntBuffer length);
69 @Const @PointerArray(value = "count", lengths = "length") CharSequence[] path,
70 @Constant("APIUtil.getLengths(path), 0") @Const IntBuffer length);
6971
7072 boolean glIsNamedStringARB(@AutoSize("name") int namelen, @Const @GLchar ByteBuffer name);
7173
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.PointerWrapper;
35 import org.lwjgl.util.generator.Alternate;
36 import org.lwjgl.util.generator.opengl.*;
3437
3538 import java.nio.IntBuffer;
3639 import java.nio.LongBuffer;
6972 int GL_CONDITION_SATISFIED = 0x911C;
7073 int GL_WAIT_FAILED = 0x911D;
7174
72 @GLpointer("GLsync")
75 @Reuse("GL32")
76 @PointerWrapper("GLsync")
7377 GLSync glFenceSync(@GLenum int condition, @GLbitfield int flags);
7478
75 boolean glIsSync(@GLpointer("GLsync") GLSync sync);
79 @Reuse("GL32")
80 boolean glIsSync(@PointerWrapper("GLsync") GLSync sync);
7681
77 void glDeleteSync(@GLpointer("GLsync") GLSync sync);
82 @Reuse("GL32")
83 void glDeleteSync(@PointerWrapper("GLsync") GLSync sync);
7884
85 @Reuse("GL32")
7986 @GLenum
80 int glClientWaitSync(@GLpointer("GLsync") GLSync sync, @GLbitfield int flags, @GLuint64 long timeout);
87 int glClientWaitSync(@PointerWrapper("GLsync") GLSync sync, @GLbitfield int flags, @GLuint64 long timeout);
8188
82 void glWaitSync(@GLpointer("GLsync") GLSync sync, @GLbitfield int flags, @GLuint64 long timeout);
89 @Reuse("GL32")
90 void glWaitSync(@PointerWrapper("GLsync") GLSync sync, @GLbitfield int flags, @GLuint64 long timeout);
8391
84 @StripPostfix(value = "params", postfix = "64")
92 @Reuse("GL32")
93 @StripPostfix("params")
8594 void glGetInteger64v(@GLenum int pname, @OutParameter @Check("1") @GLint64 LongBuffer params);
8695
96 @Reuse("GL32")
8797 @Alternate("glGetInteger64v")
8898 @GLreturn("params")
89 @StripPostfix(value = "params", postfix = "64")
99 @StripPostfix("params")
90100 void glGetInteger64v2(@GLenum int pname, @OutParameter @GLint64 LongBuffer params);
91101
102 @Reuse("GL32")
92103 @StripPostfix("values")
93 void glGetSynciv(@GLpointer("GLsync") GLSync sync, @GLenum int pname, @AutoSize("values") @GLsizei int bufSize,
104 void glGetSynciv(@PointerWrapper("GLsync") GLSync sync, @GLenum int pname, @AutoSize("values") @GLsizei int bufSize,
94105 @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length,
95106 @OutParameter IntBuffer values);
96107
108 @Reuse("GL32")
97109 @Alternate("glGetSynciv")
98110 @GLreturn("values")
99111 @StripPostfix("values")
100 void glGetSynciv2(@GLpointer("GLsync") GLSync sync, @GLenum int pname, @Constant("1") @GLsizei int bufSize,
112 void glGetSynciv2(@PointerWrapper("GLsync") GLSync sync, @GLenum int pname, @Constant("1") @GLsizei int bufSize,
101113 @OutParameter @GLsizei @Constant("null, 0") IntBuffer length,
102114 @OutParameter IntBuffer values);
103115 }
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.GLenum;
3435
3536 import java.nio.FloatBuffer;
3637
113114 int GL_TESS_EVALUATION_SHADER = 0x8E87;
114115 int GL_TESS_CONTROL_SHADER = 0x8E88;
115116
117 @Reuse("GL40")
116118 void glPatchParameteri(@GLenum int pname, int value);
117119
120 @Reuse("GL40")
118121 @StripPostfix("values")
119122 void glPatchParameterfv(@GLenum int pname, @Check("4") @Const FloatBuffer values);
120123
3030 */
3131 package org.lwjgl.opengl;
3232
33 import org.lwjgl.util.generator.GLenum;
34 import org.lwjgl.util.generator.GLuint;
33 import org.lwjgl.util.generator.opengl.GLenum;
34 import org.lwjgl.util.generator.opengl.GLuint;
3535
3636 public interface ARB_texture_buffer_object {
3737
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.GLenum;
35 import org.lwjgl.util.generator.opengl.GLsizei;
36 import org.lwjgl.util.generator.opengl.GLvoid;
3437
3538 import java.nio.*;
3639
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.GLbitfield;
35 import org.lwjgl.util.generator.opengl.GLenum;
36 import org.lwjgl.util.generator.opengl.GLsizei;
37 import org.lwjgl.util.generator.opengl.GLuint;
3438
3539 import java.nio.FloatBuffer;
3640
9498 int GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY = 0x910C;
9599 int GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY = 0x910D;
96100
101 @Reuse("GL32")
97102 void glTexImage2DMultisample(@GLenum int target, @GLsizei int samples, int internalformat,
98103 @GLsizei int width, @GLsizei int height,
99104 boolean fixedsamplelocations);
100105
106 @Reuse("GL32")
101107 void glTexImage3DMultisample(@GLenum int target, @GLsizei int samples, int internalformat,
102108 @GLsizei int width, @GLsizei int height, @GLsizei int depth,
103109 boolean fixedsamplelocations);
104110
111 @Reuse("GL32")
105112 @StripPostfix("val")
106113 void glGetMultisamplefv(@GLenum int pname, @GLuint int index, @OutParameter @Check("2") FloatBuffer val);
107114
115 @Reuse("GL32")
108116 void glSampleMaski(@GLuint int index, @GLbitfield int mask);
109117
110118 }
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
35 import org.lwjgl.util.generator.opengl.*;
3436
3537 import java.nio.LongBuffer;
3638
5052 */
5153 int GL_TIMESTAMP = 0x8E28;
5254
55 @Reuse("GL33")
5356 void glQueryCounter(@GLuint int id, @GLenum int target);
5457
58 @Reuse("GL33")
5559 @StripPostfix("params")
5660 void glGetQueryObjecti64v(@GLuint int id, @GLenum int pname, @OutParameter @Check("1") @GLint64 LongBuffer params);
5761
62 @Reuse("GL33")
5863 @Alternate("glGetQueryObjecti64v")
5964 @GLreturn("params")
6065 @StripPostfix("params")
6166 void glGetQueryObjecti64v2(@GLuint int id, @GLenum int pname, @OutParameter @GLint64 LongBuffer params);
6267
68 @Reuse("GL33")
6369 @StripPostfix("params")
6470 void glGetQueryObjectui64v(@GLuint int id, @GLenum int pname, @OutParameter @Check("1") @GLuint64 LongBuffer params);
6571
72 @Reuse("GL33")
6673 @Alternate("glGetQueryObjectui64v")
6774 @GLreturn("params")
6875 @StripPostfix("params")
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
35 import org.lwjgl.util.generator.opengl.GLenum;
36 import org.lwjgl.util.generator.opengl.GLreturn;
37 import org.lwjgl.util.generator.opengl.GLsizei;
38 import org.lwjgl.util.generator.opengl.GLuint;
3439
3540 import java.nio.IntBuffer;
3641
4752 int GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE = 0x8E24;
4853 int GL_TRANSFORM_FEEDBACK_BINDING = 0x8E25;
4954
55 @Reuse("GL40")
5056 void glBindTransformFeedback(@GLenum int target, @GLuint int id);
5157
58 @Reuse("GL40")
5259 void glDeleteTransformFeedbacks(@AutoSize("ids") @GLsizei int n, @Const @GLuint IntBuffer ids);
5360
61 @Reuse("GL40")
5462 @Alternate("glDeleteTransformFeedbacks")
55 void glDeleteTransformFeedbacks(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, id), 0", keepParam = true) int id);
63 void glDeleteTransformFeedbacks(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, id), 0", keepParam = true) int id);
5664
65 @Reuse("GL40")
5766 void glGenTransformFeedbacks(@AutoSize("ids") @GLsizei int n, @OutParameter @GLuint IntBuffer ids);
5867
68 @Reuse("GL40")
5969 @Alternate("glGenTransformFeedbacks")
6070 @GLreturn("ids")
6171 void glGenTransformFeedbacks2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer ids);
6272
73 @Reuse("GL40")
6374 boolean glIsTransformFeedback(@GLuint int id);
6475
76 @Reuse("GL40")
6577 void glPauseTransformFeedback();
6678
79 @Reuse("GL40")
6780 void glResumeTransformFeedback();
6881
82 @Reuse("GL40")
6983 void glDrawTransformFeedback(@GLenum int mode, @GLuint int id);
7084
7185 }
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
35 import org.lwjgl.util.generator.opengl.GLenum;
36 import org.lwjgl.util.generator.opengl.GLreturn;
37 import org.lwjgl.util.generator.opengl.GLuint;
3438
3539 import java.nio.IntBuffer;
3640
4448 int GL_MAX_TRANSFORM_FEEDBACK_BUFFERS = 0x8E70;
4549 int GL_MAX_VERTEX_STREAMS = 0x8E71;
4650
51 @Reuse("GL40")
4752 void glDrawTransformFeedbackStream(@GLenum int mode, @GLuint int id, @GLuint int stream);
4853
54 @Reuse("GL40")
4955 void glBeginQueryIndexed(@GLenum int target, @GLuint int index, @GLuint int id);
5056
57 @Reuse("GL40")
5158 void glEndQueryIndexed(@GLenum int target, @GLuint int index);
5259
60 @Reuse("GL40")
5361 @StripPostfix("params")
5462 void glGetQueryIndexediv(@GLenum int target, @GLuint int index, @GLenum int pname, @OutParameter @Check("1") IntBuffer params);
5563
64 @Reuse("GL40")
5665 @Alternate("glGetQueryIndexediv")
5766 @GLreturn("params")
5867 @StripPostfix("params")
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
35 import org.lwjgl.util.generator.opengl.*;
3436
3537 import java.nio.ByteBuffer;
3638 import java.nio.IntBuffer;
9799 /** Returned by GetActiveUniformsivARB and GetUniformBlockIndexARB */
98100 int GL_INVALID_INDEX = 0xFFFFFFFF;
99101
102 @Reuse("GL31")
100103 void glGetUniformIndices(@GLuint int program, @AutoSize("uniformIndices") @GLsizei int uniformCount,
101 @Const @NullTerminated("uniformIndices.remaining()") @GLchar @StringList("uniformCount") ByteBuffer uniformNames,
104 @Const @NullTerminated("uniformIndices.remaining()") @GLchar @PointerArray("uniformCount") ByteBuffer uniformNames,
102105 @OutParameter @GLuint IntBuffer uniformIndices);
103106
107 @Reuse("GL31")
104108 @Alternate(value = "glGetUniformIndices")
105109 void glGetUniformIndices(@GLuint int program, @Constant("uniformNames.length") @GLsizei int uniformCount,
106 @Const @NullTerminated @StringList("uniformCount") CharSequence[] uniformNames,
110 @Const @NullTerminated @PointerArray("uniformCount") CharSequence[] uniformNames,
107111 @OutParameter @Check("uniformNames.length") @GLuint IntBuffer uniformIndices);
108112
113 @Reuse("GL31")
109114 @StripPostfix("params")
110115 void glGetActiveUniformsiv(@GLuint int program, @AutoSize("uniformIndices") @GLsizei int uniformCount,
111116 @Const @GLuint IntBuffer uniformIndices,
112117 @GLenum int pname,
113118 @OutParameter @Check("uniformIndices.remaining()") @GLint IntBuffer params);
114119
120 @Reuse("GL31")
115121 @Alternate("glGetActiveUniformsiv")
116122 @GLreturn("params")
117123 @StripPostfix("params")
120126 @GLenum int pname,
121127 @OutParameter @GLint IntBuffer params);
122128
129 @Reuse("GL31")
123130 void glGetActiveUniformName(@GLuint int program, @GLuint int uniformIndex, @AutoSize("uniformName") @GLsizei int bufSize,
124131 @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length,
125132 @OutParameter @GLchar ByteBuffer uniformName);
126133
134 @Reuse("GL31")
127135 @Alternate("glGetActiveUniformName")
128136 @GLreturn(value = "uniformName", maxLength = "bufSize")
129137 void glGetActiveUniformName2(@GLuint int program, @GLuint int uniformIndex, @GLsizei int bufSize,
130138 @OutParameter @GLsizei @Constant("uniformName_length, 0") IntBuffer length,
131139 @OutParameter @GLchar ByteBuffer uniformName);
132140
141 @Reuse("GL31")
133142 @GLuint
134143 int glGetUniformBlockIndex(@GLuint int program, @Const @NullTerminated @GLchar ByteBuffer uniformBlockName);
135144
145 @Reuse("GL31")
136146 @Alternate("glGetUniformBlockIndex")
137147 @GLuint
138148 int glGetUniformBlockIndex(@GLuint int program, @NullTerminated CharSequence uniformBlockName);
139149
150 @Reuse("GL31")
140151 @StripPostfix("params")
141152 void glGetActiveUniformBlockiv(@GLuint int program, @GLuint int uniformBlockIndex, @GLenum int pname,
142153 @OutParameter @Check(value = "16") @GLint IntBuffer params);
143154
155 @Reuse("GL31")
144156 @Alternate("glGetActiveUniformBlockiv")
145157 @GLreturn("params")
146158 @StripPostfix("params")
147159 void glGetActiveUniformBlockiv2(@GLuint int program, @GLuint int uniformBlockIndex, @GLenum int pname,
148160 @OutParameter @GLint IntBuffer params);
149161
162 @Reuse("GL31")
150163 void glGetActiveUniformBlockName(@GLuint int program, @GLuint int uniformBlockIndex, @AutoSize("uniformBlockName") @GLsizei int bufSize,
151164 @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length,
152165 @OutParameter @GLchar ByteBuffer uniformBlockName);
153166
167 @Reuse("GL31")
154168 @Alternate("glGetActiveUniformBlockName")
155169 @GLreturn(value = "uniformBlockName", maxLength = "bufSize")
156170 void glGetActiveUniformBlockName2(@GLuint int program, @GLuint int uniformBlockIndex, @GLsizei int bufSize,
157171 @OutParameter @GLsizei @Constant("uniformBlockName_length, 0") IntBuffer length,
158172 @OutParameter @GLchar ByteBuffer uniformBlockName);
159173
174 @Reuse("GL30")
160175 void glBindBufferRange(@GLenum int target, @GLuint int index, @GLuint int buffer, @GLintptr long offset, @GLsizeiptr long size);
161176
177 @Reuse("GL30")
162178 void glBindBufferBase(@GLenum int target, @GLuint int index, @GLuint int buffer);
163179
180 @Reuse("GL30")
164181 @StripPostfix(value = "data", extension = "")
165182 void glGetIntegeri_v(@GLenum int value, @GLuint int index, @OutParameter @Check("4") IntBuffer data);
166183
184 @Reuse("GL30")
167185 @Alternate("glGetIntegeri_v")
168186 @GLreturn("data")
169187 @StripPostfix("data")
170188 void glGetIntegeri_v2(@GLenum int value, @GLuint int index, @OutParameter IntBuffer data);
171189
190 @Reuse("GL31")
172191 void glUniformBlockBinding(@GLuint int program, @GLuint int uniformBlockIndex, @GLuint int uniformBlockBinding);
173192
174193 }
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
35 import org.lwjgl.util.generator.opengl.GLreturn;
36 import org.lwjgl.util.generator.opengl.GLsizei;
37 import org.lwjgl.util.generator.opengl.GLuint;
3438
3539 import java.nio.IntBuffer;
3640
4246 */
4347 int GL_VERTEX_ARRAY_BINDING = 0x85B5;
4448
49 @Reuse("GL30")
4550 void glBindVertexArray(@GLuint int array);
4651
52 @Reuse("GL30")
4753 void glDeleteVertexArrays(@AutoSize("arrays") @GLsizei int n, @Const @GLuint IntBuffer arrays);
4854
55 @Reuse("GL30")
4956 @Alternate("glDeleteVertexArrays")
50 void glDeleteVertexArrays(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, array), 0", keepParam = true) int array);
57 void glDeleteVertexArrays(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, array), 0", keepParam = true) int array);
5158
59 @Reuse("GL30")
5260 void glGenVertexArrays(@AutoSize("arrays") @GLsizei int n, @OutParameter @GLuint IntBuffer arrays);
5361
62 @Reuse("GL30")
5463 @Alternate("glGenVertexArrays")
5564 @GLreturn("arrays")
5665 void glGenVertexArrays2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer arrays);
5766
67 @Reuse("GL30")
5868 boolean glIsVertexArray(@GLuint int array);
5969
6070 }
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 import org.lwjgl.util.generator.opengl.*;
35
36 import java.nio.Buffer;
37 import java.nio.DoubleBuffer;
38
39 @Dependent
40 @Extension(postfix = "")
41 public interface ARB_vertex_attrib_64bit {
42
43 /** Returned in the &lt;type&gt; parameter of GetActiveAttrib: */
44 int GL_DOUBLE_VEC2 = 0x8FFC;
45 int GL_DOUBLE_VEC3 = 0x8FFD;
46 int GL_DOUBLE_VEC4 = 0x8FFE;
47 int GL_DOUBLE_MAT2 = 0x8F46;
48 int GL_DOUBLE_MAT3 = 0x8F47;
49 int GL_DOUBLE_MAT4 = 0x8F48;
50 int GL_DOUBLE_MAT2x3 = 0x8F49;
51 int GL_DOUBLE_MAT2x4 = 0x8F4A;
52 int GL_DOUBLE_MAT3x2 = 0x8F4B;
53 int GL_DOUBLE_MAT3x4 = 0x8F4C;
54 int GL_DOUBLE_MAT4x2 = 0x8F4D;
55 int GL_DOUBLE_MAT4x3 = 0x8F4E;
56
57 @Reuse("GL41")
58 void glVertexAttribL1d(@GLuint int index, double x);
59
60 @Reuse("GL41")
61 void glVertexAttribL2d(@GLuint int index, double x, double y);
62
63 @Reuse("GL41")
64 void glVertexAttribL3d(@GLuint int index, double x, double y, double z);
65
66 @Reuse("GL41")
67 void glVertexAttribL4d(@GLuint int index, double x, double y, double z, double w);
68
69 @Reuse("GL41")
70 @StripPostfix("v")
71 void glVertexAttribL1dv(@GLuint int index, @Const @Check("1") DoubleBuffer v);
72
73 @Reuse("GL41")
74 @StripPostfix("v")
75 void glVertexAttribL2dv(@GLuint int index, @Const @Check("2") DoubleBuffer v);
76
77 @Reuse("GL41")
78 @StripPostfix("v")
79 void glVertexAttribL3dv(@GLuint int index, @Const @Check("3") DoubleBuffer v);
80
81 @Reuse("GL41")
82 @StripPostfix("v")
83 void glVertexAttribL4dv(@GLuint int index, @Const @Check("4") DoubleBuffer v);
84
85 @Reuse("GL41")
86 void glVertexAttribLPointer(@GLuint int index, int size, @Constant("GL11.GL_DOUBLE") @GLenum int type, @GLsizei int stride,
87 @CachedReference(index = "index", name = "glVertexAttribPointer_buffer")
88 @BufferObject(BufferKind.ArrayVBO)
89 @Check @Const @GLdouble Buffer pointer);
90
91 @Reuse("GL41")
92 @StripPostfix("params")
93 void glGetVertexAttribLdv(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") DoubleBuffer params);
94
95 @Dependent("EXT_direct_state_access")
96 void glVertexArrayVertexAttribLOffsetEXT(@GLuint int vaobj, @GLuint int buffer, @GLuint int index, int size, @GLenum int type, @GLsizei int stride, @GLintptr long offset);
97
98 }
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.*;
3435
3536 import java.nio.*;
3637
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.*;
3435
3536 import java.nio.*;
3637
7879 */
7980 int GL_MAX_VERTEX_ATTRIBS_ARB = 0x8869;
8081
82 @Reuse("ARBVertexShader")
8183 @NoErrorCheck
8284 void glVertexAttrib1sARB(@GLuint int index, short x);
8385
86 @Reuse("ARBVertexShader")
8487 @NoErrorCheck
8588 void glVertexAttrib1fARB(@GLuint int index, float x);
8689
90 @Reuse("ARBVertexShader")
8791 @NoErrorCheck
8892 void glVertexAttrib1dARB(@GLuint int index, double x);
8993
94 @Reuse("ARBVertexShader")
9095 @NoErrorCheck
9196 void glVertexAttrib2sARB(@GLuint int index, short x, short y);
9297
98 @Reuse("ARBVertexShader")
9399 @NoErrorCheck
94100 void glVertexAttrib2fARB(@GLuint int index, float x, float y);
95101
102 @Reuse("ARBVertexShader")
96103 @NoErrorCheck
97104 void glVertexAttrib2dARB(@GLuint int index, double x, double y);
98105
106 @Reuse("ARBVertexShader")
99107 @NoErrorCheck
100108 void glVertexAttrib3sARB(@GLuint int index, short x, short y, short z);
101109
110 @Reuse("ARBVertexShader")
102111 @NoErrorCheck
103112 void glVertexAttrib3fARB(@GLuint int index, float x, float y, float z);
104113
114 @Reuse("ARBVertexShader")
105115 @NoErrorCheck
106116 void glVertexAttrib3dARB(@GLuint int index, double x, double y, double z);
107117
118 @Reuse("ARBVertexShader")
108119 @NoErrorCheck
109120 void glVertexAttrib4sARB(@GLuint int index, short x, short y, short z, short w);
110121
122 @Reuse("ARBVertexShader")
111123 @NoErrorCheck
112124 void glVertexAttrib4fARB(@GLuint int index, float x, float y, float z, float w);
113125
126 @Reuse("ARBVertexShader")
114127 @NoErrorCheck
115128 void glVertexAttrib4dARB(@GLuint int index, double x, double y, double z, double w);
116129
130 @Reuse("ARBVertexShader")
117131 @NoErrorCheck
118132 void glVertexAttrib4NubARB(@GLuint int index, @GLubyte byte x, @GLubyte byte y, @GLubyte byte z, @GLubyte byte w);
119133
134 @Reuse("ARBVertexShader")
120135 void glVertexAttribPointerARB(@GLuint int index, int size, @AutoType("buffer") @GLenum int type, boolean normalized, @GLsizei int stride,
121136 @CachedReference(index = "index", name = "glVertexAttribPointer_buffer")
122137 @BufferObject(BufferKind.ArrayVBO)
131146 @GLfloat
132147 @GLdouble Buffer buffer);
133148
149 @Reuse("ARBVertexShader")
134150 void glEnableVertexAttribArrayARB(@GLuint int index);
135151
152 @Reuse("ARBVertexShader")
136153 void glDisableVertexAttribArrayARB(@GLuint int index);
137154
155 @Reuse("ARBVertexShader")
138156 @StripPostfix("params")
139157 void glGetVertexAttribfvARB(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params);
140158
159 @Reuse("ARBVertexShader")
141160 @StripPostfix("params")
142161 void glGetVertexAttribdvARB(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") DoubleBuffer params);
143162
163 @Reuse("ARBVertexShader")
144164 @StripPostfix("params")
145165 void glGetVertexAttribivARB(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") IntBuffer params);
146166
167 @Reuse("ARBVertexShader")
147168 @StripPostfix("result")
148169 void glGetVertexAttribPointervARB(@GLuint int index, @GLenum int pname, @Result @GLvoid ByteBuffer result);
149170 }
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
35 import org.lwjgl.util.generator.opengl.*;
3436
3537 import java.nio.*;
3638
167169 @Alternate(value = "glGetActiveAttribARB", javaAlt = true)
168170 @GLreturn(value = "name", maxLength = "maxLength")
169171 void glGetActiveAttribARB(@GLhandleARB int programObj, @GLuint int index, @GLsizei int maxLength,
170 @OutParameter @GLsizei @Constant("name_length, 0, APIUtils.getBufferInt(), 0, APIUtils.getBufferInt(), 1") IntBuffer length,
172 @OutParameter @GLsizei @Constant("name_length, 0, APIUtil.getBufferInt(), 0, APIUtil.getBufferInt(), 1") IntBuffer length,
171173 @OutParameter @GLcharARB ByteBuffer name);
172174
173175 /** Overloads glGetActiveAttribARB. This version returns only the attrib size. */
177179 @OutParameter @GLsizei @Constant("null, 0") IntBuffer length,
178180 @OutParameter IntBuffer size,
179181 @OutParameter @GLenum @Constant("size, 1") IntBuffer type, // Reuse size buffer and ignore
180 @OutParameter @GLcharARB @Constant("APIUtils.getBufferByte(0), 0") ByteBuffer name);
182 @OutParameter @GLcharARB @Constant("APIUtil.getBufferByte(0), 0") ByteBuffer name);
181183
182184 /** Overloads glGetActiveAttribARB. This version returns only the attrib type. */
183185 @Alternate(value = "glGetActiveAttribARB", javaAlt = true)
186188 @OutParameter @GLsizei @Constant("null, 0") IntBuffer length,
187189 @OutParameter @Constant("type, 1") IntBuffer size, // Reuse type buffer and ignore
188190 @OutParameter @GLenum IntBuffer type,
189 @OutParameter @GLcharARB @Constant("APIUtils.getBufferByte(0), 0") ByteBuffer name);
191 @OutParameter @GLcharARB @Constant("APIUtil.getBufferByte(0), 0") ByteBuffer name);
190192
191193 int glGetAttribLocationARB(@GLhandleARB int programObj, @NullTerminated @Const @GLcharARB ByteBuffer name);
192194
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.GLenum;
35 import org.lwjgl.util.generator.opengl.GLuint;
3436
3537 import java.nio.IntBuffer;
3638
4648 int GL_UNSIGNED_INT_2_10_10_10_REV = GL12.GL_UNSIGNED_INT_2_10_10_10_REV;
4749 int GL_INT_2_10_10_10_REV = 0x8D9F;
4850
51 @Reuse("GL33")
4952 @NoErrorCheck
5053 void glVertexP2ui(@GLenum int type, @GLuint int value);
5154
55 @Reuse("GL33")
5256 @NoErrorCheck
5357 void glVertexP3ui(@GLenum int type, @GLuint int value);
5458
59 @Reuse("GL33")
5560 @NoErrorCheck
5661 void glVertexP4ui(@GLenum int type, @GLuint int value);
5762
63 @Reuse("GL33")
5864 @NoErrorCheck
5965 @StripPostfix("value")
6066 void glVertexP2uiv(@GLenum int type, @Check("2") @Const @GLuint IntBuffer value);
6167
68 @Reuse("GL33")
6269 @NoErrorCheck
6370 @StripPostfix("value")
6471 void glVertexP3uiv(@GLenum int type, @Check("3") @Const @GLuint IntBuffer value);
6572
73 @Reuse("GL33")
6674 @NoErrorCheck
6775 @StripPostfix("value")
6876 void glVertexP4uiv(@GLenum int type, @Check("4") @Const @GLuint IntBuffer value);
6977
78 @Reuse("GL33")
7079 @NoErrorCheck
7180 void glTexCoordP1ui(@GLenum int type, @GLuint int coords);
7281
82 @Reuse("GL33")
7383 @NoErrorCheck
7484 void glTexCoordP2ui(@GLenum int type, @GLuint int coords);
7585
86 @Reuse("GL33")
7687 @NoErrorCheck
7788 void glTexCoordP3ui(@GLenum int type, @GLuint int coords);
7889
90 @Reuse("GL33")
7991 @NoErrorCheck
8092 void glTexCoordP4ui(@GLenum int type, @GLuint int coords);
8193
94 @Reuse("GL33")
8295 @NoErrorCheck
8396 @StripPostfix("coords")
8497 void glTexCoordP1uiv(@GLenum int type, @Check("1") @Const @GLuint IntBuffer coords);
8598
99 @Reuse("GL33")
86100 @NoErrorCheck
87101 @StripPostfix("coords")
88102 void glTexCoordP2uiv(@GLenum int type, @Check("2") @Const @GLuint IntBuffer coords);
89103
104 @Reuse("GL33")
90105 @NoErrorCheck
91106 @StripPostfix("coords")
92107 void glTexCoordP3uiv(@GLenum int type, @Check("3") @Const @GLuint IntBuffer coords);
93108
109 @Reuse("GL33")
94110 @NoErrorCheck
95111 @StripPostfix("coords")
96112 void glTexCoordP4uiv(@GLenum int type, @Check("4") @Const @GLuint IntBuffer coords);
97113
114 @Reuse("GL33")
98115 @NoErrorCheck
99116 void glMultiTexCoordP1ui(@GLenum int texture, @GLenum int type, @GLuint int coords);
100117
118 @Reuse("GL33")
101119 @NoErrorCheck
102120 void glMultiTexCoordP2ui(@GLenum int texture, @GLenum int type, @GLuint int coords);
103121
122 @Reuse("GL33")
104123 @NoErrorCheck
105124 void glMultiTexCoordP3ui(@GLenum int texture, @GLenum int type, @GLuint int coords);
106125
126 @Reuse("GL33")
107127 @NoErrorCheck
108128 void glMultiTexCoordP4ui(@GLenum int texture, @GLenum int type, @GLuint int coords);
109129
130 @Reuse("GL33")
110131 @NoErrorCheck
111132 @StripPostfix("coords")
112133 void glMultiTexCoordP1uiv(@GLenum int texture, @GLenum int type, @Check("1") @Const @GLuint IntBuffer coords);
113134
135 @Reuse("GL33")
114136 @NoErrorCheck
115137 @StripPostfix("coords")
116138 void glMultiTexCoordP2uiv(@GLenum int texture, @GLenum int type, @Check("2") @Const @GLuint IntBuffer coords);
117139
140 @Reuse("GL33")
118141 @NoErrorCheck
119142 @StripPostfix("coords")
120143 void glMultiTexCoordP3uiv(@GLenum int texture, @GLenum int type, @Check("3") @Const @GLuint IntBuffer coords);
121144
145 @Reuse("GL33")
122146 @NoErrorCheck
123147 @StripPostfix("coords")
124148 void glMultiTexCoordP4uiv(@GLenum int texture, @GLenum int type, @Check("4") @Const @GLuint IntBuffer coords);
125149
150 @Reuse("GL33")
126151 @NoErrorCheck
127152 void glNormalP3ui(@GLenum int type, @GLuint int coords);
128153
154 @Reuse("GL33")
129155 @NoErrorCheck
130156 @StripPostfix("coords")
131157 void glNormalP3uiv(@GLenum int type, @Check("3") @Const @GLuint IntBuffer coords);
132158
159 @Reuse("GL33")
133160 @NoErrorCheck
134161 void glColorP3ui(@GLenum int type, @GLuint int color);
135162
163 @Reuse("GL33")
136164 @NoErrorCheck
137165 void glColorP4ui(@GLenum int type, @GLuint int color);
138166
167 @Reuse("GL33")
139168 @NoErrorCheck
140169 @StripPostfix("color")
141170 void glColorP3uiv(@GLenum int type, @Check("3") @Const @GLuint IntBuffer color);
142171
172 @Reuse("GL33")
143173 @NoErrorCheck
144174 @StripPostfix("color")
145175 void glColorP4uiv(@GLenum int type, @Check("4") @Const @GLuint IntBuffer color);
146176
177 @Reuse("GL33")
147178 @NoErrorCheck
148179 void glSecondaryColorP3ui(@GLenum int type, @GLuint int color);
149180
181 @Reuse("GL33")
150182 @NoErrorCheck
151183 @StripPostfix("color")
152184 void glSecondaryColorP3uiv(@GLenum int type, @Check("3") @Const @GLuint IntBuffer color);
153185
186 @Reuse("GL33")
154187 @NoErrorCheck
155188 void glVertexAttribP1ui(@GLuint int index, @GLenum int type, boolean normalized, @GLuint int value);
156189
190 @Reuse("GL33")
157191 @NoErrorCheck
158192 void glVertexAttribP2ui(@GLuint int index, @GLenum int type, boolean normalized, @GLuint int value);
159193
194 @Reuse("GL33")
160195 @NoErrorCheck
161196 void glVertexAttribP3ui(@GLuint int index, @GLenum int type, boolean normalized, @GLuint int value);
162197
198 @Reuse("GL33")
163199 @NoErrorCheck
164200 void glVertexAttribP4ui(@GLuint int index, @GLenum int type, boolean normalized, @GLuint int value);
165201
202 @Reuse("GL33")
166203 @NoErrorCheck
167204 @StripPostfix("value")
168205 void glVertexAttribP1uiv(@GLuint int index, @GLenum int type, boolean normalized, @Check("1") @Const @GLuint IntBuffer value);
169206
207 @Reuse("GL33")
170208 @NoErrorCheck
171209 @StripPostfix("value")
172210 void glVertexAttribP2uiv(@GLuint int index, @GLenum int type, boolean normalized, @Check("2") @Const @GLuint IntBuffer value);
173211
212 @Reuse("GL33")
174213 @NoErrorCheck
175214 @StripPostfix("value")
176215 void glVertexAttribP3uiv(@GLuint int index, @GLenum int type, boolean normalized, @Check("3") @Const @GLuint IntBuffer value);
177216
217 @Reuse("GL33")
178218 @NoErrorCheck
179219 @StripPostfix("value")
180220 void glVertexAttribP4uiv(@GLuint int index, @GLenum int type, boolean normalized, @Check("4") @Const @GLuint IntBuffer value);
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 import org.lwjgl.util.generator.Alternate;
35 import org.lwjgl.util.generator.opengl.*;
36
37 import java.nio.DoubleBuffer;
38 import java.nio.FloatBuffer;
39 import java.nio.IntBuffer;
40
41 @Extension(postfix = "")
42 public interface ARB_viewport_array {
43
44 /**
45 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv,
46 * GetDoublev and GetInteger64v:
47 */
48 int GL_MAX_VIEWPORTS = 0x825B,
49 GL_VIEWPORT_SUBPIXEL_BITS = 0x825C,
50 GL_VIEWPORT_BOUNDS_RANGE = 0x825D,
51 GL_LAYER_PROVOKING_VERTEX = 0x825E,
52 GL_VIEWPORT_INDEX_PROVOKING_VERTEX = 0x825F;
53
54 /** Accepted by the &lt;pname&gt; parameter of GetIntegeri_v: */
55 int GL_SCISSOR_BOX = 0x0C10;
56
57 /** Accepted by the &lt;pname&gt; parameter of GetFloati_v: */
58 int GL_VIEWPORT = 0x0BA2;
59
60 /** Accepted by the &lt;pname&gt; parameter of GetDoublei_v: */
61 int GL_DEPTH_RANGE = 0x0B70;
62
63 /** Accepted by the &lt;pname&gt; parameter of Enablei, Disablei, and IsEnabledi: */
64 int GL_SCISSOR_TEST = 0x0C11;
65
66 /**
67 * Returned in the &lt;data&gt; parameter from a Get query with a &lt;pname&gt; of
68 * LAYER_PROVOKING_VERTEX or VIEWPORT_INDEX_PROVOKING_VERTEX:
69 */
70 int GL_FIRST_VERTEX_CONVENTION = 0x8E4D,
71 GL_LAST_VERTEX_CONVENTION = 0x8E4E,
72 GL_PROVOKING_VERTEX = 0x8E4F,
73 GL_UNDEFINED_VERTEX = 0x8260;
74
75 @Reuse("GL41")
76 @StripPostfix("v")
77 void glViewportArrayv(@GLuint int first, @AutoSize(value = "v", expression = " >> 2") @GLsizei int count, @Const FloatBuffer v);
78
79 @Reuse("GL41")
80 void glViewportIndexedf(@GLuint int index, float x, float y, float w, float h);
81
82 @Reuse("GL41")
83 @StripPostfix("v")
84 void glViewportIndexedfv(@GLuint int index, @Check("4") @Const FloatBuffer v);
85
86 @Reuse("GL41")
87 @StripPostfix("v")
88 void glScissorArrayv(@GLuint int first, @AutoSize(value = "v", expression = " >> 2") @GLsizei int count, @Const IntBuffer v);
89
90 @Reuse("GL41")
91 void glScissorIndexed(@GLuint int index, int left, int bottom, @GLsizei int width, @GLsizei int height);
92
93 @Reuse("GL41")
94 @StripPostfix("v")
95 void glScissorIndexedv(@GLuint int index, @Check("4") @Const IntBuffer v);
96
97 @Reuse("GL41")
98 @StripPostfix("v")
99 void glDepthRangeArrayv(@GLuint int first, @AutoSize(value = "v", expression = " >> 1") @GLsizei int count, @Const @GLclampd DoubleBuffer v);
100
101 @Reuse("GL41")
102 void glDepthRangeIndexed(@GLuint int index, @GLclampd double n, @GLclampd double f);
103
104 @Reuse("GL41")
105 @StripPostfix("data")
106 void glGetFloati_v(@GLenum int target, @GLuint int index, @Check @OutParameter FloatBuffer data);
107
108 @Reuse("GL41")
109 @Alternate("glGetFloati_v")
110 @GLreturn("data")
111 @StripPostfix("data")
112 void glGetFloati_v2(@GLenum int target, @GLuint int index, @OutParameter FloatBuffer data);
113
114 @Reuse("GL41")
115 @StripPostfix("data")
116 void glGetDoublei_v(@GLenum int target, @GLuint int index, @Check @OutParameter DoubleBuffer data);
117
118 @Reuse("GL41")
119 @Alternate("glGetDoublei_v")
120 @GLreturn("data")
121 @StripPostfix("data")
122 void glGetDoublei_v2(@GLenum int target, @GLuint int index, @OutParameter DoubleBuffer data);
123
124 @Reuse("EXTDrawBuffers2")
125 @StripPostfix(value = "v", extension = "EXT")
126 void glGetIntegerIndexedvEXT(@GLenum int target, @GLuint int index, @Check @OutParameter IntBuffer v);
127
128 @Reuse("EXTDrawBuffers2")
129 @Alternate("glGetIntegerIndexedivEXT")
130 @GLreturn("v")
131 @StripPostfix(value = "v", extension = "EXT")
132 void glGetIntegerIndexedvEXT2(@GLenum int target, @GLuint int index, @OutParameter IntBuffer v);
133
134 @Reuse("EXTDrawBuffers2")
135 void glEnableIndexedEXT(@GLenum int target, @GLuint int index);
136
137 @Reuse("EXTDrawBuffers2")
138 void glDisableIndexedEXT(@GLenum int target, @GLuint int index);
139
140 @Reuse("EXTDrawBuffers2")
141 boolean glIsEnabledIndexedEXT(@GLenum int target, @GLuint int index);
142
143 }
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
35 import org.lwjgl.util.generator.opengl.GLenum;
36 import org.lwjgl.util.generator.opengl.GLsizei;
3437
3538 import java.nio.*;
3639
6164 void glDrawBuffersATI(@AutoSize("buffers") @GLsizei int size, @Const @GLenum IntBuffer buffers);
6265
6366 @Alternate("glDrawBuffersATI")
64 void glDrawBuffersATI(@Constant("1") @GLsizei int size, @Constant(value = "APIUtils.getBufferInt().put(0, buffer), 0", keepParam = true) int buffer);
67 void glDrawBuffersATI(@Constant("1") @GLsizei int size, @Constant(value = "APIUtil.getBufferInt().put(0, buffer), 0", keepParam = true) int buffer);
6568 }
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.*;
3435
3536 import java.nio.*;
3637
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.GLenum;
3435
3536 import java.nio.*;
3637
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.GLenum;
35 import org.lwjgl.util.generator.opengl.GLuint;
3436
3537 import java.nio.*;
3638
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.GLuint;
35 import org.lwjgl.util.generator.opengl.GLvoid;
3436
3537 import java.nio.*;
3638
6163 */
6264 @CachedResult
6365 @GLvoid
64 @AutoResultSize("GLChecks.getBufferObjectSizeATI(caps, buffer)")
66 @AutoSize("GLChecks.getBufferObjectSizeATI(caps, buffer)")
6567 ByteBuffer glMapObjectBufferATI(@GLuint int buffer);
6668
6769 void glUnmapObjectBufferATI(@GLuint int buffer);
3030 */
3131 package org.lwjgl.opengl;
3232
33 import org.lwjgl.util.generator.*;
33 import org.lwjgl.util.generator.opengl.GLenum;
3434
3535 public interface ATI_pn_triangles {
3636 int GL_PN_TRIANGLES_ATI = 0x87F0;
3030 */
3131 package org.lwjgl.opengl;
3232
33 import org.lwjgl.util.generator.*;
33 import org.lwjgl.util.generator.opengl.GLenum;
34 import org.lwjgl.util.generator.opengl.GLuint;
3435
3536 public interface ATI_separate_stencil {
3637 int GL_STENCIL_BACK_FUNC_ATI = 0x8800;
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
35 import org.lwjgl.util.generator.opengl.*;
3436
3537 import java.nio.*;
3638
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.GLenum;
35 import org.lwjgl.util.generator.opengl.GLsizei;
36 import org.lwjgl.util.generator.opengl.GLuint;
3437
3538 import java.nio.*;
3639
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.GLenum;
3435
3536 public interface ATI_vertex_streams {
3637 int GL_MAX_VERTEX_STREAMS_ATI = 0x876B;
3030 */
3131 package org.lwjgl.opengl;
3232
33 import org.lwjgl.util.generator.GLintptr;
34 import org.lwjgl.util.generator.GLuint;
33 import org.lwjgl.util.generator.opengl.GLintptr;
34 import org.lwjgl.util.generator.opengl.GLuint;
3535
3636 public interface EXT_bindable_uniform {
3737
3030 */
3131 package org.lwjgl.opengl;
3232
33 import org.lwjgl.util.generator.*;
33 import org.lwjgl.util.generator.opengl.GLclampf;
3434
3535 public interface EXT_blend_color {
3636
3030 */
3131 package org.lwjgl.opengl;
3232
33 import org.lwjgl.util.generator.*;
33 import org.lwjgl.util.generator.opengl.GLenum;
3434
3535 public interface EXT_blend_equation_separate {
3636
3030 */
3131 package org.lwjgl.opengl;
3232
33 import org.lwjgl.util.generator.*;
33 import org.lwjgl.util.generator.opengl.GLenum;
3434
3535 public interface EXT_blend_func_separate {
3636 int GL_BLEND_DST_RGB_EXT = 0x80C8;
3030 */
3131 package org.lwjgl.opengl;
3232
33 import org.lwjgl.util.generator.*;
33 import org.lwjgl.util.generator.opengl.GLenum;
3434
3535 public interface EXT_blend_minmax {
3636
3030 */
3131 package org.lwjgl.opengl;
3232
33 import org.lwjgl.util.generator.*;
33 import org.lwjgl.util.generator.opengl.GLsizei;
3434
3535 public interface EXT_compiled_vertex_array {
3636 int GL_ARRAY_ELEMENT_LOCK_FIRST_EXT = 0x81A8;
3030 */
3131 package org.lwjgl.opengl;
3232
33 import org.lwjgl.util.generator.*;
33 import org.lwjgl.util.generator.opengl.GLclampd;
3434
3535 public interface EXT_depth_bounds_test {
3636
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.*;
3435
3536 import java.nio.*;
3637
518519 value parameters
519520 */
520521
521 @Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
522 @Optional(reason = "AMD does not expose this (last driver checked: 10.9)")
522523 @Dependent("OpenGL30")
523524 void glEnableClientStateiEXT(@GLenum int array, @GLuint int index);
524525
525 @Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
526 @Optional(reason = "AMD does not expose this (last driver checked: 10.9)")
526527 @Dependent("OpenGL30")
527528 void glDisableClientStateiEXT(@GLenum int array, @GLuint int index);
528529
564565 and before state value parameters
565566 */
566567
567 @Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
568 @Optional(reason = "AMD does not expose this (last driver checked: 10.9)")
568569 @Dependent("OpenGL30")
569570 @StripPostfix("params")
570571 void glGetFloati_vEXT(@GLenum int pname, @GLuint int index, @OutParameter @Check("16") FloatBuffer params);
575576 @StripPostfix("params")
576577 void glGetFloati_vEXT2(@GLenum int pname, @GLuint int index, @OutParameter FloatBuffer params);
577578
578 @Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
579 @Optional(reason = "AMD does not expose this (last driver checked: 10.9)")
579580 @Dependent("OpenGL30")
580581 @StripPostfix("params")
581582 void glGetDoublei_vEXT(@GLenum int pname, @GLuint int index, @OutParameter @Check("16") DoubleBuffer params);
586587 @StripPostfix("params")
587588 void glGetDoublei_vEXT2(@GLenum int pname, @GLuint int index, @OutParameter DoubleBuffer params);
588589
589 @Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
590 @Optional(reason = "AMD does not expose this (last driver checked: 10.9)")
590591 @Dependent("OpenGL30")
591592 @StripPostfix(value = "params", hasPostfix = false)
592593 void glGetPointeri_vEXT(@GLenum int pname, @GLuint int index, @Result @GLvoid ByteBuffer params);
597598 TODO: Why 1.2.1 and not EXT_draw_buffers2?
598599 */
599600
600 @Dependent("GL_EXT_draw_buffers2")
601 @Reuse("EXTDrawBuffers2")
602 @Dependent("OpenGL13")
601603 void glEnableIndexedEXT(@GLenum int cap, @GLuint int index);
602604
603 @Dependent("GL_EXT_draw_buffers2")
605 @Reuse("EXTDrawBuffers2")
606 @Dependent("OpenGL13")
604607 void glDisableIndexedEXT(@GLenum int cap, @GLuint int index);
605608
606 @Dependent("GL_EXT_draw_buffers2")
609 @Reuse("EXTDrawBuffers2")
610 @Dependent("OpenGL13")
607611 boolean glIsEnabledIndexedEXT(@GLenum int cap, @GLuint int index);
608612
609 @Dependent("GL_EXT_draw_buffers2")
613 @Reuse("EXTDrawBuffers2")
614 @Dependent("OpenGL13")
610615 @StripPostfix("params")
611616 void glGetIntegerIndexedvEXT(@GLenum int pname, @GLuint int index, @OutParameter @Check("16") IntBuffer params);
612617
618 @Reuse("EXTDrawBuffers2")
613619 @Alternate("glGetIntegerIndexedvEXT")
614620 @GLreturn("params")
615 @Dependent("GL_EXT_draw_buffers2")
621 @Dependent("OpenGL13")
616622 @StripPostfix("params")
617623 void glGetIntegerIndexedvEXT2(@GLenum int pname, @GLuint int index, @OutParameter IntBuffer params);
618624
619 @Dependent("GL_EXT_draw_buffers2")
620 @StripPostfix("params")
621 void glGetBooleanIndexedvEXT(@GLenum int pname, @GLuint int index, @OutParameter @Check("16") @GLboolean ByteBuffer params);
622
625 @Reuse("EXTDrawBuffers2")
626 @Dependent("OpenGL13")
627 @StripPostfix("params")
628 void glGetBooleanIndexedvEXT(@GLenum int pname, @GLuint int index, @OutParameter @Check("4") @GLboolean ByteBuffer params);
629
630 @Reuse("EXTDrawBuffers2")
623631 @Alternate("glGetBooleanIndexedvEXT")
624632 @GLreturn("params")
625 @Dependent("GL_EXT_draw_buffers2")
633 @Dependent("OpenGL13")
626634 @StripPostfix("params")
627635 void glGetBooleanIndexedvEXT2(@GLenum int pname, @GLuint int index, @OutParameter @GLboolean ByteBuffer params);
628636
808816 @GLvoid
809817 ByteBuffer data);
810818
819
811820 @Dependent("OpenGL13")
812821 void glGetCompressedMultiTexImageEXT(@GLenum int texunit, @GLenum int target, int level,
813822 @OutParameter
816825 @GLbyte
817826 @GLshort
818827 @GLint Buffer img);
819
820 @Dependent("OpenGL13")
821 void glGetCompressedTexImage(@GLenum int target, int lod,
822 @OutParameter
823 @BufferObject(BufferKind.PackPBO)
824 @Check
825 @GLbyte
826 @GLshort
827 @GLint Buffer img);
828828
829829 /*
830830 OpenGL 1.3: New transpose matrix commands add "Matrix" suffix
904904 @Dependent("OpenGL15")
905905 @CachedResult
906906 @GLvoid
907 @AutoResultSize("GLChecks.getNamedBufferObjectSize(caps, buffer)")
907 @AutoSize("GLChecks.getNamedBufferObjectSize(caps, buffer)")
908908 ByteBuffer glMapNamedBufferEXT(@GLuint int buffer, @GLenum int access);
909909
910910 @Dependent("OpenGL15")
922922
923923 @Dependent("OpenGL15")
924924 @StripPostfix("params")
925 @AutoResultSize("GLChecks.getNamedBufferObjectSize(caps, buffer)")
925 @AutoSize("GLChecks.getNamedBufferObjectSize(caps, buffer)")
926926 void glGetNamedBufferPointervEXT(@GLuint int buffer, @GLenum int pname, @OutParameter @Result @GLvoid ByteBuffer params);
927927
928928 @Dependent("OpenGL15")
10741074 @Alternate("glTextureParameterIivEXT")
10751075 @Dependent("GL_EXT_texture_integer")
10761076 @StripPostfix("param")
1077 void glTextureParameterIivEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, @Constant(value = "APIUtils.getBufferInt().put(0, param), 0", keepParam = true) int param);
1077 void glTextureParameterIivEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getBufferInt().put(0, param), 0", keepParam = true) int param);
10781078
10791079 @Dependent("GL_EXT_texture_integer")
10801080 @StripPostfix("params")
10831083 @Alternate("glTextureParameterIuivEXT")
10841084 @Dependent("GL_EXT_texture_integer")
10851085 @StripPostfix("param")
1086 void glTextureParameterIuivEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, @Constant(value = "APIUtils.getBufferInt().put(0, param), 0", keepParam = true) @GLuint int param);
1086 void glTextureParameterIuivEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getBufferInt().put(0, param), 0", keepParam = true) @GLuint int param);
10871087
10881088 @Dependent("GL_EXT_texture_integer")
10891089 @StripPostfix("params")
11181118 @Alternate("glMultiTexParameterIivEXT")
11191119 @Dependent("GL_EXT_texture_integer")
11201120 @StripPostfix("param")
1121 void glMultiTexParameterIivEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Constant(value = "APIUtils.getBufferInt().put(0, param), 0", keepParam = true) int param);
1121 void glMultiTexParameterIivEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getBufferInt().put(0, param), 0", keepParam = true) int param);
11221122
11231123 @Dependent("GL_EXT_texture_integer")
11241124 @StripPostfix("params")
11271127 @Alternate("glMultiTexParameterIuivEXT")
11281128 @Dependent("GL_EXT_texture_integer")
11291129 @StripPostfix("param")
1130 void glMultiTexParameterIuivEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Constant(value = "APIUtils.getBufferInt().put(0, param), 0", keepParam = true) int param);
1130 void glMultiTexParameterIuivEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getBufferInt().put(0, param), 0", keepParam = true) int param);
11311131
11321132 @Dependent("GL_EXT_texture_integer")
11331133 @StripPostfix("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)")
13461345 @Dependent("OpenGL31,GL_ARB_copy_buffer")
13471346 void glNamedCopyBufferSubDataEXT(@GLuint int readBuffer, @GLuint int writeBuffer, @GLintptr long readoffset, @GLintptr long writeoffset, @GLsizeiptr long size);
13481347
13861385 and change the final parameter from "const void *" to "intptr offset"
13871386 */
13881387
1389 @Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
13901388 @Dependent("OpenGL30")
13911389 @DeprecatedGL
13921390 void glVertexArrayVertexOffsetEXT(@GLuint int vaobj, @GLuint int buffer, int size, @GLenum int type, @GLsizei int stride, @GLintptr long offset);
13931391
1394 @Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
13951392 @Dependent("OpenGL30")
13961393 @DeprecatedGL
13971394 void glVertexArrayColorOffsetEXT(@GLuint int vaobj, @GLuint int buffer, int size, @GLenum int type, @GLsizei int stride, @GLintptr long offset);
13981395
1399 @Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
14001396 @Dependent("OpenGL30")
14011397 @DeprecatedGL
14021398 void glVertexArrayEdgeFlagOffsetEXT(@GLuint int vaobj, @GLuint int buffer, @GLsizei int stride, @GLintptr long offset);
14031399
1404 @Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
14051400 @Dependent("OpenGL30")
14061401 void glVertexArrayIndexOffsetEXT(@GLuint int vaobj, @GLuint int buffer, @GLenum int type, @GLsizei int stride, @GLintptr long offset);
14071402
1408 @Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
14091403 @Dependent("OpenGL30")
14101404 @DeprecatedGL
14111405 void glVertexArrayNormalOffsetEXT(@GLuint int vaobj, @GLuint int buffer, @GLenum int type, @GLsizei int stride, @GLintptr long offset);
14121406
1413 @Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
14141407 @Dependent("OpenGL30")
14151408 @DeprecatedGL
14161409 void glVertexArrayTexCoordOffsetEXT(@GLuint int vaobj, @GLuint int buffer, int size, @GLenum int type, @GLsizei int stride, @GLintptr long offset);
14171410
1418 @Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
14191411 @Dependent("OpenGL30")
14201412 @DeprecatedGL
14211413 void glVertexArrayMultiTexCoordOffsetEXT(@GLuint int vaobj, @GLuint int buffer, @GLenum int texunit, int size, @GLenum int type, @GLsizei int stride, @GLintptr long offset);
14221414
1423 @Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
14241415 @Dependent("OpenGL30")
14251416 @DeprecatedGL
14261417 void glVertexArrayFogCoordOffsetEXT(@GLuint int vaobj, @GLuint int buffer, @GLenum int type, @GLsizei int stride, @GLintptr long offset);
14271418
1428 @Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
14291419 @Dependent("OpenGL30")
14301420 @DeprecatedGL
14311421 void glVertexArraySecondaryColorOffsetEXT(@GLuint int vaobj, @GLuint int buffer, int size, @GLenum int type, @GLsizei int stride, @GLintptr long offset);
14321422
1433 @Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
14341423 @Dependent("OpenGL30")
14351424 void glVertexArrayVertexAttribOffsetEXT(@GLuint int vaobj, @GLuint int buffer, @GLuint int index, int size, @GLenum int type, boolean normalized, @GLsizei int stride, @GLintptr long offset);
14361425
1437 @Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
14381426 @Dependent("OpenGL30")
14391427 void glVertexArrayVertexAttribIOffsetEXT(@GLuint int vaobj, @GLuint int buffer, @GLuint int index, int size, @GLenum int type, @GLsizei int stride, @GLintptr long offset);
14401428
14441432 "uint vaobj" parameter
14451433 */
14461434
1447 @Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
14481435 @Dependent("OpenGL30")
14491436 void glEnableVertexArrayEXT(@GLuint int vaobj, @GLenum int array);
14501437
1451 @Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
14521438 @Dependent("OpenGL30")
14531439 void glDisableVertexArrayEXT(@GLuint int vaobj, @GLenum int array);
14541440
14581444 and add an initial "uint vaobj" parameter
14591445 */
14601446
1461 @Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
14621447 @Dependent("OpenGL30")
14631448 void glEnableVertexArrayAttribEXT(@GLuint int vaobj, @GLuint int index);
14641449
1465 @Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
14661450 @Dependent("OpenGL30")
14671451 void glDisableVertexArrayAttribEXT(@GLuint int vaobj, @GLuint int index);
14681452
14701454 OpenGL 3.0: New queries for vertex array objects
14711455 */
14721456
1473 @Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
14741457 @Dependent("OpenGL30")
14751458 @StripPostfix("param")
14761459 void glGetVertexArrayIntegervEXT(@GLuint int vaobj, @GLenum int pname, @OutParameter @Check("16") IntBuffer param);
14811464 @StripPostfix("param")
14821465 void glGetVertexArrayIntegervEXT2(@GLuint int vaobj, @GLenum int pname, @OutParameter IntBuffer param);
14831466
1484 @Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
14851467 @Dependent("OpenGL30")
14861468 @StripPostfix("param")
14871469 void glGetVertexArrayPointervEXT(@GLuint int vaobj, @GLenum int pname, @Result @GLvoid ByteBuffer param);
14881470
1489 @Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
14901471 @Dependent("OpenGL30")
14911472 @StripPostfix(value = "param")
14921473 void glGetVertexArrayIntegeri_vEXT(@GLuint int vaobj, @GLuint int index, @GLenum int pname, @OutParameter @Check("16") IntBuffer param);
14971478 @StripPostfix(value = "param", postfix = "_v")
14981479 void glGetVertexArrayIntegeri_vEXT2(@GLuint int vaobj, @GLuint int index, @GLenum int pname, @OutParameter IntBuffer param);
14991480
1500 @Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
15011481 @Dependent("OpenGL30")
15021482 @StripPostfix(value = "param")
15031483 void glGetVertexArrayPointeri_vEXT(@GLuint int vaobj, @GLuint int index, @GLenum int pname, @Result @GLvoid ByteBuffer param);
15211501 *
15221502 * @return A ByteBuffer representing the mapped buffer memory.
15231503 */
1524 @Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
15251504 @Dependent("OpenGL30")
15261505 @CachedResult(isRange = true)
15271506 @GLvoid
1528 @AutoResultSize("length")
1507 @AutoSize("length")
15291508 ByteBuffer glMapNamedBufferRangeEXT(@GLuint int buffer, @GLintptr long offset, @GLsizeiptr long length, @GLbitfield int access);
15301509
1531 @Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
15321510 @Dependent("OpenGL30")
15331511 void glFlushMappedNamedBufferRangeEXT(@GLuint int buffer, @GLintptr long offset, @GLsizeiptr long length);
15341512
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
35 import org.lwjgl.util.generator.opengl.GLboolean;
36 import org.lwjgl.util.generator.opengl.GLenum;
37 import org.lwjgl.util.generator.opengl.GLreturn;
38 import org.lwjgl.util.generator.opengl.GLuint;
3439
3540 import java.nio.IntBuffer;
3641 import java.nio.ByteBuffer;
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.*;
3435
3536 import java.nio.Buffer;
3637
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.*;
3435
3536 import java.nio.*;
3637
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.GLdouble;
35 import org.lwjgl.util.generator.opengl.GLenum;
36 import org.lwjgl.util.generator.opengl.GLfloat;
37 import org.lwjgl.util.generator.opengl.GLsizei;
3438
3539 import java.nio.*;
3640
3030 */
3131 package org.lwjgl.opengl;
3232
33 import org.lwjgl.util.generator.*;
33 import org.lwjgl.util.generator.opengl.GLbitfield;
34 import org.lwjgl.util.generator.opengl.GLenum;
35 import org.lwjgl.util.generator.opengl.GLint;
3436
3537 public interface EXT_framebuffer_blit {
3638
3030 */
3131 package org.lwjgl.opengl;
3232
33 import org.lwjgl.util.generator.GLenum;
34 import org.lwjgl.util.generator.GLsizei;
33 import org.lwjgl.util.generator.opengl.GLenum;
34 import org.lwjgl.util.generator.opengl.GLsizei;
3535
3636 public interface EXT_framebuffer_multisample {
3737
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
35 import org.lwjgl.util.generator.opengl.GLenum;
36 import org.lwjgl.util.generator.opengl.GLreturn;
37 import org.lwjgl.util.generator.opengl.GLsizei;
38 import org.lwjgl.util.generator.opengl.GLuint;
3439
3540 import java.nio.IntBuffer;
3641
130135 void glDeleteRenderbuffersEXT(@AutoSize("renderbuffers") int n, @Const @GLuint IntBuffer renderbuffers);
131136
132137 @Alternate("glDeleteRenderbuffersEXT")
133 void glDeleteRenderbuffersEXT(@Constant("1") int n, @Constant(value = "APIUtils.getBufferInt().put(0, renderbuffer), 0", keepParam = true) int renderbuffer);
138 void glDeleteRenderbuffersEXT(@Constant("1") int n, @Constant(value = "APIUtil.getBufferInt().put(0, renderbuffer), 0", keepParam = true) int renderbuffer);
134139
135140 void glGenRenderbuffersEXT(@AutoSize("renderbuffers") int n, @OutParameter @GLuint IntBuffer renderbuffers);
136141
155160 void glDeleteFramebuffersEXT(@AutoSize("framebuffers") int n, @Const @GLuint IntBuffer framebuffers);
156161
157162 @Alternate("glDeleteFramebuffersEXT")
158 void glDeleteFramebuffersEXT(@Constant("1") int n, @Constant(value = "APIUtils.getBufferInt().put(0, framebuffer), 0", keepParam = true) int framebuffer);
163 void glDeleteFramebuffersEXT(@Constant("1") int n, @Constant(value = "APIUtil.getBufferInt().put(0, framebuffer), 0", keepParam = true) int framebuffer);
159164
160165 void glGenFramebuffersEXT(@AutoSize("framebuffers") int n, @OutParameter @GLuint IntBuffer framebuffers);
161166
3030 */
3131 package org.lwjgl.opengl;
3232
33 import org.lwjgl.util.generator.GLenum;
34 import org.lwjgl.util.generator.GLuint;
33 import org.lwjgl.util.generator.opengl.GLenum;
34 import org.lwjgl.util.generator.opengl.GLuint;
3535
3636 public interface EXT_geometry_shader4 {
3737
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.GLenum;
35 import org.lwjgl.util.generator.opengl.GLsizei;
36 import org.lwjgl.util.generator.opengl.GLuint;
3437
3538 import java.nio.*;
3639
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
35 import org.lwjgl.util.generator.opengl.*;
3436
3537 import java.nio.Buffer;
3638 import java.nio.ByteBuffer;
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.GLenum;
35 import org.lwjgl.util.generator.opengl.GLsizei;
3436
3537 import java.nio.*;
3638
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.*;
3435
3536 import java.nio.*;
3637
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.GLenum;
3435
3536 import java.nio.*;
3637
3030 */
3131 package org.lwjgl.opengl;
3232
33 import org.lwjgl.util.generator.GLenum;
33 import org.lwjgl.util.generator.opengl.GLenum;
3434
3535 public interface EXT_provoking_vertex {
3636
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.*;
3435
3536 import java.nio.Buffer;
3637
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
35 import org.lwjgl.util.generator.opengl.GLchar;
36 import org.lwjgl.util.generator.opengl.GLenum;
37 import org.lwjgl.util.generator.opengl.GLuint;
3438
3539 import java.nio.ByteBuffer;
3640
3030 */
3131 package org.lwjgl.opengl;
3232
33 import org.lwjgl.util.generator.GLbitfield;
34 import org.lwjgl.util.generator.GLenum;
35 import org.lwjgl.util.generator.GLuint;
33 import org.lwjgl.util.generator.opengl.GLbitfield;
34 import org.lwjgl.util.generator.opengl.GLenum;
35 import org.lwjgl.util.generator.opengl.GLuint;
3636
3737 public interface EXT_shader_image_load_store {
3838
3030 */
3131 package org.lwjgl.opengl;
3232
33 import org.lwjgl.util.generator.*;
33 import org.lwjgl.util.generator.opengl.GLsizei;
34 import org.lwjgl.util.generator.opengl.GLuint;
3435
3536 public interface EXT_stencil_clear_tag {
3637
3030 */
3131 package org.lwjgl.opengl;
3232
33 import org.lwjgl.util.generator.*;
33 import org.lwjgl.util.generator.opengl.GLenum;
3434
3535 public interface EXT_stencil_two_side {
3636 int GL_STENCIL_TEST_TWO_SIDE_EXT = 0x8910;
3030 */
3131 package org.lwjgl.opengl;
3232
33 import org.lwjgl.util.generator.GLenum;
34 import org.lwjgl.util.generator.GLuint;
33 import org.lwjgl.util.generator.Reuse;
34 import org.lwjgl.util.generator.opengl.GLenum;
35 import org.lwjgl.util.generator.opengl.GLuint;
3536
3637 public interface EXT_texture_array {
3738
8283 int GL_SAMPLER_1D_ARRAY_SHADOW_EXT = 0x8DC3;
8384 int GL_SAMPLER_2D_ARRAY_SHADOW_EXT = 0x8DC4;
8485
86 @Reuse("EXTGeometryShader4")
8587 void glFramebufferTextureLayerEXT(@GLenum int target, @GLenum int attachment, @GLuint int texture, int level, int layer);
8688
8789 }
3030 */
3131 package org.lwjgl.opengl;
3232
33 import org.lwjgl.util.generator.GLenum;
34 import org.lwjgl.util.generator.GLuint;
33 import org.lwjgl.util.generator.opengl.GLenum;
34 import org.lwjgl.util.generator.opengl.GLuint;
3535
3636 public interface EXT_texture_buffer_object {
3737
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
35 import org.lwjgl.util.generator.opengl.GLenum;
36 import org.lwjgl.util.generator.opengl.GLreturn;
37 import org.lwjgl.util.generator.opengl.GLuint;
3438
3539 import java.nio.IntBuffer;
3640
113117
114118 @Alternate("glTexParameterIivEXT")
115119 @StripPostfix(value = "param", postfix = "v")
116 void glTexParameterIivEXT(@GLenum int target, @GLenum int pname, @Constant(value = "APIUtils.getBufferInt().put(0, param), 0", keepParam = true) int param);
120 void glTexParameterIivEXT(@GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getBufferInt().put(0, param), 0", keepParam = true) int param);
117121
118122 @StripPostfix("params")
119123 void glTexParameterIuivEXT(@GLenum int target, @GLenum int pname, @Check("4") @GLuint IntBuffer params);
120124
121125 @Alternate("glTexParameterIuivEXT")
122126 @StripPostfix(value = "param", postfix = "v")
123 void glTexParameterIuivEXT(@GLenum int target, @GLenum int pname, @Constant(value = "APIUtils.getBufferInt().put(0, param), 0", keepParam = true) int param);
127 void glTexParameterIuivEXT(@GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getBufferInt().put(0, param), 0", keepParam = true) int param);
124128
125129 @StripPostfix("params")
126130 void glGetTexParameterIivEXT(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params);
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.opengl;
32
33 public interface EXT_texture_sRGB_decode {
34
35 /**
36 * Accepted by the &lt;pname&gt; parameter of TexParameterf, TexParameteri,
37 * GetTexParameterfv, GetTexParameteriv, SamplerParameteri,
38 * SamplerParameterf, SamplerParameteriv, SamplerParameterfv,
39 * SamplerParameterIiv, SamplerParameterIuiv, GetSamplerParameteriv,
40 * GetSamplerParameterfv, GetSamplerParameterIiv, and GetSamplerParameterIuiv:
41 */
42 int GL_TEXTURE_SRGB_DECODE_EXT = 0x8A48;
43
44 /**
45 * Accepted by the &lt;enum&gt; parameter of TexParameterf, TexParameteri,
46 * SamplerParameteri, SamplerParameterf, SamplerParameteriv, SamplerParameterfv,
47 * SamplerParameterIiv and SamplerParameterIuiv:
48 */
49 int GL_DECODE_EXT = 0x8A49,
50 GL_SKIP_DECODE_EXT = 0x8A4A;
51
52 }
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
35 import org.lwjgl.util.generator.opengl.*;
3436
3537 import java.nio.*;
3638
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
35 import org.lwjgl.util.generator.opengl.*;
3436
3537 import java.nio.ByteBuffer;
3638 import java.nio.IntBuffer;
101103 void glEndTransformFeedbackEXT();
102104
103105 void glTransformFeedbackVaryingsEXT(@GLuint int program, @GLsizei int count,
104 @Const @NullTerminated("count") @GLchar @StringList("count") ByteBuffer varyings,
106 @Const @NullTerminated("count") @GLchar @PointerArray("count") ByteBuffer varyings,
105107 @GLenum int bufferMode);
106108
107109 @Alternate("glTransformFeedbackVaryingsEXT")
108110 void glTransformFeedbackVaryingsEXT(@GLuint int program, @Constant("varyings.length") @GLsizei int count,
109 @Const @NullTerminated @StringList("count") CharSequence[] varyings,
111 @Const @NullTerminated @PointerArray("count") CharSequence[] varyings,
110112 @GLenum int bufferMode);
111113
112114 void glGetTransformFeedbackVaryingEXT(@GLuint int program, @GLuint int index, @AutoSize("name") @GLsizei int bufSize,
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.*;
3435
3536 import java.nio.Buffer;
3637 import java.nio.DoubleBuffer;
8081 @StripPostfix("params")
8182 void glGetVertexAttribLdvEXT(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") DoubleBuffer params);
8283
84 @Reuse("ARBVertexAttrib64bit")
8385 @Dependent("EXT_direct_state_access")
8486 void glVertexArrayVertexAttribLOffsetEXT(@GLuint int vaobj, @GLuint int buffer, @GLuint int index, int size, @GLenum int type, @GLsizei int stride, @GLintptr long offset);
8587
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.*;
3435
3536 import java.nio.*;
3637
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.GLenum;
35 import org.lwjgl.util.generator.opengl.GLfloat;
36 import org.lwjgl.util.generator.opengl.GLsizei;
3437
3538 import java.nio.*;
3639
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
35 import org.lwjgl.util.generator.opengl.*;
3436
3537 import java.nio.*;
3638
3840 * The core OpenGL1.1 API.
3941 *
4042 * @author cix_foo <cix_foo@users.sourceforge.net>
41 * @version $Revision: 3338 $
42 * $Id: GL11.java 3338 2010-05-01 09:19:00Z spasi $
43 * @version $Revision: 3460 $
44 * $Id: GL11.java 3460 2010-11-29 18:25:28Z spasi $
4345 */
4446 @DeprecatedGL
4547 public interface GL11 {
781783 void glDeleteTextures(@AutoSize("textures") @GLsizei int n, @Const @GLuint IntBuffer textures);
782784
783785 @Alternate("glDeleteTextures")
784 void glDeleteTextures(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, texture), 0", keepParam = true) int texture);
786 void glDeleteTextures(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, texture), 0", keepParam = true) int texture);
785787
786788 void glCullFace(@GLenum int mode);
787789
15621564
15631565 @DeprecatedGL
15641566 void glTexCoordPointer(int size, @AutoType("pointer") @GLenum int type, @GLsizei int stride,
1565 @CachedReference(index = "GLChecks.getReferences(caps).glClientActiveTexture", name = "glTexCoordPointer_buffer")
1567 @CachedReference(index = "StateTracker.getReferences(caps).glClientActiveTexture", name = "glTexCoordPointer_buffer")
15661568 @BufferObject(BufferKind.ArrayVBO)
15671569 @Check
15681570 @Const
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.*;
3435
3536 import java.nio.Buffer;
3637
3940 * The core OpenGL1.2.1 API, with the imaging subset.
4041 *
4142 * @author cix_foo <cix_foo@users.sourceforge.net>
42 * @version $Revision: 2984 $
43 * $Id: GL12.java 2984 2008-04-07 18:39:53Z matzon $
43 * @version $Revision: 3412 $
44 * $Id: GL12.java 3412 2010-09-26 23:43:24Z spasi $
4445 */
4546
4647 public interface GL12 {
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.*;
3435
3536 import java.nio.*;
3637
3940 * The core OpenGL1.3 API.
4041 *
4142 * @author cix_foo <cix_foo@users.sourceforge.net>
42 * @version $Revision: 3116 $
43 * $Id: GL13.java 3116 2008-08-19 16:46:03Z spasi $
43 * @version $Revision: 3460 $
44 * $Id: GL13.java 3460 2010-11-29 18:25:28Z spasi $
4445 */
4546 @DeprecatedGL
4647 public interface GL13 {
148149
149150 void glActiveTexture(@GLenum int texture);
150151
151 @Code("\t\tGLChecks.getReferences(caps).glClientActiveTexture = texture - GL_TEXTURE0;")
152 @Code("\t\tStateTracker.getReferences(caps).glClientActiveTexture = texture - GL_TEXTURE0;")
152153 @DeprecatedGL
153154 void glClientActiveTexture(@GLenum int texture);
154155
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.*;
3435
3536 import java.nio.*;
3637
3940 * The core OpenGL1.4 API.
4041 *
4142 * @author cix_foo <cix_foo@users.sourceforge.net>
42 * @version $Revision: 3287 $
43 * $Id: GL14.java 3287 2010-03-14 23:24:40Z spasi $
43 * @version $Revision: 3460 $
44 * $Id: GL14.java 3460 2010-11-29 18:25:28Z spasi $
4445 */
4546 @DeprecatedGL
4647 public interface GL14 {
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
35 import org.lwjgl.util.generator.opengl.*;
3436
3537 import java.nio.Buffer;
3638 import java.nio.ByteBuffer;
9496 void glDeleteBuffers(@AutoSize("buffers") @GLsizei int n, @Const @GLuint IntBuffer buffers);
9597
9698 @Alternate("glDeleteBuffers")
97 void glDeleteBuffers(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, buffer), 0", keepParam = true) int buffer);
99 void glDeleteBuffers(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, buffer), 0", keepParam = true) int buffer);
98100
99101 void glGenBuffers(@AutoSize("buffers") @GLsizei int n, @OutParameter @GLuint IntBuffer buffers);
100102
155157 */
156158 @CachedResult
157159 @GLvoid
158 @AutoResultSize("GLChecks.getBufferObjectSize(caps, target)")
160 @AutoSize("GLChecks.getBufferObjectSize(caps, target)")
159161 ByteBuffer glMapBuffer(@GLenum int target, @GLenum int access);
160162
161163 boolean glUnmapBuffer(@GLenum int target);
169171 void glGetBufferParameteriv2(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params);
170172
171173 @StripPostfix("pointer")
172 @AutoResultSize("GLChecks.getBufferObjectSize(caps, target)")
174 @AutoSize("GLChecks.getBufferObjectSize(caps, target)")
173175 void glGetBufferPointerv(@GLenum int target, @GLenum int pname, @OutParameter @Result @GLvoid ByteBuffer pointer);
174176
175177 // -----------------------------------------------------------------
202204 void glDeleteQueries(@AutoSize("ids") @GLsizei int n, @GLuint IntBuffer ids);
203205
204206 @Alternate("glDeleteQueries")
205 void glDeleteQueries(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, id), 0", keepParam = true) int id);
207 void glDeleteQueries(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, id), 0", keepParam = true) int id);
206208
207209 boolean glIsQuery(@GLuint int id);
208210
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
35 import org.lwjgl.util.generator.opengl.*;
3436
3537 import java.nio.*;
3638
104106
105107 @Alternate(value = "glShaderSource", nativeAlt = true)
106108 void glShaderSource3(@GLuint int shader, @Constant("strings.length") @GLsizei int count,
107 @Const @StringList(value = "count", lengths = "length") CharSequence[] strings,
108 @Constant("APIUtils.getLengths(strings), 0") @Const IntBuffer length);
109 @Const @PointerArray(value = "count", lengths = "length") CharSequence[] strings,
110 @Constant("APIUtil.getLengths(strings), 0") @Const IntBuffer length);
109111
110112 int glCreateShader(@GLuint int type);
111113
254256 @Alternate(value = "glGetActiveUniform", javaAlt = true)
255257 @GLreturn(value = "name", maxLength = "maxLength")
256258 void glGetActiveUniform(@GLuint int program, @GLuint int index, @GLsizei int maxLength,
257 @OutParameter @GLsizei @Constant("name_length, 0, APIUtils.getBufferInt(), 0, APIUtils.getBufferInt(), 1") IntBuffer length,
259 @OutParameter @GLsizei @Constant("name_length, 0, APIUtil.getBufferInt(), 0, APIUtil.getBufferInt(), 1") IntBuffer length,
258260 @OutParameter @GLchar ByteBuffer name);
259261
260262 /** Overloads glGetActiveUniform. This version returns only the uniform size. */
264266 @OutParameter @GLsizei @Constant("null, 0") IntBuffer length,
265267 @OutParameter IntBuffer size,
266268 @OutParameter @GLenum @Constant("size, 1") IntBuffer type, // Reuse size buffer and ignore
267 @OutParameter @GLchar @Constant("APIUtils.getBufferByte(0), 0") ByteBuffer name);
269 @OutParameter @GLchar @Constant("APIUtil.getBufferByte(0), 0") ByteBuffer name);
268270
269271 /** Overloads glGetActiveUniform. This version returns only the uniform type. */
270272 @Alternate(value = "glGetActiveUniform", javaAlt = true)
273275 @OutParameter @GLsizei @Constant("null, 0") IntBuffer length,
274276 @OutParameter @Constant("type, 1") IntBuffer size, // Reuse type buffer and ignore
275277 @OutParameter @GLenum IntBuffer type,
276 @OutParameter @GLchar @Constant("APIUtils.getBufferByte(0), 0") ByteBuffer name);
278 @OutParameter @GLchar @Constant("APIUtil.getBufferByte(0), 0") ByteBuffer name);
277279
278280 @StripPostfix("params")
279281 void glGetUniformfv(@GLuint int program, int location, @OutParameter @Check FloatBuffer params);
429431 @Alternate(value = "glGetActiveAttrib", javaAlt = true)
430432 @GLreturn(value = "name", maxLength = "maxLength")
431433 void glGetActiveAttrib(@GLuint int program, @GLuint int index, @GLsizei int maxLength,
432 @OutParameter @GLsizei @Constant("name_length, 0, APIUtils.getBufferInt(), 0, APIUtils.getBufferInt(), 1") IntBuffer length,
434 @OutParameter @GLsizei @Constant("name_length, 0, APIUtil.getBufferInt(), 0, APIUtil.getBufferInt(), 1") IntBuffer length,
433435 @OutParameter @GLchar ByteBuffer name);
434436
435437 /** Overloads glGetActiveAttribARB. This version returns only the attrib size. */
439441 @OutParameter @GLsizei @Constant("null, 0") IntBuffer length,
440442 @OutParameter IntBuffer size,
441443 @OutParameter @GLenum @Constant("size, 1") IntBuffer type, // Reuse size buffer and ignore
442 @OutParameter @GLchar @Constant("APIUtils.getBufferByte(0), 0") ByteBuffer name);
444 @OutParameter @GLchar @Constant("APIUtil.getBufferByte(0), 0") ByteBuffer name);
443445
444446 /** Overloads glGetActiveAttrib. This version returns only the attrib type. */
445447 @Alternate(value = "glGetActiveAttrib", javaAlt = true)
448450 @OutParameter @GLsizei @Constant("null, 0") IntBuffer length,
449451 @OutParameter @Constant("type, 1") IntBuffer size, // Reuse type buffer and ignore
450452 @OutParameter @GLenum IntBuffer type,
451 @OutParameter @GLchar @Constant("APIUtils.getBufferByte(0), 0") ByteBuffer name);
453 @OutParameter @GLchar @Constant("APIUtil.getBufferByte(0), 0") ByteBuffer name);
452454
453455 int glGetAttribLocation(@GLuint int program, @NullTerminated @Const @GLchar ByteBuffer name);
454456
506508 void glDrawBuffers(@AutoSize("buffers") @GLsizei int size, @Const @GLenum IntBuffer buffers);
507509
508510 @Alternate("glDrawBuffers")
509 void glDrawBuffers(@Constant("1") @GLsizei int size, @Constant(value = "APIUtils.getBufferInt().put(0, buffer), 0", keepParam = true) int buffer);
511 void glDrawBuffers(@Constant("1") @GLsizei int size, @Constant(value = "APIUtil.getBufferInt().put(0, buffer), 0", keepParam = true) int buffer);
510512
511513 // ----------------------------------------------------------------
512514 // ----------------------[ ARB_point_sprite ]----------------------
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.AutoSize;
34 import org.lwjgl.util.generator.GLsizei;
34 import org.lwjgl.util.generator.opengl.GLsizei;
3535 import org.lwjgl.util.generator.StripPostfix;
3636
3737 import java.nio.FloatBuffer;
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
35 import org.lwjgl.util.generator.opengl.*;
3436
3537 import java.nio.*;
3638
293295 */
294296 @CachedResult(isRange = true)
295297 @GLvoid
296 @AutoResultSize("length")
298 @AutoSize("length")
297299 ByteBuffer glMapBufferRange(@GLenum int target, @GLintptr long offset, @GLsizeiptr long length, @GLbitfield int access);
298300
299301 void glFlushMappedBufferRange(@GLenum int target, @GLintptr long offset, @GLsizeiptr long length);
411413 int GL_TEXTURE_SHARED_SIZE = 0x8C3F;
412414
413415 // ----------------------------------------------------------------------
414 // ----------------------[ EXT_framebuffer_object ]----------------------
416 // ----------------------[ ARB_framebuffer_object ]----------------------
415417 // ----------------------------------------------------------------------
416418
417419 /**
418420 * Accepted by the &lt;target&gt; parameter of BindFramebuffer,
419 * CheckFramebufferStatus, FramebufferTexture{1D|2D|3D}, and
420 * FramebufferRenderbuffer:
421 * CheckFramebufferStatus, FramebufferTexture{1D|2D|3D},
422 * FramebufferRenderbuffer, and
423 * GetFramebufferAttachmentParameteriv:
421424 */
422425 int GL_FRAMEBUFFER = 0x8D40;
426 int GL_READ_FRAMEBUFFER = 0x8CA8;
427 int GL_DRAW_FRAMEBUFFER = 0x8CA9;
423428
424429 /**
425430 * Accepted by the &lt;target&gt; parameter of BindRenderbuffer,
456461 int GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME = 0x8CD1;
457462 int GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL = 0x8CD2;
458463 int GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = 0x8CD3;
459 int GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET = 0x8CD4;
464 int GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING = 0x8210;
465 int GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE = 0x8211;
466 int GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE = 0x8212;
467 int GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE = 0x8213;
468 int GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE = 0x8214;
469 int GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE = 0x8215;
470 int GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE = 0x8216;
471 int GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE = 0x8217;
472
473 /** Returned in &lt;params&gt; by GetFramebufferAttachmentParameteriv: */
474 int GL_FRAMEBUFFER_DEFAULT = 0x8218;
475 int GL_INDEX = 0x8222;
460476
461477 /**
462478 * Accepted by the &lt;attachment&gt; parameter of
481497 int GL_COLOR_ATTACHMENT15 = 0x8CEF;
482498 int GL_DEPTH_ATTACHMENT = 0x8D00;
483499 int GL_STENCIL_ATTACHMENT = 0x8D20;
500 int GL_DEPTH_STENCIL_ATTACHMENT = 0x821A;
484501
485502 /** Returned by CheckFramebufferStatus(): */
486503 int GL_FRAMEBUFFER_COMPLETE = 0x8CD5;
487504 int GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT = 0x8CD6;
488505 int GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = 0x8CD7;
489 int GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS = 0x8CD9;
490 int GL_FRAMEBUFFER_INCOMPLETE_FORMATS = 0x8CDA;
491506 int GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER = 0x8CDB;
492507 int GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER = 0x8CDC;
493508 int GL_FRAMEBUFFER_UNSUPPORTED = 0x8CDD;
494
495 /** Accepted by GetIntegerv(): */
496 int GL_FRAMEBUFFER_BINDING = 0x8CA6;
509 int GL_FRAMEBUFFER_UNDEFINED = 0x8219;
510
511 /**
512 * Accepted by the &lt;pname&gt; parameters of GetIntegerv, GetFloatv,
513 * and GetDoublev:
514 */
515 int GL_FRAMEBUFFER_BINDING = 0x8CA6; // alias DRAW_FRAMEBUFFER_BINDING
497516 int GL_RENDERBUFFER_BINDING = 0x8CA7;
498517 int GL_MAX_COLOR_ATTACHMENTS = 0x8CDF;
499518 int GL_MAX_RENDERBUFFER_SIZE = 0x84E8;
508527 void glDeleteRenderbuffers(@AutoSize("renderbuffers") int n, @Const @GLuint IntBuffer renderbuffers);
509528
510529 @Alternate("glDeleteRenderbuffers")
511 void glDeleteRenderbuffers(@Constant("1") int n, @Constant(value = "APIUtils.getBufferInt().put(0, renderbuffer), 0", keepParam = true) int renderbuffer);
530 void glDeleteRenderbuffers(@Constant("1") int n, @Constant(value = "APIUtil.getBufferInt().put(0, renderbuffer), 0", keepParam = true) int renderbuffer);
512531
513532 void glGenRenderbuffers(@AutoSize("renderbuffers") int n, @OutParameter @GLuint IntBuffer renderbuffers);
514533
533552 void glDeleteFramebuffers(@AutoSize("framebuffers") int n, @Const @GLuint IntBuffer framebuffers);
534553
535554 @Alternate("glDeleteFramebuffers")
536 void glDeleteFramebuffers(@Constant("1") int n, @Constant(value = "APIUtils.getBufferInt().put(0, framebuffer), 0", keepParam = true) int framebuffer);
555 void glDeleteFramebuffers(@Constant("1") int n, @Constant(value = "APIUtil.getBufferInt().put(0, framebuffer), 0", keepParam = true) int framebuffer);
537556
538557 void glGenFramebuffers(@AutoSize("framebuffers") int n, @OutParameter @GLuint IntBuffer framebuffers);
539558
608627 // --------------------------------------------------------------------
609628 // ----------------------[ EXT_framebuffer_blit ]----------------------
610629 // --------------------------------------------------------------------
611
612 /**
613 * Accepted by the &lt;target&gt; parameter of BindFramebuffer,
614 * CheckFramebufferStatus, FramebufferTexture{1D|2D|3D},
615 * FramebufferRenderbuffer, and
616 * GetFramebufferAttachmentParameteriv.
617 */
618 int GL_READ_FRAMEBUFFER = 0x8CA8;
619 int GL_DRAW_FRAMEBUFFER = 0x8CA9;
620630
621631 /** Accepted by the &lt;pname&gt; parameters of GetIntegerv, GetFloatv, and GetDoublev. */
622632 int GL_DRAW_FRAMEBUFFER_BINDING = 0x8CA6; // alias FRAMEBUFFER_BINDING
701711
702712 @Alternate("glTexParameterIiv")
703713 @StripPostfix(value = "param", postfix = "v")
704 void glTexParameterIiv(@GLenum int target, @GLenum int pname, @Constant(value = "APIUtils.getBufferInt().put(0, param), 0", keepParam = true) int param);
714 void glTexParameterIiv(@GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getBufferInt().put(0, param), 0", keepParam = true) int param);
705715
706716 @StripPostfix("params")
707717 void glTexParameterIuiv(@GLenum int target, @GLenum int pname, @Check("4") @GLuint IntBuffer params);
708718
709719 @Alternate("glTexParameterIuiv")
710720 @StripPostfix(value = "param", postfix = "v")
711 void glTexParameterIuiv(@GLenum int target, @GLenum int pname, @Constant(value = "APIUtils.getBufferInt().put(0, param), 0", keepParam = true) int param);
721 void glTexParameterIuiv(@GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getBufferInt().put(0, param), 0", keepParam = true) int param);
712722
713723 @StripPostfix("params")
714724 void glGetTexParameterIiv(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params);
968978 void glEndTransformFeedback();
969979
970980 void glTransformFeedbackVaryings(@GLuint int program, @GLsizei int count,
971 @Const @NullTerminated("count") @GLchar @StringList("count") ByteBuffer varyings,
981 @Const @NullTerminated("count") @GLchar @PointerArray("count") ByteBuffer varyings,
972982 @GLenum int bufferMode);
973983
974984 @Alternate("glTransformFeedbackVaryings")
975985 void glTransformFeedbackVaryings(@GLuint int program, @Constant("varyings.length") @GLsizei int count,
976 @Const @NullTerminated @StringList("count") CharSequence[] varyings,
986 @Const @NullTerminated @PointerArray("count") CharSequence[] varyings,
977987 @GLenum int bufferMode);
978988
979989 void glGetTransformFeedbackVarying(@GLuint int program, @GLuint int index, @AutoSize("name") @GLsizei int bufSize,
10001010 */
10011011 int GL_VERTEX_ARRAY_BINDING = 0x85B5;
10021012
1013 @Code(" StateTracker.bindVAO(caps, array);")
10031014 void glBindVertexArray(@GLuint int array);
10041015
1016 @Code(" StateTracker.deleteVAO(caps, arrays);")
10051017 void glDeleteVertexArrays(@AutoSize("arrays") @GLsizei int n, @Const @GLuint IntBuffer arrays);
10061018
10071019 @Alternate("glDeleteVertexArrays")
1008 void glDeleteVertexArrays(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, array), 0", keepParam = true) int array);
1020 @Code(" StateTracker.deleteVAO(caps, array);")
1021 void glDeleteVertexArrays(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, array), 0", keepParam = true) int array);
10091022
10101023 void glGenVertexArrays(@AutoSize("arrays") @GLsizei int n, @OutParameter @GLuint IntBuffer arrays);
10111024
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
35 import org.lwjgl.util.generator.opengl.*;
3436
3537 import java.nio.Buffer;
3638 import java.nio.ByteBuffer;
231233 int GL_INVALID_INDEX = 0xFFFFFFFF;
232234
233235 void glGetUniformIndices(@GLuint int program, @AutoSize("uniformIndices") @GLsizei int uniformCount,
234 @Const @NullTerminated("uniformIndices.remaining()") @GLchar @StringList("uniformCount") ByteBuffer uniformNames,
236 @Const @NullTerminated("uniformIndices.remaining()") @GLchar @PointerArray("uniformCount") ByteBuffer uniformNames,
235237 @OutParameter @GLuint IntBuffer uniformIndices);
236238
237239 @Alternate("glGetUniformIndices")
238240 void glGetUniformIndices(@GLuint int program, @Constant("uniformNames.length") @GLsizei int uniformCount,
239 @Const @NullTerminated @StringList("uniformCount") CharSequence[] uniformNames,
241 @Const @NullTerminated @PointerArray("uniformCount") CharSequence[] uniformNames,
240242 @OutParameter @Check("uniformNames.length") @GLuint IntBuffer uniformIndices);
241243
242244 @StripPostfix("params")
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.PointerWrapper;
35 import org.lwjgl.util.generator.Alternate;
36 import org.lwjgl.util.generator.opengl.*;
3437
3538 import java.nio.Buffer;
3639 import java.nio.FloatBuffer;
258261
259262 void glFramebufferTexture(@GLenum int target, @GLenum int attachment, @GLuint int texture, int level);
260263
261 void glFramebufferTextureLayer(@GLenum int target, @GLenum int attachment, @GLuint int texture, int level, int layer);
262
263264 // --------------------------------------------------------
264265 // ----------------------[ ARB_sync ]----------------------
265266 // --------------------------------------------------------
295296 int GL_CONDITION_SATISFIED = 0x911C;
296297 int GL_WAIT_FAILED = 0x911D;
297298
298 @GLpointer("GLsync")
299 @PointerWrapper("GLsync")
299300 GLSync glFenceSync(@GLenum int condition, @GLbitfield int flags);
300301
301 boolean glIsSync(@GLpointer("GLsync") GLSync sync);
302
303 void glDeleteSync(@GLpointer("GLsync") GLSync sync);
302 boolean glIsSync(@PointerWrapper("GLsync") GLSync sync);
303
304 void glDeleteSync(@PointerWrapper("GLsync") GLSync sync);
304305
305306 @GLenum
306 int glClientWaitSync(@GLpointer("GLsync") GLSync sync, @GLbitfield int flags, @GLuint64 long timeout);
307
308 void glWaitSync(@GLpointer("GLsync") GLSync sync, @GLbitfield int flags, @GLuint64 long timeout);
309
310 @StripPostfix(value = "data", postfix = "64")
307 int glClientWaitSync(@PointerWrapper("GLsync") GLSync sync, @GLbitfield int flags, @GLuint64 long timeout);
308
309 void glWaitSync(@PointerWrapper("GLsync") GLSync sync, @GLbitfield int flags, @GLuint64 long timeout);
310
311 @StripPostfix("data")
311312 void glGetInteger64v(@GLenum int pname, @OutParameter @Check("1") @GLint64 LongBuffer data);
312313
313314 @Alternate("glGetInteger64v")
314315 @GLreturn("data")
315 @StripPostfix(value = "data", postfix = "64")
316 @StripPostfix("data")
316317 void glGetInteger64v2(@GLenum int pname, @OutParameter @GLint64 LongBuffer data);
317318
318 @StripPostfix(value = "data", postfix = "64")
319 @StripPostfix("data")
319320 @Optional(reason = "NV's 3.2 implementation does not expose this (last driver checked: 19?.??)")
320321 void glGetInteger64i_v(@GLenum int value, @GLuint int index, @OutParameter @Check("4") @GLint64 LongBuffer data);
321322
322323 @Alternate("glGetInteger64i_v")
323324 @GLreturn("data")
324 @StripPostfix(value = "data", postfix = "64")
325 @StripPostfix("data")
325326 void glGetInteger64i_v2(@GLenum int value, @GLuint int index, @OutParameter @GLint64 LongBuffer data);
326327
327328 @StripPostfix("values")
328 void glGetSynciv(@GLpointer("GLsync") GLSync sync, @GLenum int pname, @AutoSize("values") @GLsizei int bufSize,
329 void glGetSynciv(@PointerWrapper("GLsync") GLSync sync, @GLenum int pname, @AutoSize("values") @GLsizei int bufSize,
329330 @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length,
330331 @OutParameter IntBuffer values);
331332
332333 @Alternate("glGetSynciv")
333334 @GLreturn("values")
334335 @StripPostfix("values")
335 void glGetSynciv2(@GLpointer("GLsync") GLSync sync, @GLenum int pname, @Constant("1") @GLsizei int bufSize,
336 void glGetSynciv2(@PointerWrapper("GLsync") GLSync sync, @GLenum int pname, @Constant("1") @GLsizei int bufSize,
336337 @OutParameter @GLsizei @Constant("null, 0") IntBuffer length,
337338 @OutParameter IntBuffer values);
338339 }
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
35 import org.lwjgl.util.generator.opengl.*;
3436
3537 import java.nio.ByteBuffer;
3638 import java.nio.FloatBuffer;
99101 void glDeleteSamplers(@AutoSize("samplers") @GLsizei int count, @Const @GLuint IntBuffer samplers);
100102
101103 @Alternate("glDeleteSamplers")
102 void glDeleteSamplers(@Constant("1") @GLsizei int count, @Constant(value = "APIUtils.getBufferInt().put(0, sampler), 0", keepParam = true) int sampler);
104 void glDeleteSamplers(@Constant("1") @GLsizei int count, @Constant(value = "APIUtil.getBufferInt().put(0, sampler), 0", keepParam = true) int sampler);
103105
104106 boolean glIsSampler(@GLuint int sampler);
105107
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
35 import org.lwjgl.util.generator.opengl.*;
3436
3537 import java.nio.ByteBuffer;
3638 import java.nio.DoubleBuffer;
4547 // ----------------------[ ARB_draw_buffers_blend ]----------------------
4648 // ----------------------------------------------------------------------
4749
48 @Optional(reason = "AMD's 4.0 implementation does not expose this (last driver checked: 10.3)")
4950 void glBlendEquationi(@GLuint int buf, @GLenum int mode);
5051
51 @Optional(reason = "AMD's 4.0 implementation does not expose this (last driver checked: 10.3)")
5252 void glBlendEquationSeparatei(@GLuint int buf, @GLenum int modeRGB, @GLenum int modeAlpha);
5353
54 @Optional(reason = "AMD's 4.0 implementation does not expose this (last driver checked: 10.3)")
5554 void glBlendFunci(@GLuint int buf, @GLenum int src, @GLenum int dst);
5655
57 @Optional(reason = "AMD's 4.0 implementation does not expose this (last driver checked: 10.3)")
5856 void glBlendFuncSeparatei(@GLuint int buf, @GLenum int srcRGB, @GLenum int dstRGB, @GLenum int srcAlpha, @GLenum int dstAlpha);
5957
6058 // -----------------------------------------------------------------
185183 */
186184 int GL_MIN_SAMPLE_SHADING_VALUE = 0x8C37;
187185
188 @Optional(reason = "AMD's 4.0 implementation does not expose this (last driver checked: 10.3)")
186 @Optional(reason = "AMD does not expose this (last driver checked: 10.9)")
189187 void glMinSampleShading(@GLclampf float value);
190188
191189 // ---------------------------------------------------------------------
405403 void glDeleteTransformFeedbacks(@AutoSize("ids") @GLsizei int n, @Const @GLuint IntBuffer ids);
406404
407405 @Alternate("glDeleteTransformFeedbacks")
408 void glDeleteTransformFeedbacks(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, id), 0", keepParam = true) int id);
406 void glDeleteTransformFeedbacks(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, id), 0", keepParam = true) int id);
409407
410408 void glGenTransformFeedbacks(@AutoSize("ids") @GLsizei int n, @OutParameter @GLuint IntBuffer ids);
411409
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 import org.lwjgl.util.generator.opengl.*;
35
36 import java.nio.*;
37
38 public interface GL41 {
39
40 // ---------------------------------------------------------------------
41 // ----------------------[ ARB_ES2_compatibility ]----------------------
42 // ---------------------------------------------------------------------
43
44 /**
45 * Accepted by the &lt;value&gt; parameter of GetBooleanv, GetIntegerv,
46 * GetInteger64v, GetFloatv, and GetDoublev:
47 */
48 int GL_SHADER_COMPILER = 0x8DFA,
49 GL_NUM_SHADER_BINARY_FORMATS = 0x8DF9,
50 GL_MAX_VERTEX_UNIFORM_VECTORS = 0x8DFB,
51 GL_MAX_VARYING_VECTORS = 0x8DFC,
52 GL_MAX_FRAGMENT_UNIFORM_VECTORS = 0x8DFD,
53 GL_IMPLEMENTATION_COLOR_READ_TYPE = 0x8B9A,
54 GL_IMPLEMENTATION_COLOR_READ_FORMAT = 0x8B9B;
55
56 /** Accepted by the &lt;type&gt; parameter of VertexAttribPointer: */
57 int GL_FIXED = 0x140C;
58
59 /**
60 * Accepted by the &lt;precisiontype&gt; parameter of
61 * GetShaderPrecisionFormat:
62 */
63 int GL_LOW_FLOAT = 0x8DF0,
64 GL_MEDIUM_FLOAT = 0x8DF1,
65 GL_HIGH_FLOAT = 0x8DF2,
66 GL_LOW_INT = 0x8DF3,
67 GL_MEDIUM_INT = 0x8DF4,
68 GL_HIGH_INT = 0x8DF5;
69
70 @Optional(reason = "Not exposed in ATI Catalyst 10.10c")
71 void glReleaseShaderCompiler();
72
73 @Optional(reason = "Not exposed in ATI Catalyst 10.10c")
74 void glShaderBinary(@AutoSize("shaders") @GLsizei int count, @Const @GLuint IntBuffer shaders,
75 @GLenum int binaryformat, @Const @GLvoid ByteBuffer binary, @AutoSize("binary") @GLsizei int length);
76
77 @Optional(reason = "Not exposed in ATI Catalyst 10.10c")
78 void glGetShaderPrecisionFormat(@GLenum int shadertype, @GLenum int precisiontype,
79 @OutParameter @Check("2") IntBuffer range,
80 @OutParameter @Check("1") IntBuffer precision);
81
82 @Optional(reason = "Not exposed in ATI Catalyst 10.10c")
83 void glDepthRangef(@GLclampf float n, @GLclampf float f);
84
85 @Optional(reason = "Not exposed in ATI Catalyst 10.10c")
86 void glClearDepthf(@GLclampf float d);
87
88 // ----------------------------------------------------------------------
89 // ----------------------[ ARB_get_program_binary ]----------------------
90 // ----------------------------------------------------------------------
91
92 /**
93 * Accepted by the &lt;pname&gt; parameter of ProgramParameteri and
94 * GetProgramiv:
95 */
96 int GL_PROGRAM_BINARY_RETRIEVABLE_HINT = 0x8257;
97
98 /** Accepted by the &lt;pname&gt; parameter of GetProgramiv: */
99 int GL_PROGRAM_BINARY_LENGTH = 0x8741;
100
101 /**
102 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
103 * GetInteger64v, GetFloatv and GetDoublev:
104 */
105 int GL_NUM_PROGRAM_BINARY_FORMATS = 0x87FE,
106 GL_PROGRAM_BINARY_FORMATS = 0x87FF;
107
108 void glGetProgramBinary(@GLuint int program, @AutoSize("binary") @GLsizei int bufSize,
109 @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length,
110 @Check("1") @GLenum IntBuffer binaryFormat,
111 @OutParameter @GLvoid ByteBuffer binary);
112
113 void glProgramBinary(@GLuint int program, @GLenum int binaryFormat, @Const @GLvoid ByteBuffer binary, @AutoSize("binary") @GLsizei int length);
114
115 void glProgramParameteri(@GLuint int program, @GLenum int pname, int value);
116
117 // ---------------------------------------------------------------------------
118 // ----------------------[ ARB_separate_shader_objects ]----------------------
119 // ---------------------------------------------------------------------------
120
121 /** Accepted by &lt;stages&gt; parameter to UseProgramStages: */
122 int GL_VERTEX_SHADER_BIT = 0x00000001,
123 GL_FRAGMENT_SHADER_BIT = 0x00000002,
124 GL_GEOMETRY_SHADER_BIT = 0x00000004,
125 GL_TESS_CONTROL_SHADER_BIT = 0x00000008,
126 GL_TESS_EVALUATION_SHADER_BIT = 0x00000010,
127 GL_ALL_SHADER_BITS = 0xFFFFFFFF;
128
129 /**
130 * Accepted by the &lt;pname&gt; parameter of ProgramParameteri and
131 * GetProgramiv:
132 */
133 int GL_PROGRAM_SEPARABLE = 0x8258;
134
135 /** Accepted by &lt;type&gt; parameter to GetProgramPipelineiv: */
136 int GL_ACTIVE_PROGRAM = 0x8259;
137
138 /**
139 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv,
140 * GetInteger64v, GetFloatv, and GetDoublev:
141 */
142 int GL_PROGRAM_PIPELINE_BINDING = 0x825A;
143
144 void glUseProgramStages(@GLuint int pipeline, @GLbitfield int stages, @GLuint int program);
145
146 void glActiveShaderProgram(@GLuint int pipeline, @GLuint int program);
147
148 @StripPostfix(value = "strings", postfix = "v")
149 @GLuint
150 int glCreateShaderProgramv(@GLenum int type, @GLsizei int count, @Check @Const @Indirect @GLchar ByteBuffer strings);
151
152 @Alternate("glCreateShaderProgramv")
153 @StripPostfix(value = "string", postfix = "v")
154 @GLuint
155 int glCreateShaderProgramv(@GLenum int type, @Constant("1") @GLsizei int count, @NullTerminated CharSequence string);
156
157 @Alternate("glCreateShaderProgramv")
158 @StripPostfix(value = "strings", postfix = "v")
159 @GLuint
160 int glCreateShaderProgramv(@GLenum int type, @Constant("strings.length") @GLsizei int count,
161 @Const @NullTerminated @PointerArray(value = "count") CharSequence[] strings);
162
163 void glBindProgramPipeline(@GLuint int pipeline);
164
165 void glDeleteProgramPipelines(@AutoSize("pipelines") @GLsizei int n, @Const @GLuint IntBuffer pipelines);
166
167 @Alternate("glDeleteProgramPipelines")
168 void glDeleteProgramPipelines(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, pipeline), 0", keepParam = true) int pipeline);
169
170 void glGenProgramPipelines(@AutoSize("pipelines") @GLsizei int n, @OutParameter @GLuint IntBuffer pipelines);
171
172 @Alternate("glGenProgramPipelines")
173 @GLreturn("pipelines")
174 void glGenProgramPipelines2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer pipelines);
175
176 boolean glIsProgramPipeline(@GLuint int pipeline);
177
178 @StripPostfix("params")
179 void glGetProgramPipelineiv(@GLuint int pipeline, @GLenum int pname, @OutParameter @Check("1") IntBuffer params);
180
181 @Alternate("glGetProgramPipelineiv")
182 @GLreturn("params")
183 @StripPostfix("params")
184 void glGetProgramPipelineiv2(@GLuint int pipeline, @GLenum int pname, @OutParameter IntBuffer params);
185
186 void glProgramUniform1i(@GLuint int program, int location, int v0);
187
188 void glProgramUniform2i(@GLuint int program, int location, int v0, int v1);
189
190 void glProgramUniform3i(@GLuint int program, int location, int v0, int v1, int v2);
191
192 void glProgramUniform4i(@GLuint int program, int location, int v0, int v1, int v2, int v3);
193
194 void glProgramUniform1f(@GLuint int program, int location, float v0);
195
196 void glProgramUniform2f(@GLuint int program, int location, float v0, float v1);
197
198 void glProgramUniform3f(@GLuint int program, int location, float v0, float v1, float v2);
199
200 void glProgramUniform4f(@GLuint int program, int location, float v0, float v1, float v2, float v3);
201
202 void glProgramUniform1d(@GLuint int program, int location, double v0);
203
204 void glProgramUniform2d(@GLuint int program, int location, double v0, double v1);
205
206 void glProgramUniform3d(@GLuint int program, int location, double v0, double v1, double v2);
207
208 void glProgramUniform4d(@GLuint int program, int location, double v0, double v1, double v2, double v3);
209
210 @StripPostfix("value")
211 void glProgramUniform1iv(@GLuint int program, int location, @AutoSize("value") @GLsizei int count, @Const IntBuffer value);
212
213 @StripPostfix("value")
214 void glProgramUniform2iv(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 1") @GLsizei int count, @Const IntBuffer value);
215
216 @StripPostfix("value")
217 void glProgramUniform3iv(@GLuint int program, int location, @AutoSize(value = "value", expression = " / 3") @GLsizei int count, @Const IntBuffer value);
218
219 @StripPostfix("value")
220 void glProgramUniform4iv(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, @Const IntBuffer value);
221
222 @StripPostfix("value")
223 void glProgramUniform1fv(@GLuint int program, int location, @AutoSize("value") @GLsizei int count, @Const FloatBuffer value);
224
225 @StripPostfix("value")
226 void glProgramUniform2fv(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 1") @GLsizei int count, @Const FloatBuffer value);
227
228 @StripPostfix("value")
229 void glProgramUniform3fv(@GLuint int program, int location, @AutoSize(value = "value", expression = " / 3") @GLsizei int count, @Const FloatBuffer value);
230
231 @StripPostfix("value")
232 void glProgramUniform4fv(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, @Const FloatBuffer value);
233
234 @StripPostfix("value")
235 void glProgramUniform1dv(@GLuint int program, int location, @AutoSize("value") @GLsizei int count, @Const DoubleBuffer value);
236
237 @StripPostfix("value")
238 void glProgramUniform2dv(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 1") @GLsizei int count, @Const DoubleBuffer value);
239
240 @StripPostfix("value")
241 void glProgramUniform3dv(@GLuint int program, int location, @AutoSize(value = "value", expression = " / 3") @GLsizei int count, @Const DoubleBuffer value);
242
243 @StripPostfix("value")
244 void glProgramUniform4dv(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, @Const DoubleBuffer value);
245
246 void glProgramUniform1ui(@GLuint int program, int location, int v0);
247
248 void glProgramUniform2ui(@GLuint int program, int location, int v0, int v1);
249
250 void glProgramUniform3ui(@GLuint int program, int location, int v0, int v1, int v2);
251
252 void glProgramUniform4ui(@GLuint int program, int location, int v0, int v1, int v2, int v3);
253
254 @StripPostfix("value")
255 void glProgramUniform1uiv(@GLuint int program, int location, @AutoSize("value") @GLsizei int count, @Const IntBuffer value);
256
257 @StripPostfix("value")
258 void glProgramUniform2uiv(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 1") @GLsizei int count, @Const IntBuffer value);
259
260 @StripPostfix("value")
261 void glProgramUniform3uiv(@GLuint int program, int location, @AutoSize(value = "value", expression = " / 3") @GLsizei int count, @Const IntBuffer value);
262
263 @StripPostfix("value")
264 void glProgramUniform4uiv(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, @Const IntBuffer value);
265
266 @StripPostfix("value")
267 void glProgramUniformMatrix2fv(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, boolean transpose, @Const FloatBuffer value);
268
269 @StripPostfix("value")
270 void glProgramUniformMatrix3fv(@GLuint int program, int location, @AutoSize(value = "value", expression = " / (3 * 3)") @GLsizei int count, boolean transpose, @Const FloatBuffer value);
271
272 @StripPostfix("value")
273 void glProgramUniformMatrix4fv(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 4") @GLsizei int count, boolean transpose, @Const FloatBuffer value);
274
275 @StripPostfix("value")
276 void glProgramUniformMatrix2dv(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
277
278 @StripPostfix("value")
279 void glProgramUniformMatrix3dv(@GLuint int program, int location, @AutoSize(value = "value", expression = " / (3 * 3)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
280
281 @StripPostfix("value")
282 void glProgramUniformMatrix4dv(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 4") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
283
284 @StripPostfix("value")
285 void glProgramUniformMatrix2x3fv(@GLuint int program, int location,
286 @AutoSize(value = "value", expression = " / (2 * 3)") @GLsizei int count, boolean transpose, @Const FloatBuffer value);
287
288 @StripPostfix("value")
289 void glProgramUniformMatrix3x2fv(@GLuint int program, int location,
290 @AutoSize(value = "value", expression = " / (3 * 2)") @GLsizei int count, boolean transpose, @Const FloatBuffer value);
291
292 @StripPostfix("value")
293 void glProgramUniformMatrix2x4fv(@GLuint int program, int location,
294 @AutoSize(value = "value", expression = " >> 3") @GLsizei int count, boolean transpose, @Const FloatBuffer value);
295
296 @StripPostfix("value")
297 void glProgramUniformMatrix4x2fv(@GLuint int program, int location,
298 @AutoSize(value = "value", expression = " >> 3") @GLsizei int count, boolean transpose, @Const FloatBuffer value);
299
300 @StripPostfix("value")
301 void glProgramUniformMatrix3x4fv(@GLuint int program, int location,
302 @AutoSize(value = "value", expression = " / (3 * 4)") @GLsizei int count, boolean transpose, @Const FloatBuffer value);
303
304 @StripPostfix("value")
305 void glProgramUniformMatrix4x3fv(@GLuint int program, int location,
306 @AutoSize(value = "value", expression = " / (4 * 3)") @GLsizei int count, boolean transpose, @Const FloatBuffer value);
307
308 @StripPostfix("value")
309 void glProgramUniformMatrix2x3dv(@GLuint int program, int location,
310 @AutoSize(value = "value", expression = " / (2 * 3)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
311
312 @StripPostfix("value")
313 void glProgramUniformMatrix3x2dv(@GLuint int program, int location,
314 @AutoSize(value = "value", expression = " / (3 * 2)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
315
316 @StripPostfix("value")
317 void glProgramUniformMatrix2x4dv(@GLuint int program, int location,
318 @AutoSize(value = "value", expression = " >> 3") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
319
320 @StripPostfix("value")
321 void glProgramUniformMatrix4x2dv(@GLuint int program, int location,
322 @AutoSize(value = "value", expression = " >> 3") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
323
324 @StripPostfix("value")
325 void glProgramUniformMatrix3x4dv(@GLuint int program, int location,
326 @AutoSize(value = "value", expression = " / (3 * 4)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
327
328 @StripPostfix("value")
329 void glProgramUniformMatrix4x3dv(@GLuint int program, int location,
330 @AutoSize(value = "value", expression = " / (4 * 3)") @GLsizei int count, boolean transpose, @Const DoubleBuffer value);
331
332 void glValidateProgramPipeline(@GLuint int pipeline);
333
334 void glGetProgramPipelineInfoLog(@GLuint int pipeline, @AutoSize("infoLog") @GLsizei int bufSize,
335 @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length,
336 @OutParameter @GLchar ByteBuffer infoLog);
337
338 @Alternate("glGetProgramPipelineInfoLog")
339 @GLreturn(value = "infoLog", maxLength = "bufSize")
340 void glGetProgramPipelineInfoLog2(@GLuint int pipeline, @GLsizei int bufSize,
341 @OutParameter @GLsizei @Constant("infoLog_length, 0") IntBuffer length,
342 @OutParameter @GLchar ByteBuffer infoLog);
343
344 // -----------------------------------------------------------------------
345 // ----------------------[ ARB_vertex_attrib_64bit ]----------------------
346 // -----------------------------------------------------------------------
347
348 /** Returned in the &lt;type&gt; parameter of GetActiveAttrib: */
349 int GL_DOUBLE_VEC2 = 0x8FFC;
350 int GL_DOUBLE_VEC3 = 0x8FFD;
351 int GL_DOUBLE_VEC4 = 0x8FFE;
352 int GL_DOUBLE_MAT2 = 0x8F46;
353 int GL_DOUBLE_MAT3 = 0x8F47;
354 int GL_DOUBLE_MAT4 = 0x8F48;
355 int GL_DOUBLE_MAT2x3 = 0x8F49;
356 int GL_DOUBLE_MAT2x4 = 0x8F4A;
357 int GL_DOUBLE_MAT3x2 = 0x8F4B;
358 int GL_DOUBLE_MAT3x4 = 0x8F4C;
359 int GL_DOUBLE_MAT4x2 = 0x8F4D;
360 int GL_DOUBLE_MAT4x3 = 0x8F4E;
361
362 @Optional(reason = "Not exposed in ATI Catalyst 10.10c")
363 void glVertexAttribL1d(@GLuint int index, double x);
364
365 @Optional(reason = "Not exposed in ATI Catalyst 10.10c")
366 void glVertexAttribL2d(@GLuint int index, double x, double y);
367
368 @Optional(reason = "Not exposed in ATI Catalyst 10.10c")
369 void glVertexAttribL3d(@GLuint int index, double x, double y, double z);
370
371 @Optional(reason = "Not exposed in ATI Catalyst 10.10c")
372 void glVertexAttribL4d(@GLuint int index, double x, double y, double z, double w);
373
374 @Optional(reason = "Not exposed in ATI Catalyst 10.10c")
375 @StripPostfix("v")
376 void glVertexAttribL1dv(@GLuint int index, @Const @Check("1") DoubleBuffer v);
377
378 @Optional(reason = "Not exposed in ATI Catalyst 10.10c")
379 @StripPostfix("v")
380 void glVertexAttribL2dv(@GLuint int index, @Const @Check("2") DoubleBuffer v);
381
382 @Optional(reason = "Not exposed in ATI Catalyst 10.10c")
383 @StripPostfix("v")
384 void glVertexAttribL3dv(@GLuint int index, @Const @Check("3") DoubleBuffer v);
385
386 @Optional(reason = "Not exposed in ATI Catalyst 10.10c")
387 @StripPostfix("v")
388 void glVertexAttribL4dv(@GLuint int index, @Const @Check("4") DoubleBuffer v);
389
390 @Optional(reason = "Not exposed in ATI Catalyst 10.10c")
391 void glVertexAttribLPointer(@GLuint int index, int size, @Constant("GL11.GL_DOUBLE") @GLenum int type, @GLsizei int stride,
392 @CachedReference(index = "index", name = "glVertexAttribPointer_buffer")
393 @BufferObject(BufferKind.ArrayVBO)
394 @Check @Const @GLdouble Buffer pointer);
395
396 @Optional(reason = "Not exposed in ATI Catalyst 10.10c")
397 @StripPostfix("params")
398 void glGetVertexAttribLdv(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") DoubleBuffer params);
399
400 // ------------------------------------------------------------------
401 // ----------------------[ ARB_viewport_array ]----------------------
402 // ------------------------------------------------------------------
403
404 /**
405 * Accepted by the &lt;pname&gt; parameter of GetBooleanv, GetIntegerv, GetFloatv,
406 * GetDoublev and GetInteger64v:
407 */
408 int GL_MAX_VIEWPORTS = 0x825B,
409 GL_VIEWPORT_SUBPIXEL_BITS = 0x825C,
410 GL_VIEWPORT_BOUNDS_RANGE = 0x825D,
411 GL_LAYER_PROVOKING_VERTEX = 0x825E,
412 GL_VIEWPORT_INDEX_PROVOKING_VERTEX = 0x825F;
413
414 /** Accepted by the &lt;pname&gt; parameter of GetIntegeri_v: */
415 int GL_SCISSOR_BOX = 0x0C10;
416
417 /** Accepted by the &lt;pname&gt; parameter of GetFloati_v: */
418 int GL_VIEWPORT = 0x0BA2;
419
420 /** Accepted by the &lt;pname&gt; parameter of GetDoublei_v: */
421 int GL_DEPTH_RANGE = 0x0B70;
422
423 /** Accepted by the &lt;pname&gt; parameter of Enablei, Disablei, and IsEnabledi: */
424 int GL_SCISSOR_TEST = 0x0C11;
425
426 /**
427 * Returned in the &lt;data&gt; parameter from a Get query with a &lt;pname&gt; of
428 * LAYER_PROVOKING_VERTEX or VIEWPORT_INDEX_PROVOKING_VERTEX:
429 */
430 int GL_FIRST_VERTEX_CONVENTION = 0x8E4D,
431 GL_LAST_VERTEX_CONVENTION = 0x8E4E,
432 GL_PROVOKING_VERTEX = 0x8E4F,
433 GL_UNDEFINED_VERTEX = 0x8260;
434
435 @StripPostfix("v")
436 void glViewportArrayv(@GLuint int first, @AutoSize(value = "v", expression = " >> 2") @GLsizei int count, @Const FloatBuffer v);
437
438 void glViewportIndexedf(@GLuint int index, float x, float y, float w, float h);
439
440 @StripPostfix("v")
441 void glViewportIndexedfv(@GLuint int index, @Check("4") @Const FloatBuffer v);
442
443 @StripPostfix("v")
444 void glScissorArrayv(@GLuint int first, @AutoSize(value = "v", expression = " >> 2") @GLsizei int count, @Const IntBuffer v);
445
446 void glScissorIndexed(@GLuint int index, int left, int bottom, @GLsizei int width, @GLsizei int height);
447
448 @StripPostfix("v")
449 void glScissorIndexedv(@GLuint int index, @Check("4") @Const IntBuffer v);
450
451 @StripPostfix("v")
452 void glDepthRangeArrayv(@GLuint int first, @AutoSize(value = "v", expression = " >> 1") @GLsizei int count, @Const @GLclampd DoubleBuffer v);
453
454 void glDepthRangeIndexed(@GLuint int index, @GLclampd double n, @GLclampd double f);
455
456 @StripPostfix("data")
457 void glGetFloati_v(@GLenum int target, @GLuint int index, @Check @OutParameter FloatBuffer data);
458
459 @Alternate("glGetFloati_v")
460 @GLreturn("data")
461 @StripPostfix("data")
462 void glGetFloati_v2(@GLenum int target, @GLuint int index, @OutParameter FloatBuffer data);
463
464 @StripPostfix("data")
465 void glGetDoublei_v(@GLenum int target, @GLuint int index, @Check @OutParameter DoubleBuffer data);
466
467 @Alternate("glGetDoublei_v")
468 @GLreturn("data")
469 @StripPostfix("data")
470 void glGetDoublei_v2(@GLenum int target, @GLuint int index, @OutParameter DoubleBuffer data);
471
472 }
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
35 import org.lwjgl.util.generator.opengl.GLsizei;
3436
3537 import java.nio.ByteBuffer;
3638
3030 */
3131 package org.lwjgl.opengl;
3232
33 import org.lwjgl.util.generator.GLenum;
34 import org.lwjgl.util.generator.GLuint;
33 import org.lwjgl.util.generator.opengl.GLenum;
34 import org.lwjgl.util.generator.opengl.GLuint;
3535
3636 public interface NV_conditional_render {
3737
3030 */
3131 package org.lwjgl.opengl;
3232
33 import org.lwjgl.util.generator.GLenum;
34 import org.lwjgl.util.generator.GLsizei;
35 import org.lwjgl.util.generator.GLuint;
33 import org.lwjgl.util.generator.opengl.GLenum;
34 import org.lwjgl.util.generator.opengl.GLsizei;
35 import org.lwjgl.util.generator.opengl.GLuint;
3636
3737 public interface NV_copy_image {
3838
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.GLenum;
35 import org.lwjgl.util.generator.opengl.GLfloat;
36 import org.lwjgl.util.generator.opengl.GLsizei;
37 import org.lwjgl.util.generator.opengl.GLuint;
3438
3539 import java.nio.*;
3640
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
35 import org.lwjgl.util.generator.opengl.*;
3436
3537 import java.nio.ByteBuffer;
3638 import java.nio.FloatBuffer;
7476 int GL_INT_SAMPLER_RENDERBUFFER_NV = 0x8E57;
7577 int GL_UNSIGNED_INT_SAMPLER_RENDERBUFFER_NV = 0x8E58;
7678
79 @Reuse("EXTDrawBuffers2")
7780 @StripPostfix(value = "data", extension = "EXT")
78 void glGetBooleanIndexedvEXT(@GLenum int pname, @GLuint int index, @OutParameter @Check("16") @GLboolean ByteBuffer data);
81 void glGetBooleanIndexedvEXT(@GLenum int pname, @GLuint int index, @OutParameter @Check("4") @GLboolean ByteBuffer data);
7982
83 @Reuse("EXTDrawBuffers2")
8084 @Alternate("glGetBooleanIndexedvEXT")
8185 @GLreturn("data")
8286 @StripPostfix(value = "data", extension = "EXT")
8387 void glGetBooleanIndexedvEXT2(@GLenum int pname, @GLuint int index, @OutParameter @GLboolean ByteBuffer data);
8488
89 @Reuse("EXTDrawBuffers2")
8590 @StripPostfix(value = "data", extension = "EXT")
8691 void glGetIntegerIndexedvEXT(@GLenum int pname, @GLuint int index, @OutParameter @Check("16") IntBuffer data);
8792
93 @Reuse("EXTDrawBuffers2")
8894 @Alternate("glGetIntegerIndexedvEXT")
8995 @GLreturn("data")
9096 @StripPostfix(value = "data", extension = "EXT")
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
35 import org.lwjgl.util.generator.opengl.GLenum;
36 import org.lwjgl.util.generator.opengl.GLreturn;
37 import org.lwjgl.util.generator.opengl.GLsizei;
38 import org.lwjgl.util.generator.opengl.GLuint;
3439
3540 import java.nio.*;
3641
4853 void glDeleteFencesNV(@AutoSize("piFences") @GLsizei int n, @Const @GLuint IntBuffer piFences);
4954
5055 @Alternate("glDeleteFencesNV")
51 void glDeleteFencesNV(@Constant("1") @GLsizei int n, @Const @GLuint @Constant(value = "APIUtils.getBufferInt().put(0, fence), 0", keepParam = true) int fence);
56 void glDeleteFencesNV(@Constant("1") @GLsizei int n, @Const @GLuint @Constant(value = "APIUtil.getBufferInt().put(0, fence), 0", keepParam = true) int fence);
5257
5358 void glSetFenceNV(@GLuint int fence, @GLenum int condition);
5459
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.GLsizei;
35 import org.lwjgl.util.generator.opengl.GLubyte;
36 import org.lwjgl.util.generator.opengl.GLuint;
3437
3538 import java.nio.*;
3639
3030 */
3131 package org.lwjgl.opengl;
3232
33 import org.lwjgl.util.generator.GLenum;
34 import org.lwjgl.util.generator.GLsizei;
33 import org.lwjgl.util.generator.opengl.GLenum;
34 import org.lwjgl.util.generator.opengl.GLsizei;
3535
3636 public interface NV_framebuffer_multisample_coverage {
3737
4141
4242 /** Accepted by the &lt;pname&gt; parameter of GetIntegerv. */
4343 int GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV = 0x8E11;
44 int GL_MULITSAMPLE_COVERAGE_MODES_NV = 0x8E12;
44 int GL_MULTISAMPLE_COVERAGE_MODES_NV = 0x8E12;
4545
4646 void glRenderbufferStorageMultisampleCoverageNV(@GLenum int target, @GLsizei int coverageSamples, @GLsizei int colorSamples,
4747 @GLenum int internalformat, @GLsizei int width, @GLsizei int height);
3030 */
3131 package org.lwjgl.opengl;
3232
33 import org.lwjgl.util.generator.GLenum;
34 import org.lwjgl.util.generator.GLuint;
33 import org.lwjgl.util.generator.Reuse;
34 import org.lwjgl.util.generator.opengl.GLenum;
35 import org.lwjgl.util.generator.opengl.GLuint;
3536
3637 public interface NV_geometry_program4 {
3738
4849
4950 void glProgramVertexLimitNV(@GLenum int target, int limit);
5051
52 @Reuse("EXTGeometryShader4")
5153 void glFramebufferTextureEXT(@GLenum int target, @GLenum int attachment, @GLuint int texture, int level);
5254
55 @Reuse("EXTGeometryShader4")
5356 void glFramebufferTextureLayerEXT(@GLenum int target, @GLenum int attachment, @GLuint int texture, int level, int layer);
5457
58 @Reuse("EXTGeometryShader4")
5559 void glFramebufferTextureFaceEXT(@GLenum int target, @GLenum int attachment, @GLuint int texture, int level, @GLenum int face);
5660
5761 }
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.GLenum;
35 import org.lwjgl.util.generator.opengl.GLsizei;
36 import org.lwjgl.util.generator.opengl.GLuint;
3437
3538 import java.nio.IntBuffer;
3639
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.GLint64EXT;
35 import org.lwjgl.util.generator.opengl.GLsizei;
36 import org.lwjgl.util.generator.opengl.GLuint;
37 import org.lwjgl.util.generator.opengl.GLuint64EXT;
3438
3539 import java.nio.LongBuffer;
3640
8387 void glUniform4i64NV(int location, @GLint64EXT long x, @GLint64EXT long y, @GLint64EXT long z, @GLint64EXT long w);
8488
8589 @StripPostfix("value")
86 void glUniform1i64vNV(int location, @GLsizei int count, @Const @GLint64EXT @Check("1") LongBuffer value);
90 void glUniform1i64vNV(int location, @AutoSize("value") @GLsizei int count, @Const @GLint64EXT LongBuffer value);
8791
8892 @StripPostfix("value")
89 void glUniform2i64vNV(int location, @GLsizei int count, @Const @GLint64EXT @Check("2") LongBuffer value);
93 void glUniform2i64vNV(int location, @AutoSize(value = "value", expression = " >> 1") @GLsizei int count, @Const @GLint64EXT LongBuffer value);
9094
9195 @StripPostfix("value")
92 void glUniform3i64vNV(int location, @GLsizei int count, @Const @GLint64EXT @Check("3") LongBuffer value);
96 void glUniform3i64vNV(int location, @AutoSize(value = "value", expression = " / 3") @GLsizei int count, @Const @GLint64EXT LongBuffer value);
9397
9498 @StripPostfix("value")
95 void glUniform4i64vNV(int location, @GLsizei int count, @Const @GLint64EXT @Check("4") LongBuffer value);
99 void glUniform4i64vNV(int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, @Const @GLint64EXT LongBuffer value);
96100
97101 void glUniform1ui64NV(int location, @GLuint64EXT long x);
98102
103107 void glUniform4ui64NV(int location, @GLuint64EXT long x, @GLuint64EXT long y, @GLuint64EXT long z, @GLuint64EXT long w);
104108
105109 @StripPostfix("value")
106 void glUniform1ui64vNV(int location, @GLsizei int count, @Const @GLuint64EXT @Check("1") LongBuffer value);
110 void glUniform1ui64vNV(int location, @AutoSize("value") @GLsizei int count, @Const @GLuint64EXT LongBuffer value);
107111
108112 @StripPostfix("value")
109 void glUniform2ui64vNV(int location, @GLsizei int count, @Const @GLuint64EXT @Check("2") LongBuffer value);
113 void glUniform2ui64vNV(int location, @AutoSize(value = "value", expression = " >> 1") @GLsizei int count, @Const @GLuint64EXT LongBuffer value);
110114
111115 @StripPostfix("value")
112 void glUniform3ui64vNV(int location, @GLsizei int count, @Const @GLuint64EXT @Check("3") LongBuffer value);
116 void glUniform3ui64vNV(int location, @AutoSize(value = "value", expression = " / 3") @GLsizei int count, @Const @GLuint64EXT LongBuffer value);
113117
114118 @StripPostfix("value")
115 void glUniform4ui64vNV(int location, @GLsizei int count, @Const @GLuint64EXT @Check("4") LongBuffer value);
119 void glUniform4ui64vNV(int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, @Const @GLuint64EXT LongBuffer value);
116120
117121 @StripPostfix("params")
118 void glGetUniformi64vNV(@GLuint int program, int location, @GLint64EXT @Check LongBuffer params);
122 void glGetUniformi64vNV(@GLuint int program, int location, @OutParameter @Check("1") @GLint64EXT LongBuffer params);
119123
120124 @StripPostfix("params")
121 void glGetUniformui64vNV(@GLuint int program, int location, @GLuint64EXT @Check LongBuffer params);
125 void glGetUniformui64vNV(@GLuint int program, int location, @OutParameter @Check("1") @GLuint64EXT LongBuffer params);
122126
123127 // -------------
124128
136140
137141 @Dependent("EXT_direct_state_access")
138142 @StripPostfix("value")
139 void glProgramUniform1i64vNV(@GLuint int program, int location, @GLsizei int count, @Const @GLint64EXT @Check("1") LongBuffer value);
143 void glProgramUniform1i64vNV(@GLuint int program, int location, @AutoSize("value") @GLsizei int count, @Const @GLint64EXT LongBuffer value);
140144
141145 @Dependent("EXT_direct_state_access")
142146 @StripPostfix("value")
143 void glProgramUniform2i64vNV(@GLuint int program, int location, @GLsizei int count, @Const @GLint64EXT @Check("2") LongBuffer value);
147 void glProgramUniform2i64vNV(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 1") @GLsizei int count, @Const @GLint64EXT LongBuffer value);
144148
145149 @Dependent("EXT_direct_state_access")
146150 @StripPostfix("value")
147 void glProgramUniform3i64vNV(@GLuint int program, int location, @GLsizei int count, @Const @GLint64EXT @Check("3") LongBuffer value);
151 void glProgramUniform3i64vNV(@GLuint int program, int location, @AutoSize(value = "value", expression = " / 3") @GLsizei int count, @Const @GLint64EXT LongBuffer value);
148152
149153 @Dependent("EXT_direct_state_access")
150154 @StripPostfix("value")
151 void glProgramUniform4i64vNV(@GLuint int program, int location, @GLsizei int count, @Const @GLint64EXT @Check("4") LongBuffer value);
155 void glProgramUniform4i64vNV(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, @Const @GLint64EXT LongBuffer value);
152156
153157 @Dependent("EXT_direct_state_access")
154158 void glProgramUniform1ui64NV(@GLuint int program, int location, @GLuint64EXT long x);
164168
165169 @Dependent("EXT_direct_state_access")
166170 @StripPostfix("value")
167 void glProgramUniform1ui64vNV(@GLuint int program, int location, @GLsizei int count, @Const @GLuint64EXT @Check("1") LongBuffer value);
171 void glProgramUniform1ui64vNV(@GLuint int program, int location, @AutoSize("value") @GLsizei int count, @Const @GLuint64EXT LongBuffer value);
168172
169173 @Dependent("EXT_direct_state_access")
170174 @StripPostfix("value")
171 void glProgramUniform2ui64vNV(@GLuint int program, int location, @GLsizei int count, @Const @GLuint64EXT @Check("2") LongBuffer value);
175 void glProgramUniform2ui64vNV(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 1") @GLsizei int count, @Const @GLuint64EXT LongBuffer value);
172176
173177 @Dependent("EXT_direct_state_access")
174178 @StripPostfix("value")
175 void glProgramUniform3ui64vNV(@GLuint int program, int location, @GLsizei int count, @Const @GLuint64EXT @Check("3") LongBuffer value);
179 void glProgramUniform3ui64vNV(@GLuint int program, int location, @AutoSize(value = "value", expression = " / 3") @GLsizei int count, @Const @GLuint64EXT LongBuffer value);
176180
177181 @Dependent("EXT_direct_state_access")
178182 @StripPostfix("value")
179 void glProgramUniform4ui64vNV(@GLuint int program, int location, @GLsizei int count, @Const @GLuint64EXT @Check("4") LongBuffer value);
183 void glProgramUniform4ui64vNV(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, @Const @GLuint64EXT LongBuffer value);
180184
181185 }
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.GLenum;
35 import org.lwjgl.util.generator.opengl.GLhalf;
36 import org.lwjgl.util.generator.opengl.GLsizei;
37 import org.lwjgl.util.generator.opengl.GLuint;
3438
3539 import java.nio.*;
3640
9397 @NoErrorCheck
9498 void glSecondaryColor3hNV(@GLhalf short red, @GLhalf short green, @GLhalf short blue);
9599
96 @Optional(reason = "AMD does not expose this (last driver checked: 10.3)")
100 @Optional(reason = "AMD does not expose this (last driver checked: 10.9)")
97101 @NoErrorCheck
98102 void glVertexWeighthNV(@GLhalf short weight);
99103
100 @Optional(reason = "AMD does not expose this (last driver checked: 10.3)")
104 @Optional(reason = "AMD does not expose this (last driver checked: 10.9)")
101105 @NoErrorCheck
102106 void glVertexAttrib1hNV(@GLuint int index, @GLhalf short x);
103107
104 @Optional(reason = "AMD does not expose this (last driver checked: 10.3)")
108 @Optional(reason = "AMD does not expose this (last driver checked: 10.9)")
105109 @NoErrorCheck
106110 void glVertexAttrib2hNV(@GLuint int index, @GLhalf short x, @GLhalf short y);
107111
108 @Optional(reason = "AMD does not expose this (last driver checked: 10.3)")
112 @Optional(reason = "AMD does not expose this (last driver checked: 10.9)")
109113 @NoErrorCheck
110114 void glVertexAttrib3hNV(@GLuint int index, @GLhalf short x, @GLhalf short y, @GLhalf short z);
111115
112 @Optional(reason = "AMD does not expose this (last driver checked: 10.3)")
116 @Optional(reason = "AMD does not expose this (last driver checked: 10.9)")
113117 @NoErrorCheck
114118 void glVertexAttrib4hNV(@GLuint int index, @GLhalf short x, @GLhalf short y, @GLhalf short z, @GLhalf short w);
115119
116 @Optional(reason = "AMD does not expose this (last driver checked: 10.3)")
120 @Optional(reason = "AMD does not expose this (last driver checked: 10.9)")
117121 @NoErrorCheck
118122 @StripPostfix("attribs")
119123 void glVertexAttribs1hvNV(@GLuint int index, @AutoSize("attribs") @GLsizei int n, @Const @GLhalf ShortBuffer attribs);
120124
121 @Optional(reason = "AMD does not expose this (last driver checked: 10.3)")
125 @Optional(reason = "AMD does not expose this (last driver checked: 10.9)")
122126 @NoErrorCheck
123127 @StripPostfix("attribs")
124128 void glVertexAttribs2hvNV(@GLuint int index, @AutoSize(value = "attribs", expression = " >> 1") @GLsizei int n, @Const @GLhalf ShortBuffer attribs);
125129
126 @Optional(reason = "AMD does not expose this (last driver checked: 10.3)")
130 @Optional(reason = "AMD does not expose this (last driver checked: 10.9)")
127131 @NoErrorCheck
128132 @StripPostfix("attribs")
129133 void glVertexAttribs3hvNV(@GLuint int index, @AutoSize(value = "attribs", expression = " / 3") @GLsizei int n, @Const @GLhalf ShortBuffer attribs);
130134
131 @Optional(reason = "AMD does not expose this (last driver checked: 10.3)")
135 @Optional(reason = "AMD does not expose this (last driver checked: 10.9)")
132136 @NoErrorCheck
133137 @StripPostfix("attribs")
134138 void glVertexAttribs4hvNV(@GLuint int index, @AutoSize(value = "attribs", expression = " >> 2") @GLsizei int n, @Const @GLhalf ShortBuffer attribs);
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
35 import org.lwjgl.util.generator.opengl.GLenum;
36 import org.lwjgl.util.generator.opengl.GLreturn;
37 import org.lwjgl.util.generator.opengl.GLsizei;
38 import org.lwjgl.util.generator.opengl.GLuint;
3439
3540 import java.nio.IntBuffer;
3641
5358 void glDeleteOcclusionQueriesNV(@AutoSize("piIDs") @GLsizei int n, @Const @GLuint IntBuffer piIDs);
5459
5560 @Alternate("glDeleteOcclusionQueriesNV")
56 void glDeleteOcclusionQueriesNV(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, piID), 0", keepParam = true) int piID);
61 void glDeleteOcclusionQueriesNV(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, piID), 0", keepParam = true) int piID);
5762
5863 boolean glIsOcclusionQueryNV(@GLuint int id);
5964
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.GLenum;
35 import org.lwjgl.util.generator.opengl.GLsizei;
36 import org.lwjgl.util.generator.opengl.GLuint;
3437
3538 import java.nio.FloatBuffer;
3639 import java.nio.IntBuffer;
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.*;
3435
3536 import java.nio.*;
3637
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.GLenum;
3435
3536 import java.nio.*;
3637
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.GLuint;
3435
3536 @ForceInit
3637 public interface NV_primitive_restart {
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
35 import org.lwjgl.util.generator.opengl.*;
3436
3537 import java.nio.Buffer;
3638 import java.nio.ByteBuffer;
6668 void glDeleteProgramsNV(@AutoSize("programs") @GLsizei int n, @Const @GLuint IntBuffer programs);
6769
6870 @Alternate("glDeleteProgramsNV")
69 void glDeleteProgramsNV(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, program), 0", keepParam = true) int program);
71 void glDeleteProgramsNV(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, program), 0", keepParam = true) int program);
7072
7173 void glGenProgramsNV(@AutoSize("programs") @GLsizei int n, @OutParameter @GLuint IntBuffer programs);
7274
98100 void glRequestResidentProgramsNV(@AutoSize("programIDs") @GLsizei int n, @GLuint IntBuffer programIDs);
99101
100102 @Alternate("glRequestResidentProgramsNV")
101 void glRequestResidentProgramsNV(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, programID), 0", keepParam = true) int programID);
103 void glRequestResidentProgramsNV(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, programID), 0", keepParam = true) int programID);
102104 }
103105
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
35 import org.lwjgl.util.generator.opengl.GLenum;
36 import org.lwjgl.util.generator.opengl.GLreturn;
3437
3538 import java.nio.*;
3639
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.GLenum;
3435
3536 import java.nio.*;
3637
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
35 import org.lwjgl.util.generator.opengl.*;
3436
3537 import java.nio.LongBuffer;
3638
8991 @StripPostfix("value")
9092 void glUniformui64vNV(int location, @AutoSize("value") @GLsizei int count, @Const @GLuint64EXT LongBuffer value);
9193
94 @Reuse("NVGpuShader5")
9295 @StripPostfix("params")
9396 void glGetUniformui64vNV(@GLuint int program, int location, @OutParameter @Check("1") @GLuint64EXT LongBuffer params);
9497
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
35 import org.lwjgl.util.generator.opengl.*;
3436
3537 import java.nio.ByteBuffer;
3638 import java.nio.IntBuffer;
149151 @Alternate(value = "glGetActiveVaryingNV", javaAlt = true)
150152 @GLreturn(value = "name", maxLength = "bufSize")
151153 void glGetActiveVaryingNV(@GLuint int program, @GLuint int index, @GLsizei int bufSize,
152 @OutParameter @GLsizei @Constant("name_length, 0, APIUtils.getBufferInt(), 0, APIUtils.getBufferInt(), 1") IntBuffer length,
154 @OutParameter @GLsizei @Constant("name_length, 0, APIUtil.getBufferInt(), 0, APIUtil.getBufferInt(), 1") IntBuffer length,
153155 @OutParameter @GLchar ByteBuffer name);
154156
155157 /** Overloads glGetActiveVaryingNV. This version returns only the varying size. */
159161 @OutParameter @GLsizei @Constant("null, 0") IntBuffer length,
160162 @OutParameter IntBuffer size,
161163 @OutParameter @GLenum @Constant("size, 1") IntBuffer type, // Reuse size buffer and ignore
162 @OutParameter @GLchar @Constant("APIUtils.getBufferByte(0), 0") ByteBuffer name);
164 @OutParameter @GLchar @Constant("APIUtil.getBufferByte(0), 0") ByteBuffer name);
163165
164166 /** Overloads glGetActiveVaryingNV. This version returns only the varying type. */
165167 @Alternate(value = "glGetActiveVaryingNV", javaAlt = true)
168170 @OutParameter @GLsizei @Constant("null, 0") IntBuffer length,
169171 @OutParameter @Constant("type, 1") IntBuffer size, // Reuse type buffer and ignore
170172 @OutParameter @GLenum IntBuffer type,
171 @OutParameter @GLchar @Constant("APIUtils.getBufferByte(0), 0") ByteBuffer name);
173 @OutParameter @GLchar @Constant("APIUtil.getBufferByte(0), 0") ByteBuffer name);
172174
173175 void glActiveVaryingNV(@GLuint int program, @NullTerminated @Const @GLchar ByteBuffer name);
174176
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
35 import org.lwjgl.util.generator.opengl.GLenum;
36 import org.lwjgl.util.generator.opengl.GLreturn;
37 import org.lwjgl.util.generator.opengl.GLsizei;
38 import org.lwjgl.util.generator.opengl.GLuint;
3439
3540 import java.nio.IntBuffer;
3641
5358 void glDeleteTransformFeedbacksNV(@AutoSize("ids") @GLsizei int n, @Const @GLuint IntBuffer ids);
5459
5560 @Alternate("glDeleteTransformFeedbacksNV")
56 void glDeleteTransformFeedbacksNV(@Constant("1") @GLsizei int n, @Constant(value = "APIUtils.getBufferInt().put(0, id), 0", keepParam = true) int id);
61 void glDeleteTransformFeedbacksNV(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, id), 0", keepParam = true) int id);
5762
5863 void glGenTransformFeedbacksNV(@AutoSize("ids") @GLsizei int n, @OutParameter @GLuint IntBuffer ids);
5964
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.*;
3435
3536 import java.nio.*;
3637
5354
5455 @PlatformDependent({Platform.WGL, Platform.GLX})
5556 @GLvoid
56 @AutoResultSize("size")
57 @AutoSize("size")
5758 ByteBuffer glAllocateMemoryNV(int size, float readFrequency, float writeFrequency, float priority);
5859
5960 @PlatformDependent({Platform.WGL, Platform.GLX})
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.*;
3435
3536 import java.nio.LongBuffer;
3637
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.Alternate;
35 import org.lwjgl.util.generator.opengl.*;
3436
3537 import java.nio.LongBuffer;
3638
3131 package org.lwjgl.opengl;
3232
3333 import org.lwjgl.util.generator.*;
34 import org.lwjgl.util.generator.opengl.*;
3435
3536 import java.nio.*;
3637
227228 void glTrackMatrixNV(@GLenum int target, @GLuint int address, @GLenum int matrix, @GLenum int transform);
228229
229230 void glVertexAttribPointerNV(@GLuint int index, int size, @GLenum int type, @GLsizei int stride,
230 @CachedReference(index="index",name="glVertexAttribPointer_buffer")
231 @CachedReference(index="index",name="glVertexAttribPointer_buffer")
231232 @BufferObject(BufferKind.ArrayVBO)
232233 @Check
233234 @Const